Difference between revisions of "LlAxes2Rot"

From Second Life Wiki
Jump to navigation Jump to search
m
Line 34: Line 34:
|also_functions
|also_functions
|also_events
|also_events
|also_tests
|also_tests=
{{LSL_DefineRow||[[Dora_Gustafson/llAxes2Rot_right_and_wrong|Visual illustration]]|Importance of mutually orthogonal unit vectors}}
|also_articles
|also_articles
|cat1=Math/3D
|cat1=Math/3D

Revision as of 07:54, 5 August 2009

Summary

Function: rotation llAxes2Rot( vector fwd, vector left, vector up );
0.0 Forced Delay
10.0 Energy

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 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: <lsl>llAxes2Rot(fwd, left, fwd % left); llAxes2Rot(left % up, left, up); llAxes2Rot(fwd, up % fwd, up);</lsl>

Deep Notes

Tests

•  Visual illustration Importance of mutually orthogonal unit vectors

Signature

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