Jump to content

llGetSunDirection and sun zenith/nadir


Ghosty Kips
 Share

You are about to reply to a thread that has been inactive for 4105 days.

Please take a moment to consider if this thread is worth bumping.

Recommended Posts

Those familiar with the llGetSunDirection know it's very easy to determine whether the sun is above or below the horizon. I am finding it very difficult to determine when, exactly, the sun is at it's zenith (high noon) or nadir (opposite the moon at midnight) using this function, however.

I am not concerned with the slight innacuracy with windlight, and I do not want to resort to timekeeping to determine when these two events occur; I just want zenith or nadir accoding to the SL sun's position <vector> alone. I am having difficulty interpreting the data from the llGetSunPosition vector and it appears to fluctuate quite a bit - and isn't nearly as concise and neat as " z axis is above / below 0."

Can anyone shed some light on how to best determne these two sun positions using LSL and the sun's reported position alone?

Link to comment
Share on other sites

given the seasonal shift that is in the sun direction code, it may be painful to calculate....

you'd need to calculate the angle of the plane that the sun is on, which will require two sampling of position. from there the easiest way would be to eliminate the angle, then zenith and nadir would be z = +/-1

Link to comment
Share on other sites

It's pretty much as simple as determining when it's on the horizon. Just as you can tell whether the sun is above or below the horizon looking at the z-axis, and know it just crossed the horizon when it transitions from positive to negative or back, you can look at the x-axis for whether it's east or west of your "longitude", and know that it's just past its zenith or nadir when the x-axis transitions from positive to negative or back. In theory, the sun is exactly on the horizon when z=0.0, and exactly at its zenith or nadir when x=0.0, but I'm not sure if it ever has that exact value, so you might have to watch for the transition across, or do a fuzzy compare.

Incidentally, the sun position updates every 10 seconds, so llSetTimerEvent(10.0) will let you poll the sun position and theoretically (in a world with no lag) catch every single value llGetSunDirection() returns during the day.  It would be sufficient to simply save the last result in a global variable, and check to see if the sign of x or z had changed since the last tick.  This would work even if you missed ticks due to lag, or use a longer time between timer events, say llSetTimerEvent(60.0) if you don't care to be more accurate than to the nearest minute.

Link to comment
Share on other sites

You are about to reply to a thread that has been inactive for 4105 days.

Please take a moment to consider if this thread is worth bumping.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...