Search code examples
mathmatrixrotationcurvequaternions

How to calculate the orientation of an object moving along a hermite curve


I struggle with the orientation of an object I am moving along a hermite curve. I figured out how to move it at constant speed at also have the tangent of my curve, which would be the forward vector of the moving object. My problem is: How do I know the up and right vector? The easiest way would be to start at a given rotation and then step through the curve always taking the last rotation as a reference for the next one, like in this reference:

Camera movement along a splinepdf

But this would result in an uncontrollable rotation at the end of the spline. What I am trying to do is to create an algorithm which gives you the correct orientation at any point of the curve, without stepping through it. Ideally it would use the orientation of the two controlpoints for the current segment as a reference.

I thought of using some kind of pre-calculated data, which is created from the two orientations of the controlpoints and the current curve segments form, but didn't manage to come up with a solution.

I would be happy to get any answers or just ideas how to approach this problem.


Solution

  • OK i came up with a solution using frenet frames. I define an orientation for each of my control points, then i calculate a number of points along the spline for each segment. Each points orientation is then calculated using the previous points orientation. The orientatin of the first point equals the orientation of the control point. Here is a very nice description of the procedure. After calculating each points orientation, you can interpolate them so the last points orientation matches the orientation of the next controlpoint.