interpolation/Cubic/Rotation

From Second Life Wiki
Jump to navigation Jump to search
The printable version is no longer supported and may have rendering errors. Please update your browser bookmarks and please use the default browser print function instead.

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