User talk:Ugleh Ulrik/Vector2List

From Second Life Wiki
Jump to navigation Jump to search

Hi there!

Another way to grab the individual axes of vectors and rotations is as follows -

<lsl>default {

   state_entry()
   {
       vector pos = llGetPos(); // Store the position as a vector
       
       rotation rot = llGetRot(); // Store the rotation
       
       vector rot_v = llRot2Euler(rot)*RAD_TO_DEG; // Store the rotation as a vector
       
       float pos_x = pos.x;       // Note the use of .x .y and .z
       float pos_y = pos.y;       // We take the name of the variable
       float pos_z = pos.z;       // And add .x .y or .z (lower case).
                                  //
       float rot_x = rot.x;       // S is used to grab the normalizer of a rotation
       float rot_y = rot.y;       //
       float rot_z = rot.z;       //
       float rot_s = rot.s;       //
                                  //
       float rot_v_x = rot_v.x;   // A rotation as a vector is just X Y and Z
       float rot_v_y = rot_v.y;   //
       float rot_v_z = rot_v.z;   //
       
       llOwnerSay("\n\nPosition Floats:" +
                  "\nX = " + ((string)pos_x) +
                  "\nY = " + ((string)pos_y) +
                  "\nZ = " + ((string)pos_z) +
                  "\n\nRotation Floats:" +
                  "\nX = " + ((string)rot_x) +
                  "\nY = " + ((string)rot_y) +
                  "\nZ = " + ((string)rot_z) +
                  "\nS = " + ((string)rot_s) +
                  "\n\nRotation (expressed as a vector) Floats:" +
                  "\nX = " + ((string)rot_v_x) +
                  "\nY = " + ((string)rot_v_y) +
                  "\nZ = " + ((string)rot_v_z));
   }

}</lsl>-- Fred Gandt (talk|contribs) 10:51, 19 April 2010 (UTC)