Difference between revisions of "Interpolation/Cubic/Rotation"

From Second Life Wiki
Jump to navigation Jump to search
(Created page with "{{LSL_Function |mode=user |func=rCub |p1_type=rotation|p1_name=a|p1_desc=Start |p2_type=rotation|p2_name=b|p2_desc=End |p3_type=rotation|p3_name=c|p3_desc=Affects path curve |p4_…")
 
m (<lsl> tag to <source>)
 
Line 11: Line 11:
|func_desc=
|func_desc=
Spherical-Cubic interpolation between four rotations.
Spherical-Cubic interpolation between four rotations.
|spec=<lsl>rotation rCub(rotation a, rotation b, rotation c, rotation d, float t){
|spec=<source lang="lsl2">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) );
     return rLin( rLin(a,b,t), rLin(c,d,t), 2*t*(1-t) );
}
}
Line 19: Line 19:
     return x * llAxisAngle2Rot(llRot2Axis(y/x)*x, ang*t);
     return x * llAxisAngle2Rot(llRot2Axis(y/x)*x, ang*t);
}
}
// Released into public domain. By Nexii Malthus.</lsl>
// Released into public domain. By Nexii Malthus.</source>
|examples=<lsl></lsl>
|examples=<source lang="lsl2"></source>
|cat1=Examples
|cat1=Examples
}}
}}

Latest revision as of 16:02, 24 January 2015

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