Quote:
Originally Posted by rahilm
...you're going to be 1 processor cycle behind (time wise) on position.
Edit: This is what I mean by being 1 processor cycle behind. To integrate, you basically have to use Reimann sums in this case. For best accuracy, you'd want trapezoidal sums, so for 1 position value, you need 2 velocity values, so 3 acceleration values. This means you'd have to integrate acceleration for 2 cycles to get the two velocity values required for a single position value, putting you 1 cycle behind realtime.
|
Assuming that
X0 and
V0 are given, and assuming that the update period
dt is short enough that the acceleration is accurately approximated as a linear function of time, then the position is given by:
X1 = X0 + dt*V0 + dt2*(a1 + 2*a0)/6
X2 = X1 + dt*V1 + dt2*(a2 + 2*a1)/6
.
.
.
Xn = Xn-1 + dt*Vn-1 + dt2*(an + 2*an-1)/6