interpolation/Cubic/Rotation

From Second Life Wiki
< Interpolation‎ | Cubic
Revision as of 02:57, 14 September 2011 by Nexii Malthus (talk | contribs) (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_…")
(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

<lsl>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.</lsl>

Examples

<lsl></lsl>