# Calculate gravity between two points

I am trying to build a simulation of gravity in LibGDX using Bullet physics.

To simplify it, I just want to apply a force on some body towered a (0,0,0) point.

I got my body mass and it's location and I want to use the applyForce method from the bullet api. I need to give it two parameters the force and the direction.

Direction is easy to calculate it's just a vector opposite to the location, but how to calculate the force? Also the API require the force to be a vector, while I thought this should be a number, can you explain me why is it this way?

• Are you sure it is asking for a force and a "direction"? It looks like instead it is a force (which is a vector) and a location where the force is applied. May 20, 2016 at 15:34
• @BowlOfRed maybe, they got another method applyCentralForce, that only except one vector force vector. But my problem is that I don't understand how a force can be a vector, in my head I see it as a direction vector and some power number May 20, 2016 at 16:12

As an example if you had a direction of $(1,0,0)$ and a magnitude of $5$, then you can represent the force as a single vector of $(5,0,0)$.
Force has both a magnitude and direction, which are the properties of a vector. The magnitude can be given by $\vec{F} = G\frac{M_1M_2}{\vec{r^2}}$ where $G$ is the gravitational constant and $M_1,M_2$ are the masses. the distance from each other is represented by the vector $\vec{r}$ which will be the displacement from the origin.