Advertisement

(SLERP) Sperical Linear Interpolation

Started by December 11, 2002 11:43 PM
0 comments, last by Fyre_dragenn 22 years, 2 months ago
Can someone help me to understand how SLERPs functions. I have read one article provided by gamedev.net, but couldn''t understand it because it only skimmed on the topic. I would appreciate any advice or links on the topic. Oh yeah! One more question, Can slerps be applied to Matrix transformations (Such as animation keys).
SLERP is a way of interpolating between two rotations. You generally don''t need to know how it works to use it, as most libraries provide it. Usually the interface is something like

SLERP(QUAT *qOut, QUAT *qStart, QUAT *qEnd, float fScale);

qStart and qEnd are (pointers to) the initial and final quaternions, which correspond to the starting rotation and ending rotation for your object. fScale is a floating point number between 0 and 1.

''interpolation'' just means placing values between two endpoints, and you do this by varying fScale while keeping qStart and qEnd fixed. The code to do this looks something like this:

for (int iStep = 0; iStep <= 20; iStep++)
{
SLERP(&CurrentRot, &InitialRot, &FinalRot, iStep / 20);
ObjectSetRotation(obj, &CurrentRot);
ObjectDraw(obj);
}

Though in practice this will be done as part of a bigger loop, e.g. a render loop, with ''iStep / 20'' replaced with something based on the frame rate or game clock.

And no, SLERP only works with quaternions, not matrices. If you have matrices convert them to quaternions, use SLERP, then convert back.
John BlackburneProgrammer, The Pitbull Syndicate

This topic is closed to new replies.

Advertisement