Difference between revisions of "Interpolation/Linear/Rotation"

From Second Life Wiki
Jump to navigation Jump to search
(Woops)
Line 18: Line 18:
rotation x = llEuler2Rot(<0,0,30*DEG_TO_RAD>);
rotation x = llEuler2Rot(<0,0,30*DEG_TO_RAD>);
rotation y = llEuler2Rot(<0,0,90*DEG_TO_RAD>);
rotation y = llEuler2Rot(<0,0,90*DEG_TO_RAD>);
rotation z = rLin(x, y, 0.5); // z equivalent to euler rotation of 60 degrees on Z axis</lsl>
rotation z = rLin(x, y, 0.5); // z equivalent to euler rotation of 60 degrees on Z axis
llOwnerSay((string)(llRot2Euler(z)*RAD_TO_DEG)); // <0.00000, 0.00000, 60.00001>
</lsl>
|cat1=Examples
|cat1=Examples
}}
}}

Revision as of 09:40, 17 November 2012

Summary

Function: rotation rLin( rotation x, rotation y, float t );

Interpolates between two rotation values in a linear fashion.
Returns a rotation

• rotation x
• rotation y
• float t

Specification

<lsl>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> rotation x = llEuler2Rot(<0,0,30*DEG_TO_RAD>); rotation y = llEuler2Rot(<0,0,90*DEG_TO_RAD>); rotation z = rLin(x, y, 0.5); // z equivalent to euler rotation of 60 degrees on Z axis llOwnerSay((string)(llRot2Euler(z)*RAD_TO_DEG)); // <0.00000, 0.00000, 60.00001>

</lsl>