+ 5

How to rotate the moon around the earth on JAVA

I was creating a simple Solar System. The earth rotates around the sun. Now I am struggling while trying to rotate the moon around earth, in the same time while earth rotates around sun. Thank you for your help!

12th Feb 2021, 6:24 PM
Altina
Altina - avatar
8 Antworten
+ 4
It can be called a circles superimposition implemented like here: https://code.sololearn.com/WYEQcTXBZbeK/?ref=app
12th Feb 2021, 9:43 PM
JaScript
JaScript - avatar
+ 2
Would be easier if you show your code, but maybe this helps: I guess you're defining rotation in polar coordinates, i.e. increase angle by a fixed amount in each step, and then transferring to cartesian. So for the moon you can do the same, with an increase roughly 13 times that of the earth. That will represent the rotation moon around earth. Then transfer to cartesian and add those coordinates to the coordinates of the earth
12th Feb 2021, 7:46 PM
Benjamin Jürgens
Benjamin Jürgens - avatar
+ 2
Do the rotation relative to the earth's frame of reference.
12th Feb 2021, 8:49 PM
Sonic
Sonic - avatar
+ 1
Mirielle well girl thank you so much, a great solution😍 also sorry for taking your time❤️
12th Feb 2021, 11:27 PM
Altina
Altina - avatar
- 4
ajaysingh
13th Feb 2021, 6:51 AM
Rajkumar Singh