PDA

View Full Version : Jittering while Interpolating ( using velocity )

OGL_PGR
08-20-2005, 09:31 PM

There is a lot of jittering ( back-n-forth )
movement of the object as it moves along a
path.

I'm trying to interpolate b/w 2 points.
Each point is being "received" every 0.1 secs.
( 100 ms ).

So, while I'm at the "CurrentPosition",
I Calculate the "NextPosition" and try
to get 3 "Intermediate"positions so that
this translation from A to B happens
at 40 FPS ( 25 ms b/w 2 intermediate pts )
instead of 10 FPS ( 100 ms b/w A and B ).

So its like:

0ms 25ms 50ms 75ms 100ms
A ----> i1 ----> i2 ----> i3 ----> B

i1,i2,i3 are 3 intermediate points calculated,
using : V(Ti) = [ X(Ti) - X(Ti-1) ] /
( Ti - Ti-1 ).

( from V = dX / dT )

and X(Ti + dT) = X(Ti) + V(Ti)*dT;

( from X' = X + V*dT )

XYZ Intermediate
= physics->GetNextPosition(
CurrentPosition,
CurrentVelocity,
T*DeltaT);

Where DeltaT = 0.025 ( 25ms ),
& T varies from 0 to 4.

if T = 0, point we have is A.

and T=1,2,3 for intermediate points &

if T=4, we have point B.

I've implemented it in the following way:

Initialize():

CurrentPosition = NominalData->GetScaled3DPoint(PATH_START_INDEX);
PreviousPosition = NominalData->GetScaled3DPoint(PATH_START_INDEX-1);
CurrentTime = NominalData->GetTime(PATH_START_INDEX);
PreviousTime = NominalData->GetTime(PATH_START_INDEX-1);
CurrentVelocity = physics->GetCurrentVelocity(CurrentPosition, PreviousPosition, CurrentTime, PreviousTime);
NextPosition = physics->GetNextPosition(CurrentPosition,CurrentVelocity,T* DeltaT);

& in Draw() loop :
{

XYZ Intermediate = physics->GetNextPosition(CurrentPosition, CurrentVelocity, T*DeltaT);
..
...
...
...

//and at the end of Draw() loop:
...
if(T==4)
{

j++;

// get next Position;
PreviousPosition = CurrentPosition;
CurrentPosition = NominalData->GetScaled3DPoint(j);

PreviousTime = CurrentTime;
CurrentTime = NominalData->GetTime(j);

CurrentVelocity = physics->GetCurrentVelocity(CurrentPosition, PreviousPosition, CurrentTime, PreviousTime);

NextPosition = physics->GetNextPosition(CurrentPosition, CurrentVelocity, (CurrentTime + (4*DeltaT)) );

if(j >= NominalData->NominalLineCount-1)
{
j=PATH_START_INDEX;
}
T=0;
}

} // end of Draw()

//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
Can someone please tell me why the jittering of
the object is taking place ?

Thanks !

memfr0b
08-21-2005, 12:58 AM
T should loop either 0..3 or 1..4. Otherwise you generate every control point twice, which could be the cause of your jitter problem. I'm not sure though, as it wouldn't cause the object to jump back and forth, but to stop moving every four frames.

08-22-2005, 01:58 AM
Originally posted by memfr0b:
T should loop either 0..3 or 1..4. Otherwise you generate every control point twice, which could be the cause of your jitter problem. I'm not sure though, as it wouldn't cause the object to jump back and forth, but to stop moving every four frames.Jitter is still taking place.

Tried even with Second Order Interpolation. i.e by using X2 = X1 + V(Ti)*dT + 0.5*a(Ti)*dT*dT .

Any suggestions ?

memfr0b
08-23-2005, 03:11 AM
You seem to be extrapolating the movement of your object. Ie you use the average speed between the previous and the current point to create the motion between the current and the next point.

If you know you data beforehand, you should interpolate the position with the correct control points:

// 0 <= f < 1
Speed = (NextPosition - CurrentPosition) / DeltaTime;
Position = CurrentPosition + Speed * f * DeltaTime;

// or simply
Position = f * CurrentPosition + (1-f) * NextPosition;If you don't know your data beforehand, you can either delay your display by one measurement interval and use the code above, or you'll have to write use a slightly different approach:

Error = (CurrentPosition - LastExtraPolatedPosition);
Speed = (CurrentPosition - LastPosition + Error) / DeltaTime;
Position = LastExtraPolatedPosition + Speed * f * DeltaTime;Note that the position is extrapolated starting from the last extrapolated position, not the measured position, and that speed contains an error reduction term.

I'm not entirely sure this simple approach will already give useful results. You may need to use a better "speed prediction" method that also incorporates the measured acceleration.