Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Sun position to time of day

Csteph Submariner
Registered User
Join date: 24 Apr 2007
Posts: 60
09-19-2007 17:17
Hi,

I've found a few scripts on here to turn things on or off according to day or night which use llGetSunPosition. I understand how these work, but I can't work out how to get more granular than just day/night.

What if I want to do something at noon, or dusk, or morning, or points in between?

I'm guessing that I can do something with sun_position.z, but does anyone have the figures? I don't think my geometry is up to working it out :(

tia
Cid Jacobs
Theoretical Meteorologist
Join date: 18 Jul 2004
Posts: 4,304
09-19-2007 18:27
You should be able to set up if else statements, I can not think of another way to do this without getting in world, but something like;

vector S = llGetSunDirection();
if((S.z >= llSin(10 * DEG_TO_RAD)) && (S.z <= llSin(15 * DEG_TO_RAD)))

Something like that should flag it when it is between 10 and 15 degrees above the horizon. Not tested in world though.
_____________________
Csteph Submariner
Registered User
Join date: 24 Apr 2007
Posts: 60
09-20-2007 18:43
HI, this is working well for me up to a point but I still can't distinguish between the morning and afternoon.

Is this something I can tell from the x and or y components?
Dire Graves
Registered User
Join date: 3 Sep 2007
Posts: 51
09-21-2007 13:39
I think you would probably have to look at the X and/or Y direction to figure out morning or afternoon. I think X is from east to west but not sure. I would say check the X at morning and afternoon and there should be a big difference.

I'm not sure about this but it's worth a try.
Cid Jacobs
Theoretical Meteorologist
Join date: 18 Jul 2004
Posts: 4,304
09-22-2007 00:19
if (S.z <= 0){//night} else{//day}
That should let you know when it is day or night
_____________________
Csteph Submariner
Registered User
Join date: 24 Apr 2007
Posts: 60
09-22-2007 08:46
I can do day/night no problem. What I'm having trouble with is morning/afternoon at the moment.
Csteph Submariner
Registered User
Join date: 24 Apr 2007
Posts: 60
09-24-2007 10:55
From: Dire Graves
I think you would probably have to look at the X and/or Y direction to figure out morning or afternoon. I think X is from east to west but not sure. I would say check the X at morning and afternoon and there should be a big difference.

I'm not sure about this but it's worth a try.


Spot on!

for morning x > 0

for afternoon x < 0
Joshua Philgarlic
SLinside.com
Join date: 29 Jan 2007
Posts: 143
09-24-2007 17:05
Months ago I managed this problem with llGetTimeOfDay(). The code for this is:

// to be placed in a timer event
SLtime=llGetTimeOfDay();
if (SLtime>12700 || SLtime<1800)
{
// do this at NIGHT
}
else
{
// do this at DAY
}
Rusty Satyr
Meadow Mythfit
Join date: 19 Feb 2004
Posts: 610
09-24-2007 17:57
The sun and moon alway rise in +Eaxt and sets in the -Wext.

Sometimes slightly to the +Nyorth, or slightly to the -Syouth.

That there's your +Upz and -Downz. :D
nand Nerd
Flexi Fanatic
Join date: 4 Oct 2005
Posts: 427
09-25-2007 06:27
From: Rusty Satyr
The sun and moon alway rise in +Eaxt and sets in the -Wext.

Sometimes slightly to the +Nyorth, or slightly to the -Syouth.

That there's your +Upz and -Downz. :D


Nice, I'll need to try and remember that one.

Might be worth a look:
/54/4b/125628/1.html
/54/e7/107757/1.html

Unfortunately the figures I had attached to the later thread have become corrupt but it shows that the sun does not follow a fixed path around the grid, instead it's path migrates ever so slightly day to day. I'll set up a data log again some time soon and plot some more graphs to show this. Failing that I might be able to dust off the old figures and post them.
_____________________
www.nandnerd.info
http://ordinalmalaprop.com/forum - Ordinal Malaprop's Scripting Forum