Difference between revisions of "LlAxes2Rot"

From Second Life Wiki
Jump to: navigation, search
(added unit vector requirement for llAxes2Rot)
m (Added a Haiku)
 
(14 intermediate revisions by 4 users not shown)
Line 2: Line 2:
 
|func_id=17|func_sleep=0.0|sort=Axes2Rot|func_energy=10.0
 
|func_id=17|func_sleep=0.0|sort=Axes2Rot|func_energy=10.0
 
|func=llAxes2Rot|sort=Axes2Rot
 
|func=llAxes2Rot|sort=Axes2Rot
 +
|func_footnote=All three vectors must be mutually orthogonal unit vectors.
 
|return_type=rotation
 
|return_type=rotation
 
|p1_type=vector|p1_name=fwd
 
|p1_type=vector|p1_name=fwd
Line 7: Line 8:
 
|p3_type=vector|p3_name=up
 
|p3_type=vector|p3_name=up
 
|return_text=that is defined by the 3 coordinate axes
 
|return_text=that is defined by the 3 coordinate axes
|notes=Technically, only two non-parallel vectors are needed to define this rotation which can be done by calling:
+
|notes=Technically, only the first two vectors are needed to define this rotation, which can be done by calling any of these:
<pre>llAxes2Rot(fwd, left, fwd % left);</pre>All three vectors must be mutually orthogonal unit vectors.
+
<source lang="lsl2">llAxes2Rot(fwd, left, fwd % left);
 +
llAxes2Rot(left % up, left, up);
 +
llAxes2Rot(fwd, up % fwd, up);</source>
 
|spec
 
|spec
 
|caveats
 
|caveats
|examples
+
|examples=<source lang="lsl2">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) );
 +
    }
 +
}</source>
 +
 
 +
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.
 
|helpers
 
|helpers
 
|also_functions
 
|also_functions
 
|also_events
 
|also_events
|also_tests
+
|also_tests=
 +
{{LSL_DefineRow||[[User:Dora_Gustafson/llAxes2Rot_right_and_wrong|Visual illustration]]|Importance of mutually orthogonal unit vectors}}
 
|also_articles
 
|also_articles
 
|cat1=Math/3D
 
|cat1=Math/3D
Line 21: Line 41:
 
|cat3
 
|cat3
 
|cat4
 
|cat4
 +
|haiku={{Haiku|quaternions rule|the whole world spins at your whim|or crashes and burns}}
 
}}
 
}}

Latest revision as of 04:10, 7 March 2016

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

Haiku

quaternions rule
the whole world spins at your whim
or crashes and burns