Thread: Interpolation in the MDL/X View Single Post 01-13-2006, 03:38 AM   #4
StealthFox
User

Join Date: May 2004
Posts: 132

Submissions (1)  I will add all of the knowledge that I have on bone rotations, SLerp, Hermite interpolation, and the InTan, OutTan in MDLs.

As you may have discovered, WarcraftIII models mainly have hermite in bone rotations and use SLerp (Spherical Linear Interpolation) for interpolating bone rotation...I think. Here is a formula off of http://number-none.com/product/Under...%20Using%20It/

Written in C++

Quaternion slerp(Quaternion const &v0, Quaternion const &v1, double t) { --v0 is the initial bone position and v1 is next bone position and t is a scalar value
// v0 and v1 should be unit length or else
// something broken will happen.

// Compute the cosine of the angle between the two vectors.
double dot = dot_product(v0, v1);
--This pertains to omega which represents cos theta = v0 (dot product) v1 and is found in wikipedia's formula for SLerp

const double DOT_THRESHOLD = 0.9995;
if (dot > DOT_THRESHOLD) {
// If the inputs are too close for comfort, linearly interpolate
// and normalize the result.

Quaternion result = v0 + t*(v1 – v0);
result.normalize();
return result;
}

Clamp(dot, -1, 1); // Robustness: Stay within domain of acos()
double theta_0 = acos(dot); // theta_0 = angle between input vectors
double theta = theta_0*t; // theta = angle between v0 and result

Quaternion v2 = v1 – v0*dot;
v2.normalize(); // { v0, v2 } is now an orthonormal basis

return v0*cos(theta) + v2*sin(theta);
}

How SLerp works and how it improves the smoothness of a rotation:

"Figure 1: We want to find the vector r that is at angle θ from v0."

"Figure 2: Using v1, we build the orthonormal basis { v0, v2 }, which allows us to easily compute r."

Linear Interpolation is good for easy rotations, but is choppy for most rotations.

Now for those hermite splines and what not:

From my extensive research on hermite stuff, hermite splines are used in keyframing to create a smooth transition from keyframe to keyframe. I believe 3dsMax uses TCB (tension, bias, continuity) splines in their interpolation.

TCB splines

As a side note, tension pertains to the speed at which a position is interpolated to another position (smooth bellcurve at tension = -1 and sharp pointy curve at tension = 1), bias pertains to the skewedness of the spline (curve slopes up fast on the left at bias = -1 and slopes down slowly and the curve initially slopes slowly but then drops quickly on the right when bias = 1), and continuity pertains to the continuity of the derivative of the curve or, in the common tongue, the smoothness of the curve as it approaches the next position and the smoothness as it leaves that position (continuity of -1 is a smooth curve throught the next position and a continuity of 1 curves sharply into the next position and sharply curves out of it).

Hermite splines

Finally, hermite splines use 4 formulas to interpolate keyframes. The formulas are the function for the initial position, the function for the derviative (tangent) of the initial position, the function for the next position, and the function for the derivative (tangent) of the next position. There are also formulas for calculating hermite spline interpolation, but they are complex and are everywhere on the internet. Google "hermite spline""interpolation."

Now if we could only figure out a way to export this "knowledge" from MilkShape3d.......that would help me LOTS.
Attached Images slerpvisual1.jpg (13.8 KB, 94 views) slerpvisual2.jpg (15.4 KB, 76 views)
__________________  