Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Calculating A Moon Dial - Help Please

Infrared Wind
Gridologist
Join date: 7 Jan 2007
Posts: 662
09-26-2007 07:04
Ok...I'm horrible at math...I usually figure out
things after a lot of time-consuming trail and error,
not knowing half of what I'm doing along the way. =)

* * *

I want to make a moon dial, like the ones used in
mechanical grandfather clocks and classy watches.
The moon dial simply a disk that turns 360 degrees
once a moon.

So...what I've learned thus far is that basically the moon
moves through its ecliptic thus:

360 degrees / 29.53 days = 12.19 degrees per day

Of course this is very general. There are variations...but
this would serve as a good starting point.

Now I'd like to use this bit of code I use
for clock hour hands...to rotate an object, in
this case a disk.

I worked out these numbers:

708.72 hours in a moon cycle
360 / 708.72 = 0.507958

And I'm wondering if I can use llGetWallclock base
to derive the rotation I need for the llEuler2Rot
calculation. There's probably a much better way.


This is what I use for some hour hands:

float now = llGetWallclock();
float minute = (integer)now / 60;
float hour = minute / 60;

// For 12 Hour Clock Hour Hand
rotation hand_rot = llEuler2Rot(<0, 30 * hour * DEG_TO_RAD, 0>;);
llSetLocalRot(hand_rot);

* * *

And so now...

// For the Moon???????
rotation hand_rot = llEuler2Rot(<0, 0.507958 * hour?? * DEG_TO_RAD, 0>;);
llSetLocalRot(hand_rot);


Any help would be grandly appreciated!!
--Infrared
nand Nerd
Flexi Fanatic
Join date: 4 Oct 2005
Posts: 427
09-26-2007 10:26
Hi Infrared, long time no see. :)

Problem with using llGetWallClock is that the maximum it can ever reach is 23:59:59 (hrs:min:sec) whereas your period, the length of time it'll take for your hand to rotate 360deg is 29.53 days. Therefore you'll need to include a date function and start from a specific date to give you a full period, this is best done using the llGetUnixTime function:
From: SL Wiki
Returns an integer that is the number of seconds elapsed since 00:00 hours, Jan 1, 1970 UTC from the system clock.

From that you just divide by 29.53 days or 2,551,392 seconds to give you a float which if you multiply by 360deg or 2*pi radians gives you your angle for your clock hand.

so,
From: someone

// For the Moon???????
rotation hand_rot = llEuler2Rot(<0, 0.507958 * hour?? * DEG_TO_RAD, 0>;);
llSetLocalRot(hand_rot);


becomes
From: someone

// For the Moon.
rotation hand_rot = llEuler2Rot(<0, ((float)llGetUnixTime() / 2551392.0) * TWO_PI, 0>;);
llSetLocalRot(hand_rot);


EDIT: 2,551,392 seconds, not 2,351,392 seconds, in 29.53days.
_____________________
www.nandnerd.info
http://ordinalmalaprop.com/forum - Ordinal Malaprop's Scripting Forum
Infrared Wind
Gridologist
Join date: 7 Jan 2007
Posts: 662
09-26-2007 18:56
Awesome, Nand! That's it! You have a big brain. =)

And yeah...long time no see...I'm overdue for visit to your gallery. =)

Thanks again!

-- Infrared
Infrared Wind
Gridologist
Join date: 7 Jan 2007
Posts: 662
09-26-2007 21:48
Hey Nand --

According to the google calculator:

29.53 days = 2551392 seconds, is your number a typo? =)

- Infrared
nand Nerd
Flexi Fanatic
Join date: 4 Oct 2005
Posts: 427
09-27-2007 01:40
From: Infrared Wind
Hey Nand --

According to the google calculator:

29.53 days = 2551392 seconds, is your number a typo? =)

- Infrared


Sure is Infrared,

erm I mean it was just there to check you were paying attention. ;)
_____________________
www.nandnerd.info
http://ordinalmalaprop.com/forum - Ordinal Malaprop's Scripting Forum