# How to calculate next position?

Hi All,

I am working on a way to move something in 3D space via code.

I have these givens:
previous 3D location
current 3D location
velocity

Is this enough information to calculate the next position?

If so, does anyone know the math formula or code to do so?

Thanks!

Hi Atom,

have you seen this one https://sites.google.com/site/bartiuscrouch/scripts/motion_trail
You only need location and velocity to get the next location

next = loc + t*v

t is the time and v is the velocity as a vector.

Thank you.

I had seen that motion trail when it came out a while ago. Very After Effects like.

But I think your equation is what I needed. I had forgotten about time. That equation assumes velocity is a constant, correct? If I were to vary velocity how would that affect the output? I could have an additional given of previous_velocity?

Assume constant acceleration ( force)

x = x0 + v0t + at*t/2

Looking at http://en.wikipedia.org/wiki/Equations_of_motion takes me back…

I think the basics really apply to blender.

If we have the graph of displacement vs time, a location fcurve… the velocity is the slope (or tangent) of the curve at that point, so for each point we could estamate a value of velocity, and we can use frames as our time unit.

v(i) = (loc(i+1)-loc(i-1))/2

if we were to plot this velocity curve, its slope would give us acceleration and so on. To go backwards we would integrate. This correlates to the area under the curve… ie given a velocity curve, the accumulated area under the curve is the distance travelled, once again easily estimated using the fcurve.

This will get us to the equation posted by storm street. we want to know where we’ll be at frame (i+1) the area under the curve is the rectangle v[i] by one frame + the area of the triangle on top v[i+1) - v(i)/2 (half base x height)
(Change in velocity over time is acceleration.).