Results 1 to 4 of 4

Thread: Jittering while Interpolating ( using velocity )

  1. #1
    Member Newbie
    Join Date
    Jul 2004
    Location
    Bangalore
    Posts
    37

    Jittering while Interpolating ( using velocity )

    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 !

  2. #2
    Senior Member Regular Contributor
    Join Date
    Jul 2005
    Location
    Berlin, Germany
    Posts
    188

    Re: Jittering while Interpolating ( using velocity )

    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.
    355/113 -- Not the famous irrational number PI, but an incredible simulation!

  3. #3
    Guest

    Re: Jittering while Interpolating ( using velocity )

    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 ?

  4. #4
    Senior Member Regular Contributor
    Join Date
    Jul 2005
    Location
    Berlin, Germany
    Posts
    188

    Re: Jittering while Interpolating ( using velocity )

    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:

    Code :
      // 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:

    Code :
      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.
    355/113 -- Not the famous irrational number PI, but an incredible simulation!

Similar Threads

  1. Velocity and rotation help
    By SacAche in forum OpenGL: Basic Coding
    Replies: 0
    Last Post: 01-19-2014, 07:41 AM
  2. Change velocity at a particular point
    By Abdul in forum OpenGL: Basic Coding
    Replies: 1
    Last Post: 03-17-2012, 08:23 PM
  3. gravity effecting y velocity
    By Josh Kasten in forum OpenGL: Basic Coding
    Replies: 1
    Last Post: 02-07-2003, 09:56 PM
  4. STB Velocity
    By w00t in forum OpenGL: User Software
    Replies: 0
    Last Post: 01-08-2002, 07:25 PM
  5. (orthographic) jittering using accumulation buffer? please
    By JOSE ML in forum OpenGL: Basic Coding
    Replies: 0
    Last Post: 11-04-2001, 11:05 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Proudly hosted by Digital Ocean