# Smooth Interpolation of Camera Rotation on a Spline Path

This topic is 3832 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

Hi I use splines for camera paths. So far i can smoothly interpolate the position of the camera. At each node of the path i also store the rotation of the camera as a quaternion. When calculating the position of the camera i get a time t between 0 and 1, which is used to interpolate (using the spline function) between the two positions of a spline segment. I use the same value to lerp my two camera rotation quaternions. This works, but results in pretty bad quality, because every time the camera passes the next node on a path the velocity of the rotations changes abruptly. What i would like to do is to interpolate the rotations similar to how i interpolate the positions. However my math-skills are not good enough to figure this out by myself, whether / how i can do that for rotations. Can anyone give me some pointers? Maybe i should add this: My camera is NOT fixed on looking into the direction it is traveling in. So the camera's rotation is not dependent on the position / direction it is moving into, but it really needs to interpolate between the two given rotations of the previous and next node. Thanks, Jan.

##### Share on other sites
I "solved" my problem. Maybe someone wants to know sometime, so i'll post how i did it:

Interpolating Quaternions for smooth orientations on a spline-path is a nightmare. Even code that i got from book CDs did not work properly (sudden rotations into wrong directions, still pretty yerky motion, etc.) and google only turns up either half-baked solutions or mathematically so complicated solutions, that i were not able to implement them (i know, i suck at maths).

So i took a step back, ditched quaternions altogether and solved it differently. I have one spline that interpolates the camera's position. Now i added two splines, that interpolate (as position) the look-at and camera-up vectors. That's pretty simple. Simply use the position at a node and add (using the orientation) the "forward" and "up" vector to it, which gives you two slightly shifted splines to your position-spline.

When sampling the splines, i first sample the position-spline, which returns the camera-position AND the spline-segment [0;n] and segment-time [0;1], that was used. I then sample the "dir" and "up" spline at precisely the same segment and time and use the difference-vectors to create a look-at matrix.

This works perfectly fine, orientation interpolation is reliable and quite smooth (much better than anything else i got partially working).

Maybe this will be useful to someone stumbling on this post in the future.
Jan.

1. 1
2. 2
3. 3
Rutin
15
4. 4
5. 5

• 13
• 26
• 10
• 11
• 9
• ### Forum Statistics

• Total Topics
633726
• Total Posts
3013572
×