Difference between revisions of "LlAxes2Rot"

From Second Life Wiki
Jump to navigation Jump to search
m (I definitely should preview :-( sorry)
(Perharps simpler to understand so)
Line 17: Line 17:
     state_entry()
     state_entry()
     {
     {
         rotation rot = llAxes2Rot(
         vector i = <  1.0,  0.0,  0.0>;
            0.0,  1.0,  0.0>,
        vector j = < 0.0,  1.0,  0.0>;
            < -1.0,  0.0,  0.0>,
        vector k = <  0.0,  0.0,  1.0>;
            <  0.0,  0.0,  1.0>);
 
        rotation rot = llAxes2Rot( j, -i, k );


         llSay(0, (string) (llRot2Euler(rot) * RAD_TO_DEG) );
         llSay(0, (string) (llRot2Euler(rot) * RAD_TO_DEG) );
Line 26: Line 27:
}</lsl>
}</lsl>


This script shows that ('''fwd''', '''left''', '''up''') = ('''j''', '''-i''', '''k''') is obtained by rotating ('''i''', '''j''', '''k''') 90 degrees around z direction.
This script shows that ('''j''', '''-i''', '''k''') is obtained by rotating ('''i''', '''j''', '''k''') 90 degrees around z direction.
|helpers
|helpers
|also_functions
|also_functions

Revision as of 09:03, 6 April 2008

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

<lsl> 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) );
   }

}</lsl>

This script 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:

llAxes2Rot(fwd, left, fwd % left);

Deep Notes

Search JIRA for related Issues

Signature

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