# Calculating the position of an object given object's initial position and velocity influenced by given acceleration vectors

The red circle is being pulled by two gravity points. Assume that the red circle has a given position (x,y) and a given velocity (vx, vy).

I need to calculate the velocity and position of the red circle at time (t) given these two gravity points [(x.a1, y.a1) and (x.a2, y.a2)] with both of them having a force (G) that will act upon the red circle. Assume that the gravity points will be stationary.

I can't assume anything is located at origin unfortunately :( Any help is greatly appreciated! Tried solving this on my own and I came up with the equation below - but this is assuming that the gravity point is at origin and doesn't account for multiple gravity points as well.

• Why are you using $g=9.80$m/s$^2$? That's not part of your statement. – Bill N Jun 17 at 17:20

## 1 Answer

In this case, you can try to calculate the two forces individually, and then take the vector sum of the forces. For the force between the point at (x,y) and (x.a1, y.a1), r.1=squareroot((x-x.a1)^2+(y-y.a1)^2). Using this, you can find F.1 from the formula F=GMm/r where you substitute r.1 for r and m.1 for M (assuming that the body has a mass m). Note that this is a scalar - the magnitude of F.1. To find F.1, you need to find the unit vector in the direction of r.1 : u.1.

u.1=[(x-x.a1)i+(y-y.a1)j]/r.1.

Note that the direction vector of F.1, which is v.1 is equal to -u.1 (v.1=-u.1), because gravity is an attractive force. Thus, knowing both the magnitude (F.1) and the direction (v.1) of F.1, simply multiply them together and you will get F.1, the force with which the mass (m.1) at point (x.a1, y.a1) attracts the point at (x,y).

Now, repeat this process to find F.2, this time using r.2=squareroot((x-x.a2)^2+(y-y.a2)^2).

After this, add the two vectors F.1 and F.2 to find the net resultant force F acting on the mass at (x,y). Divide this by m (the mass of the red circle at (x,y)) to get the acceleration a. Now, you can integrate this with respect to time (dt) to get the velocity over time. Remember that the velocity v at t=0 is 0m/s. Use this to get rid of the constant of proportionality. You can also integrate this once more with respect to time (dt) to get position as a function of time. Remember that at t=0, x(0)=x and y(0)=y (where (x,y) is the initial position of the body). Remember to keep the i and j vectors through the integrations and separate them at the end to give separate functions for x(t) and y(t). I hope this helps and good luck!