 # Background Rotation

Help!!! I have tried to paste in several different equations but none of them work as I am wanting. I have a background that I would like to rotate from 3 o’clock to 9 o’clock and then reverse direction back to 3 o’clock. This cycle (3-9-3) should take 29.5 days to complete its movement. If it is easier, I would even be willing for a cycle to complete every 30 days. This is a moon cycle that only appears in an upper window. The movement is a rocking motion that repeats nonstop. Please help me insert the right equations for this process.

Hi. The rotational moonphase formula is very difficult and i don‘t think you will find someone who can solve your special problem. The only one i know may be @mikeoday, he is very good in coding.

I can give you a formula for a 360 degrees rotation (180 degrees for a full cyle), maybe you can adapt it and cover the part you don‘t need with another layer.

Greetings, GAUSS.

1 Like

Ha, flattery will get you everywhere @GAUSS!

Ok, let me work the problem…

Seconds in one day: 24 x 60 x 60 = 86,400
Seconds in average lunar month = 29.530587981 x 86,400 = 2,551,442.80156
milli Seconds in average lunar month = 2,551,442,802

Desired range of rotation 180 degrees offset by 90

Positive rotation: ((((#DNOW#%2551442802)/2551442802)x180)+90)
Negative rotation: (270-(((#DNOW#%2551442802)/2551442802)x180))

Test: (#DNOW#%(2x2551442802))<2551442802 then positive rotation else negative rotation

Combined:

``````\$(#DNOW#%(2*2551442802))<2551442802?((((#DNOW#%2551442802)/2551442802)*180)+90): (270-(((#DNOW#%2551442802)/2551442802)*180))\$
``````

Optimised:

``````\$(#DNOW#%5102885604)<2551442802?(((#DNOW#%2551442802)/14174682.2333)+90): (270-((#DNOW#%2551442802)/14174682.2333))\$
``````

I think that might work.

2 Likes

Now, the above will just give you a rotation from an arbitrary start point that won’t coincide with an actual moon phase. Let me look up the correction …

Ok, a correction that can be used is to subtract the following from #DNOW#: 583,104,471

This is for the new moon. That is, the new moon will be at either end of the cycle with the full moon in the middle.

So corrected rotation becomes:

``````\$((#DNOW#-583104471)%5102885604)<2551442802?((((#DNOW#-583104471)%2551442802)/14174682.2333)+90):(270-(((#DNOW#-583104471)%2551442802)/14174682.2333))\$
``````

Note that the above is an approximation of the actual moon phase which can vary by up to 14 hours or so from the average phase obtained by assuming a circular orbit with a fixed period of 29.53 days.

3 Likes

I knew you can do.

Great job! 1 Like

Incredible!  2 Likes

Thanks @GAUSS and @Linlay 2 Likes

@mikeoday for mathematical calculations
@gauss for graphics
I … feed on the knowledge of both of us, at all times continuing in this particular moment of our life.

3 Likes

Thank you for the formula. The movement that your formula creates is acceptable for this watch face. I would like to ask you another question. Are these calculations made using calculus?

1 Like

I am glad it worked ok.

The expressions are just based on fractions …

(number of milliseconds since last new moon ) /
(number of milliseconds in a lunar cycle )

gives an increasing number from 0 to 1

multiplying this by the desired angle gives the rotation

Based on moon age (formulae):

`((#DNOW#/8.64e7-6.8583)%29.5306)`

I get the following:

`(abs((1-((#DNOW#/8.64e7-6.8583)%29.5306)/14.7653)*180)+90)`

• moon age :: 0 … 29.53 (days)
• divided by 29.53/2 :: 0 … 2 (plus fractional)
• 1 - x :: -1 … 0 … 1
• x * 180 :: -180 … 0 … 180 (angle)
• abs(x) :: 180 … 0 … 180 (angle)