Page 1 of 1

sun angle/rotation calculator

Posted: Wed Sep 04, 2013 12:50 pm
by al167
heres a quick excel calculator for working out the lighting vectors for a specific sun direction and angle
thanks to jlv for the calculations needed.

http://www.mediafire.com/download/2f7wi ... lator.xlsx

Re: sun angle/rotation calculator

Posted: Wed Sep 11, 2013 6:38 pm
by SMR 510RR
Awesome! Always my least favorite part of adding a new sky.

Re: sun angle/rotation calculator

Posted: Sat Mar 29, 2014 7:16 pm
by slowngreen
Got one question. Which is the bottom of the map when your in editor? Is it the side thats at the bottom of your screen or is it the side with the gates in their stock position?

Re: sun angle/rotation calculator

Posted: Sun Aug 03, 2014 11:44 am
by al167
slowngreen wrote:Got one question. Which is the bottom of the map when your in editor? Is it the side thats at the bottom of your screen or is it the side with the gates in their stock position?
bottom of screen, sorry for slow reply :D

Re: sun angle/rotation calculator

Posted: Mon May 28, 2018 8:02 pm
by ColtonD719
What would the formula be to go the other way, i.e. from XYZ coordinates to angle/rotation? I feel like I should be able to figure this out, but my trigonometry skills are not what they used to be.

Basically I want to figure out what rotation to set for a plane statue so that it faces the sun.
jlv wrote:?

Re: sun angle/rotation calculator

Posted: Tue May 29, 2018 12:35 am
by jlv
atan2(x, z)

You might have to swap/negate x and z to get the right quadrant.

Re: sun angle/rotation calculator

Posted: Wed May 30, 2018 6:36 am
by ColtonD719
Cool. Thanks!

Re: sun angle/rotation calculator

Posted: Fri Jun 22, 2018 4:52 am
by ColtonD719
jlv wrote:atan2(x, z)

You might have to swap/negate x and z to get the right quadrant.
This was very helpful actually. What about getting the angle of the sun from the horizon, using XYZ coordinates?

Re: sun angle/rotation calculator

Posted: Sat Jun 23, 2018 12:26 am
by jlv
atan2(y,sqrt(x*x+z*z))

Re: sun angle/rotation calculator

Posted: Sat Jun 23, 2018 12:44 am
by ColtonD719
Awesome, thanks again! Definitely wouldn't have figured that out myself in any reasonable amount of time.

For anyone reading, here's a simple atan2 calculator I found: http://util.io/calculator

Also, here is a "ruler" I made for a sphere mapped sky: http://openlightpictures.com/pub/cd_SpheremapGrid.png

Using jlv's equations, and the ruler, you can quickly pinpoint where the sun should be on the sphere map to align with the in-game lighting. Then convert the sphere map to a skybox with this tool: http://forum.mxsimulator.com/viewtopic.php?f=11&t=2868

I may write a step-by-step tutorial at some point, but hopefully someone finds this useful in the meantime!

Re: sun angle/rotation calculator

Posted: Sun Jun 24, 2018 1:17 am
by jlv
You can use the javascript console in you browser to calculate pretty much anything. For atan2 it'd be "Math.atan2(y,x)".