I am working on a path camera to be used in demo playback. (3d game) The spline math used is catmull rom. I am on my second attempt to get constant position speed :( (someone else is doing rotation). The path cam keyframes are position@time.

I have a step now when the path is recalculated, it also generates the arc distance/time lookup table which I have normalized. I have the duration of each segment(k through k+1)as well as each segments linear velocity calculated from that data.

I am not very good at reading anything except basic equations. I could use an explanation or psuedo code of what is needed next in order to get the camera to smoothly accelerate or decelerate depending on the velocity of the next segment. Right now it's instant changes and no good. I tried googling for hours and was going in circles.


1 Answer 1


Well, a very basic linear interpolation pattern goes like this (pseudocode):

currentVelocity = currentVelocity + (interpolationRate * (targetVelocity - currentVelocity ))

Calling this on update instead of directly setting the current velocity will do what you requested, the transition speed is adjustable by adjusting the interpolationRate value (between 0.0 and 1.0, 1.0 being an instant change).

  • \$\begingroup\$ Will that make it so the camera is at the right points for the given time t? It seems like it won't but hard to tell. I would approach this by lerping position myself, but shrug \$\endgroup\$
    – Alan Wolfe
    Jul 3, 2015 at 0:53
  • \$\begingroup\$ I don't think this is what OP asked for. This is a basic linear interpolation. This does not take into account the length of the spline. \$\endgroup\$
    – Tara
    Jul 3, 2015 at 3:20
  • \$\begingroup\$ Yeah, that does not solve my problem, it will not hit its next key at the correct time. I can come up with a way that it could hit the velocity of the next frame at the correct time but In order to speed up to the next velocity I first need to slowdown or else I would reach 1 before the duration that the segment is supposed to be. This becomes a problem with big slowdowns needed for big increases and visa versa. Also if a velocity is low enough it would have to go negative in order to compensate to reach 1 at the correct time for a increase the next frame. Is there even a way around that? \$\endgroup\$
    – coopn
    Jul 3, 2015 at 5:55
  • \$\begingroup\$ If you use the length of the spline to set your interpolation rate properly, you will have a smooth transition over varying spline points. You know the length of your segment, you know your velocity, so you can calculate when you get to the given point, and set the rate accordingly. \$\endgroup\$ Jul 3, 2015 at 9:19
  • \$\begingroup\$ @Laszlo: Of course. But getting the spline length is the difficult part. \$\endgroup\$
    – Tara
    Jul 3, 2015 at 10:01

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .