OGL_PGR

08-20-2005, 09:31 PM

Please help me to resolve the following problem:

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 !

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 !