A long time ago, I wrote a program that takes bunches of particles and applies Newtonian gravity to each so they interact. Lately I've rewritten this program, in an effort to simulate planetary motion. However I've ran into a bit of a snag, I can get a Sun-Earth system to behave properly, and I can get a Earth-Moon system to behave properly, but when a Sun-Earth-Moon system is created, the earth will orbit fine, but the moon will simply follow the earth around, never orbiting around it, and the distance between the Earth-Moon will slowly increase. I have attached 3 images (Absolutely not to scale): The first shows the simulation right after start, the Gray dot is the moon, slightly under it but somewhat visible is the earth in Blue, and the Yellow orb is...well I'll let you guess ;) The second shows the moon clearly trailing behind the earth. And the third for good measure is after the moon has reached about 1AU from the sun. To calculate the initial velocities I use the formula v = gc * (m / d), I apply this velocity on a vector perpendicular to the main orbiting body (Sun for Earth, Earth for Moon). For the moon I'm calculating the velocity to orbit the earth, and then adding the velocity to orbit the sun to make it relative to the sun. I find the Gravitational Acceleration using the formula a=gc * (m / d^2), I then find a normalized 2d vector to the gravitating body. I multiply this acceleration by the components of the 2d vector. and then add it to the XY position. For the moon here is the algorithm: - Calculate Vector to Earth - Calculate Vector to Sun - Calculate the Acceleration from Earth - Calculate the Acceleration from Sun - Moon's X = X + (SunAcc * -(SunDirX)) + (EarthAcc * -(EarthDirX)) - Moon's Y = Y + (SunAcc * -(SunDirY)) + (EarthAcc * -(EarthDirY)) Whew, that's a lot to type. Anyways, as you can see in the attached images, the moon doesn't exhibit the expected motion. It seems that the way I am adding the acceleration to the moon object is in error, but I have checked and recheck my formulas, masses, distances, vectors and acceleration for errors and cannot seem to spot it. I appreciate any and all help! This has me going in circles it seems.