sun angle/rotation calculator

al167
Posts: 272
Joined: Sun Jan 01, 2012 10:34 pm
Team: Privateer

sun angle/rotation calculator

Postby al167 » Wed Sep 04, 2013 12:50 pm

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/2f7wi92f6h1qsrk/sun_angle_calculator.xlsx

SMR 510RR
Posts: 2517
Joined: Sun Apr 08, 2012 6:36 am
Team: Privateer

Re: sun angle/rotation calculator

Postby SMR 510RR » Wed Sep 11, 2013 6:38 pm

Awesome! Always my least favorite part of adding a new sky.

slowngreen
Posts: 906
Joined: Mon Sep 02, 2013 6:18 pm
Team: MotoPin Racing
Location: idaho

Re: sun angle/rotation calculator

Postby slowngreen » Sat Mar 29, 2014 7:16 pm

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: 272
Joined: Sun Jan 01, 2012 10:34 pm
Team: Privateer

Re: sun angle/rotation calculator

Postby al167 » Sun Aug 03, 2014 11:44 am

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

User avatar
ColtonD719
Posts: 366
Joined: Tue Jun 21, 2016 4:15 am
Team: Privateer
Location: Oregon
Contact:

Re: sun angle/rotation calculator

Postby ColtonD719 » Mon May 28, 2018 8:02 pm

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: 12824
Joined: Fri Nov 02, 2007 5:39 am
Team: No Frills Racing
Contact:

Re: sun angle/rotation calculator

Postby jlv » Tue May 29, 2018 12:35 am

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.

User avatar
ColtonD719
Posts: 366
Joined: Tue Jun 21, 2016 4:15 am
Team: Privateer
Location: Oregon
Contact:

Re: sun angle/rotation calculator

Postby ColtonD719 » Wed May 30, 2018 6:36 am

Cool. Thanks!

User avatar
ColtonD719
Posts: 366
Joined: Tue Jun 21, 2016 4:15 am
Team: Privateer
Location: Oregon
Contact:

Re: sun angle/rotation calculator

Postby ColtonD719 » Fri Jun 22, 2018 4:52 am

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: 12824
Joined: Fri Nov 02, 2007 5:39 am
Team: No Frills Racing
Contact:

Re: sun angle/rotation calculator

Postby jlv » Sat Jun 23, 2018 12:26 am

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.

User avatar
ColtonD719
Posts: 366
Joined: Tue Jun 21, 2016 4:15 am
Team: Privateer
Location: Oregon
Contact:

Re: sun angle/rotation calculator

Postby ColtonD719 » Sat Jun 23, 2018 12:44 am

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: 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: 12824
Joined: Fri Nov 02, 2007 5:39 am
Team: No Frills Racing
Contact:

Re: sun angle/rotation calculator

Postby jlv » Sun Jun 24, 2018 1:17 am

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.


Return to “Tutorials”

Who is online

Users browsing this forum: No registered users and 1 guest