# How do I know the position of some mass in space (starting at rest) over time when applying earth's gravitational force to it?

I know how to use Newton's law of universal gravitation. But I'm not sure where to go from there.

This is for my understanding while working on a game. I'm not trying to do anything fancy here.

-
The way you would want to implement this is going to depend on your game engine. Are you doing things in time steps? Are you tracking velocity and position? – Jerry Schirmer Nov 29 '12 at 23:57

$F=ma$ so if you know the force due to gravity, you need to divide it by the mass $m$ of the object to get the acceleration.

You'll probably be doing discrete timeslices, so it makes sense to use an approximation known as Euler's step-by-step method:

At any point in time, you'll be storing the position and the current velocity of the object. As you say you're aware how to calculate the gravitational force I'll skip that, but then divide by $m$ to get $a$. You need to divide $a$ by number of time intervals per second (for example 100ms is 10 frames per second, so divide $a$ by 10) to get the change in velocity for that time chunk, and add this to your velocity. Similarly, divide your velocity by the frames per second, and add that to the position.

-

I will assume that the mass of the mass you are concerned with is very small as compared to Earth's mass, hence, the gravitational potential is only due to Earth's mass.

Furthermore, you said that the mass is initially at rest, I will assume that the same goes for Earth (no orbiting around the sun). The motion of the mass $m$ in Earth's gravitational field $\Phi$ is then governed by the following Hamiltonian:

$$H = \frac{p^2}{2m} - G \frac{M m}{q}$$

where I defined the impulse $p$ of the particle, it's position relative to Earth's core $q$ and the gravitational constant $G$. $M$ is the mass of Earth.

This Hamiltonian leads to the following Hamilton’s Equations:

$$\dot p = - \frac{\partial H}{\partial q} = - G \frac{M m}{q^2}$$ $$\dot q = \frac{\partial H}{\partial q} = \frac{p}{m}$$

You can solve these equations, but this is a rather cumbersome business. A nicer approach is the conservation of energy: As the $m$ falls in the gravitationa potential, it loses potential energy. This energy has to go somewhere: the velocity of the particle. We hence have (by setting the overall energy to $0$):

$$m \dot q^2 = 2 G \frac{m M}{q}$$

$$\frac{\textrm{d}q}{\textrm{d}t} = \sqrt{\frac{2 G M}{q}}$$

$$\sqrt{q} dq = \sqrt{2 G M} dt$$

$$q^{\frac{3}{2}} = \frac{3}{2} \sqrt{2 G M} t + C$$

$$q(t) = \left( \frac{3}{2} \sqrt{2 G M} t + C\right)^{\frac{3}{2}}$$

with some integration constant $C$ equal to the initial position of $m$ to the power of $\frac{2}{3}$ (note that I already set $\dot q(0) = 0$). Furthermore, note that the first equation also gives you a relation between the velocity and position of a particle.

This also solves Hamilton’s equations somewhere up there.

If you want to include rotations (that is, either Earth moves orthe mass moves initially), things get slightly more difficult.

-