interpolation/Cubic/Rotation

From Second Life Wiki
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