interpolation/Cubic/Rotation

From Second Life Wiki
< Interpolation‎ | Cubic
Revision as of 16:02, 24 January 2015 by ObviousAltIsObvious Resident (talk | contribs) (<lsl> tag to <source>)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Summary

Function: rotation rCub( rotation a, rotation b, rotation c, rotation d, float t );

Spherical-Cubic interpolation between four rotations.
Returns a rotation

• rotation a Start
• rotation b End
• rotation c Affects path curve
• rotation d Affects path curve
• float t

Specification

rotation rCub(rotation a, rotation b, rotation c, rotation d, float t){
    return rLin( rLin(a,b,t), rLin(c,d,t), 2*t*(1-t) );
}
rotation rLin(rotation x, rotation y, float t) {
    float ang = llAngleBetween(x, y);
    if(ang > PI) ang -= TWO_PI;
    return x * llAxisAngle2Rot(llRot2Axis(y/x)*x, ang*t);
}
// Released into public domain. By Nexii Malthus.

Examples