Difference between revisions of "LlRot2Angle"

From Second Life Wiki
Jump to navigation Jump to search
(didn't handle the negative parts of the acos)
m
Line 26: Line 26:
|cat3
|cat3
|cat4
|cat4
|deepnotes=<lsl>float llRot2Angle(rotation a)
|deepnotes=<lsl>float Rot2Angle(rotation a)
{
{
     return llAcos(llFabs(a.s) / llSqrt(a.x * a.x + a.y * a.y + a.z * a.z + a.s * a.s)) * 2.0;
     return llAcos(llFabs(a.s) / llSqrt(a.x * a.x + a.y * a.y + a.z * a.z + a.s * a.s)) * 2.0;
}</lsl>
}</lsl>
}}
}}

Revision as of 07:52, 16 March 2009

Summary

Function: float llRot2Angle( rotation rot );
0.0 Forced Delay
10.0 Energy

Returns a float that is the rotation angle represented by rot

• rotation rot

Use in conjunction with llRot2Axis.
To undo use llAxisAngle2Rot.

Caveats

This always returns a positive angle <= PI radians, that is, it is the unsigned minimum angle. A rotation of 3/2 PI radians (270 degrees) will return an angle of PI / 2 radians, not -PI / 2.

Examples

See Also

Functions

•  llAxisAngle2Rot
•  llRot2Axis
•  llRot2Up
•  llRot2Fwd
•  llRot2Left
•  llAngleBetween Similar functionality.

Deep Notes

<lsl>float Rot2Angle(rotation a) {

   return llAcos(llFabs(a.s) / llSqrt(a.x * a.x + a.y * a.y + a.z * a.z + a.s * a.s)) * 2.0;

}</lsl>

Signature

function float llRot2Angle( rotation rot );