It's fairly simple to use Newton's equation to determine the attractive force between two objects.
But that's where I got stuck...
I have two spheres of known size, mass, and position.
Using Newton's equation, I know the amount of gravitational force pulling them together.
I also have a function that allows me to apply force to an object.
Now here's where I get stuck... the force I apply to the object has be in the format of (x,y,z) with the amount of force on each axis inputted.
If I remember my math correctly, I have to use a trig function here, probably a cosine... But I can't remember exactly how.
Here is my code so far:
//gravitational constant
float G = 6.673 * pow(10.0, -8.0);
//distance between the two objects
float distance= sqrt(
(dbObjectPositionX(99999)*dbObjectPositionX(1))
+
(dbObjectPositionY(99999)*dbObjectPositionY(1))
+
(dbObjectPositionZ(99999)*dbObjectPositionZ(1))
);
float TotalForce = (G*1000*3)/pow(distance,2);
Now I just need to use this function somehow to compute how to move my objects:
ApplyForce(Object,x,y,z);
Where x is the force applied to the x axis, and so forth.
I need to figure the equation, using my TotalForce number, to figure out those 3 axis inputs.