How to account for inertia in kinematics?

Alright, I'm only in AP Physics and I asked my teacher and he couldn't help me... I'm making a 2D physics engine and I'm having problems when it comes to gravity between objects and I think its because I'm not accounting for inertia properly.

The way I have it set up, is that all the forces on an object are added up by their $X$ components and their $Y$ components, then I use those to to find the acceleration in both the $X$ and $Y$ directions. Then I use the kinematics formulas and the objects original velocity (which I set at the beginning, however this might be the problem which I will talk about later) and the difference in time (I calculate all of this and made sure this isn't the problem)(The formula I used was $x = x_o + v_ot + \frac{1}{2}at$) . When I first tried this, I realized that the forces were way too strong and had too much of an effect on the object. I realized that it wasn't accounting for the object's inertia. So, what I tried doing (And i'm not sure if this is correct) but I used the formula $v = v_o + at$ however I used the velocity at the previous instance for $v_o$ and then plugged in the $v$ for the kinematics equation I used (I hope this is making sense) However I'm not sure if this worked correctly....

Is there any way to used the kinematics formulas correctly while accounting for the objects current velocity?

• Why would inertia matter? Is there any angular motion? – HDE 226868 Nov 26 '14 at 1:49
• What is angular motion? Sorry, haven't covered that much in physics yet – MagnusCaligo Nov 26 '14 at 1:51
• Hold on. By "inertia", do you mean "mass"? – HDE 226868 Nov 26 '14 at 1:54
• Then yes, you want to account for mass. – HDE 226868 Nov 26 '14 at 2:04
• If you're using $a=\frac{F}{m}$, things should work fine. – HDE 226868 Nov 26 '14 at 2:28

There are only exact solutions when only using two bodies (namely Kepler orbits), however when you use any more bodies there will be no general solution. These systems of more than two bodies can be approximated numerically, like you tried, by using discreet time steps. But now you enter the realm of numerical integration for ordinary differential equations. The simplest method would be explicit Euler: $$\vec{v}_{n+1} = \vec{v}_n + \Delta t \vec{a}_n$$ $$\vec{x}_{n+1} = \vec{x}_n + \Delta t \vec{v}_n$$ where $\vec{a}_n$ in case of gravity can be calculated from $\vec{x}_n$.

However in this case Euler method will not be very accurate. Other easy to implement methods for gravitation are leapfrog or Verlet method. These also have the advantage that they are symplectic, which helps to conserve energy.

First, I take it from your question that you are working to make a simulation of bodies in 2D with gravitational forces between them, like say earth and moon - or sun and earth - is that correct?

If this is the case then you are going to have a problem using $v=v_0+at$ and similar formulae because the acceleration will not be constant. $v=v_0+at$ and similar equations assume that the acceleration is constant, but as the sun/earth move the acceleration will change (at least in direction). The way to do it is to use small time steps $\delta t$ and find small changes in position and velocity etc. for small steps. e.g. $\delta v=a \delta t$ and $\delta x = v_x \delta t$ - then $v=v_0+\delta v$ and $x=x_0 + \delta x$. After each small step you need to recalculate the value of $a$.

If, instead, you want to calculate close to the surface of earth in 2D where one direction is up and one is along the gravity downwards then $g$ - acceleration down due to gravity is constant and this equations like $v=v_0+at$ should work fine.

Does this help?

• I am calculating the differences in small steps in time, however I did not realize that Sv = a(St) (Sorry, I don't now how to do the symbol thing). That helps a lot thank you! – MagnusCaligo Nov 26 '14 at 3:44
• good to hear this was helpfuil - you might want to look at Euler method and Euler Cromer method - you will do one of these two with your program - Euler Cromer is more accurate and easier to program – tom Nov 26 '14 at 9:28

A simulation does not have a prescribed position $x(t)$. The forces are known, and the position and velocity is found by considering a small time step $\Delta t$ and finding the acceleration $a=\frac{\sum F}{m}$ to act on this step.

For each step then

\begin{aligned} t & \rightarrow t + \Delta t \\ x & \rightarrow x + v \Delta t \\ v & \rightarrow v + a \Delta t \\ \end{aligned}

This is the simplest (and crudest) method, but it will give you the behavior you want.