# Moving an Object along a Curve while Rotating it

I woud like to move an object along a curve. At particular points on the curve, I wish the object to change speed and rotate itself along its axis.

Imagine an airplane flying to a destination. It has its path it must follow, plus, it adjusts its speed and orientation all the way (heading, pith, bank).

Could I kindly ask for a startup information on the following:

• What kind of curves to use to smoothly interpolate an object
• What formulas to use for reliable interpolation, where I could control the speed of moving oject, and the transition between curve knots would be seamless
• What information should be exported from a 3D authoring application
• Should I use quaternions slerp() for this?

If you know about a book that covers this topic efficiently, that would hlep the most. Thank you.

-

For the motion curve, I'd suggest using Hermite curves. You simply give a starting point/velocity and an ending point/velocity, and it creates a nice and smooth curve between those two. Use the ending point/velocity of the first pair of points as the starting point/velocity of the next pair of points and you have a nice long and winding curve that is seamless.

This perfectly handles the requirement to manage the speed: you give a list of points in time with velocities you choose, and it gives you the seamlessly interpolated position and velocity values. If you want to go with this, all you need to extract from the 3D authoring application is points and velocities in the path that you desire. You can also generate them in runtime, perhaps based on user input.

To adjust the orientation, you have a number of options. If the airplane will always point towards where it's going (which is the case that makes sense) you can use the interpolated velocity vector from the Hermite curve to find where your ship should point towards. If you know the up vector (it's moving in a plane, or you know which direction should be up) you can calculate the third axis by cross(front, up) and there you have your orientation.

If you want a somehow "wobbly" orientation so that the plane sometimes deviates from the front direction in the path, you can use the front direction as the desired direction, and successively do one-step slerp between the current orientation and the desired orientation.

If you want custom orientations that have nothing to do with the path, you can of course supply a list of orientation quaternions to this. Then your points become (point, velocity, quaternion). Then you can use slerp between two successive quaternions to set your orientations along the way. Don't forget that slerp is a linear interpolation method. However, it should usually be fine. If you find that the rotations are not smooth enough in the seams, you can try interpolating the list of quaternions with a Bezier curve, as explained here on section 7.

Here is some source code that can help you get started. It has a number of smooth interpolation techniques for a list of quaternions (squad, bezier, etc).

Let me know if you have any questions!

-
 +1 - Thanks, your answer basically covers everything. It answers every question I asked, plus, you provide further material to study. Now, I have enough material to start with. Therefore, I see no reason, not to mark this as the Accepted Answer. – Bunkai.Satori May 15 '11 at 10:08 @Bunkai.Satori thank you, glad to be of help:) I would love to see what you create in the end. – Gazi Alankus May 15 '11 at 10:12