Hello, for a scool project I have to code the in the reality existing system containing sun, moon and earth as realistically as possible. In my opinion the three bodies should move witch my current code as they do in reality. I put the real values into the equation of motion. What did I do wrong? I would really appreciate any tips or help. Thank you!
Here is the link of my current code: p5.js Web Editor
Your moon and earth flying away, so it looks like your attractive gravitational force is not strong enough.
I would adjust it to a point that the earth gets the right trajectory.
Right now you probably only need to increase the starting velocity of the earth to put it on orbit, also you’d need to change the position and starting velocity of the moon as well, because it looks like the starting position is inside the earth. I wouldn’t know where to apply the changes in your code, but i’m working on a similar demo, and thats all i needed to make mine follow an orbit. At the end of the day you’d probably need a lot of fine tuning if you want a consistent orbit tho. Gool luck, I hope I helped.
Hi Pollisco, the email with your message landed in my spam ordner, thats why i am aswering so late, neverthanless thanks for replying , could you maybe send me a link so I could have a look at your code and compare it to mine, maybe it helps me. See you, Beppo
Hello, could you maybe send me a link of your code, maybe it helps me, thanks
Hello @Beppo
Since this is a project for school, please read the HOMEWORK POLICY guidelines in link below:
https://discourse.processing.org/faq#homework
In short, it is against the forum guidelines to provide full code solutions.
However, on the youtube CODING TRAIN channel there are several (at least 4) tutorials available.
I have linked 2 below. The first is using processing, and the second is p5.js:
Good luck!