Difference between revisions of "Interpolation/Linear/Rotation"
< Interpolation | Linear
Jump to navigation
Jump to search
m (<lsl> tag to <source>) |
|||
Line 9: | Line 9: | ||
|func_desc= | |func_desc= | ||
Interpolates between two rotation values in a linear fashion. | Interpolates between two rotation values in a linear fashion. | ||
|spec=< | |spec=<source lang="lsl2">rotation rLin(rotation x, rotation y, float t) { | ||
float ang = llAngleBetween(x, y); | float ang = llAngleBetween(x, y); | ||
if(ang > PI) ang -= TWO_PI; | if(ang > PI) ang -= TWO_PI; | ||
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.</ | // Released into public domain. By Nexii Malthus.</source> | ||
|examples=< | |examples=<source lang="lsl2"> | ||
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 | 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> | llOwnerSay((string)(llRot2Euler(z)*RAD_TO_DEG)); // <0.00000, 0.00000, 60.00001> | ||
</ | </source> | ||
|cat1=Examples | |cat1=Examples | ||
}} | }} |
Latest revision as of 15:05, 24 January 2015
LSL Portal | Functions | Events | Types | Operators | Constants | Flow Control | Script Library | Categorized Library | Tutorials |
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
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
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>