darkdave3000 said:
Ok I have added the sun into the simulation. What this did was make the moon actually go the opposite direction but only slightly. So the moon is now falling toward the Earth(slightly). However when increasing the jump from 1 minute to 13.6 minutes the moon now looks like is falling away again however this is the jump I need to create a full Earth orbit which seems to be falling away from the Sun.
Have a look at the following screenshots.
How strange... why would the moon now be falling toward the Earth with all correct data including the Sun? Do I need to add in the gas giants too?
Merry Christmas Everybody!
Update: Ok the moon's orbit around the Earth is adjusted so it's always relative to the Earth's core, not the barycentre, so it's not so accurate. I'll run the sim again with the sun moving opposite to the Earth's velocity instead of being stationary while making Earth and Moon not move at Earth's speed. That way Ill be able to redraw the moon's orbit but relative to barycentre.
That's not what you wanted to do. Adding the Sun just compounded the problem by adding extra factors when your original simulation wasn't even accurately modeling the simple scenario.
Earlier you said that you used 1/2 at^2 + vt. to calculate the displacement. But that will not give you the proper displacement for an orbiting object easily.
In the top image we show an object moving to the left at v with a downward acceleration of a downward. A simple application of the above equation will give you the displacement and new motion after some time t as shown in the second diagram. with the object following a parabolic path.
However, if the object is in an circular orbit ( where v is the circular orbital velocity) then it new position will be like the blue object in the bottom diagram and its path will be an arc of a circle. This is because, unlike the second diagram, which assumes that gravity acts in one direction the whole time, gravity really acts towards the center of the orbit which means by the end of the time period, it is pointing in the direction of the red arrow in the third diagram. With the Second diagram, the acceleration never effects v, and the final velocity is the vector sum of the velocity due to that acceleration and the original value of v and will end up being greater than v. In the third diagram, the direction of aceleration changes with respect to the original direction of v, and as a result the leftward component of the object's velocity will be less than the original v and it will end up that the new speed of the object, though in a different direction, will be of the same magnitude as the original v.
This error compounds with each time period even if at the end of each time period you reorient the direction of a to point towards the center of the planet.
Now, the smaller the time period you use, the smaller the difference between the two predicted paths. If you divide the above time period by ten, you get an much smaller deviation between the green and blue paths. So much smaller, that even after ten of these smaller time divisions, the total difference will still be smaller than when you used the one larger time period. This is why your simulation performed better when you used smaller time steps.
Orbital mechanics is just not a easy thing to figure out from the basics on up. Even Newton basically had to invent calculus in order to tackle it.