sun angle/rotation calculator

Post Reply
al167
Posts: 275
Joined: Sun Jan 01, 2012 10:34 pm
Team: Privateer

sun angle/rotation calculator

Post 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
SMR 510RR
Posts: 2526
Joined: Sun Apr 08, 2012 6:36 am
Team: Privateer

Re: sun angle/rotation calculator

Post by SMR 510RR »

Awesome! Always my least favorite part of adding a new sky.
slowngreen
Posts: 907
Joined: Mon Sep 02, 2013 6:18 pm
Team: MotoPin Racing
Location: idaho

Re: sun angle/rotation calculator

Post 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?
Image
al167
Posts: 275
Joined: Sun Jan 01, 2012 10:34 pm
Team: Privateer

Re: sun angle/rotation calculator

Post 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
ColtonD719
Posts: 631
Joined: Tue Jun 21, 2016 4:15 am
Team: Privateer
Location: Oregon
Contact:

Re: sun angle/rotation calculator

Post 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:?
jlv
Site Admin
Posts: 14910
Joined: Fri Nov 02, 2007 5:39 am
Team: No Frills Racing
Contact:

Re: sun angle/rotation calculator

Post by jlv »

atan2(x, z)

You might have to swap/negate x and z to get the right quadrant.
Josh Vanderhoof
Sole Proprietor
jlv@mxsimulator.com
If you email, put "MX Simulator" in the subject to make sure it gets through my spam filter.
ColtonD719
Posts: 631
Joined: Tue Jun 21, 2016 4:15 am
Team: Privateer
Location: Oregon
Contact:

Re: sun angle/rotation calculator

Post by ColtonD719 »

Cool. Thanks!
ColtonD719
Posts: 631
Joined: Tue Jun 21, 2016 4:15 am
Team: Privateer
Location: Oregon
Contact:

Re: sun angle/rotation calculator

Post 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?
jlv
Site Admin
Posts: 14910
Joined: Fri Nov 02, 2007 5:39 am
Team: No Frills Racing
Contact:

Re: sun angle/rotation calculator

Post by jlv »

atan2(y,sqrt(x*x+z*z))
Josh Vanderhoof
Sole Proprietor
jlv@mxsimulator.com
If you email, put "MX Simulator" in the subject to make sure it gets through my spam filter.
ColtonD719
Posts: 631
Joined: Tue Jun 21, 2016 4:15 am
Team: Privateer
Location: Oregon
Contact:

Re: sun angle/rotation calculator

Post 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!
jlv
Site Admin
Posts: 14910
Joined: Fri Nov 02, 2007 5:39 am
Team: No Frills Racing
Contact:

Re: sun angle/rotation calculator

Post 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)".
Josh Vanderhoof
Sole Proprietor
jlv@mxsimulator.com
If you email, put "MX Simulator" in the subject to make sure it gets through my spam filter.
Post Reply