Difference between revisions of "LlAxes2Rot"

From Second Life Wiki
Jump to: navigation, search
m
Line 9: Line 9:
 
|return_text=that is defined by the 3 coordinate axes
 
|return_text=that is defined by the 3 coordinate axes
 
|notes=Technically, only the first two vectors are needed to define this rotation, which can be done by calling any of these:
 
|notes=Technically, only the first two vectors are needed to define this rotation, which can be done by calling any of these:
<lsl>llAxes2Rot(fwd, left, fwd % left);
+
<source lang="lsl2">llAxes2Rot(fwd, left, fwd % left);
 
llAxes2Rot(left % up, left, up);
 
llAxes2Rot(left % up, left, up);
llAxes2Rot(fwd, up % fwd, up);</lsl>
+
llAxes2Rot(fwd, up % fwd, up);</source>
 
|spec
 
|spec
 
|caveats
 
|caveats
|examples=<lsl>default
+
|examples=<source lang="lsl2">default
 
{
 
{
 
     state_entry()
 
     state_entry()
Line 26: Line 26:
 
         llSay(0, (string) (llRot2Euler(rot) * RAD_TO_DEG) );
 
         llSay(0, (string) (llRot2Euler(rot) * RAD_TO_DEG) );
 
     }
 
     }
}</lsl>
+
}</source>
  
 
This script displays:
 
This script displays:

Revision as of 23:39, 21 January 2015

Summary

Function: rotation llAxes2Rot( vector fwd, vector left, vector up );

Returns a rotation that is defined by the 3 coordinate axes

• vector fwd
• vector left
• vector up

All three vectors must be mutually orthogonal unit vectors.

Examples

default
{
    state_entry()
    {
        vector i = < 1.0, 0.0, 0.0>;
        vector j = < 0.0, 1.0, 0.0>;
        vector k = < 0.0, 0.0, 1.0>;
 
        rotation rot = llAxes2Rot( j, -i, k );
 
        llSay(0, (string) (llRot2Euler(rot) * RAD_TO_DEG) );
    }
}

This script displays:

  Object: <-0.00000, 0.00000, 90.00000>
which shows that (j, -i, k) is obtained by rotating (i, j, k) 90 degrees around z direction.

Notes

Technically, only the first two vectors are needed to define this rotation, which can be done by calling any of these:

llAxes2Rot(fwd, left, fwd % left);
llAxes2Rot(left % up, left, up);
llAxes2Rot(fwd, up % fwd, up);

Deep Notes

Search JIRA for related Issues

Tests

•  Visual illustration Importance of mutually orthogonal unit vectors

Signature

function rotation llAxes2Rot( vector fwd, vector left, vector up );