Quote:Gravitational force = (G * m1 * m2) / (distance)
G = 6.67 x 10E-8
m1 = object to get force for
m2 = object to get force from
so once you solve that then you'll have a force
Next we know f = ma
so instead of that gravitational force, to get the acceleration you could just do...
a = (G * m2) / (distance);
1) m1 and m2 are the masses of the objects?
2) You're saying that instead of using the very first equation you posted, one should just use the simplified equation at the very end of the above quote to get acceleration? The mass of the moving object isn't important?
Quote:That will give you the magnitude of a, then just multiply the magnitude of a with the vector, m2.position - m1.position;
I'm not understanding what you're talking about here. you're saying to multiply the acceleration we calculated by the distance between the two objects? The equation you gave ended with dividing by the distance, so if we're multiplying by the distance now, then that doesn't make sense.
I think what you're saying is that the accel is applied to the X and Y coords of the position differently, but I don't understand the actual implementation, could you explain in more detail?
Quote:Now you have an acceleration. Then you just need to do:
position += velocity;
velocity += acceleration;
I guess what I'm not clear on is how to handle speed+direction. I can see conceptually that the new position would be the old position + velocity, but how do you actually store the "direction" information, so that the X and Y of the position are updated appropriately?