# Using acceleration to plot position

Sorry if this question is dumb, and I know is physics 101, but I'm not that good with physics.

I'm writing an iPhone program that by collecting the acceleration data of the device tries to replicate the motion of the device in an virtual environment.

To simplify things, let's consider just one axis.

If the device is at position 0 with acceleration 0 and speed 0, if it receives an acceleration of 1.25G, what it will be it's position after 1.22 seconds, considering that the acceleration will last for the whole 1.22 seconds?

-
If you know how to calculate the final speed, divide the final speed by two to get the average speed, and multiply the average speed by the time to get the distance. – Ron Maimon Dec 12 '11 at 10:34
the laws of motion should help, s=ut+1/2 at^2 etc. Any a-level text book will have all the details. – Nic Dec 12 '11 at 11:22
Hi Nicolae, and welcome to Physics Stack Exchange! You're right that this is kind of a trivial question at face value - not because it's "physics 101" level, but because all you need to do is look up a formula. It's as if you go to the English Language & Usage site and ask them for a synonym of, say, "complicated" - they'll just tell you that you should have checked a thesaurus. SE sites are not really the place for such "general reference" questions. (cont.) – David Z Dec 12 '11 at 20:55
(cont.) But you're lucky in that there is a sense in which I think this question could be more complex: you will have to not only know the equation, but also numerically compute the position by integrating the acceleration over time, and there are some subtleties involved in that sort of numerical computation which a good answer could definitely address. – David Z Dec 12 '11 at 20:57
The only way this gets interesting if if you don't know how the phone is oriented, it if the orientation is changing. There are some neat ways I can imagine to estimate that missing data, but your accuracy will still degrade over time. – Colin K Dec 19 '11 at 5:09

We are looking for the position, say $s$, of the object at a certain time $t$. Given initial conditions $t_0$ (initial time), $v_0$ (velocity at $t_0$), $s_0$ (position at $t_0$) and a constant acceleration $a$ during a time interval $t - t_0$.

We use the following equation to determine the position $s$ at time $t$:

$$s = s_0 + v_0(t-t0) + \frac {1}{2}a(t-t_0)^2$$

There are some numerical integration methods (Euler, Verlet, Runge-Kutta, ...) to integrate the accelerations of moving bodies, so we can know its position as a function of time. You can do a bit of research on Wikipedia, pick one that you understand (I don't recommend Euler however). Still, the methods (especially the second-order ones) are often based on the fact that the equation $s = s_0 + v_0 t + \frac12 gt^2$ holds approximately true for small intervals of time.