# 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.

3 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.

4 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

1 Like

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)
• adjust angle 90 degrees
2 Likes

An elegant solution, well done!

@GAUSS Could you post your 360 rotation formula for the moon phase, please?

Hello Jeffrey:

If you are referring to my “MOON DANCE” watch face, here is the formula I used:

-#DWFSS#

Happy Holidays and best wishes for the New Year!

Howard

For sure i can share the rotational formula for the moonphase with you but i don´t have the credits on this one:

It´s a cooperative work and you can find it and other (working fine as well) here in the community. I am not sure but i think this one was from MikeoDay

(((((#DNOW#/2551442844-0.228535)+0.00591997sin(#DNOW#/5023359217+3.1705094)+0.017672776sin(#DNOW#/378923968-1.5388144)-0.0038844429sin(#DNOW#/437435791+2.0017235)-0.00041488sin(#DNOW#/138539900-1.236334))%1)*360)/2)

Greetings, GAUSS.

When I plugged the formula into the rotation value it didn’t do anything?

Well, this is a formula for a rotating moon phase. You can see the effects when you change daywise. You have to combine it with a matching picture and a layer mask. What timing for rotation do you expect?

I don‘t know which purpose and timing speed you rotation should have?

You may have a look at my watch faces and get a formula when you look under the hood. All my watch faces do have inspection mode open.

1 Like

It is missing stuff because of the forum messing it up, try re-pasting it with ` before and after the expression

1 Like

I found it in one of my own projects:
`(((((#DNOW#/2551442844-0.228535)+0.00591997*sin(#DNOW#/5023359217+3.1705094)+0.017672776*sin(#DNOW#/378923968-1.5388144)-0.0038844429*sin(#DNOW#/437435791+2.0017235)-0.00041488*sin(#DNOW#/138539900-1.236334))%1)*360)/2)`

As you can see, the one @GAUSS pasted is missing the asterisks because the forum uses that for italic formatting

1 Like

You forgot to turn it on on the 2 planetarium watch faces… would love a peek at those

2 Likes