Unofficial LSL Reference

[[user:sei:roll_pitch_yaw]]


Unofficial LSL reference

User Tools

Login

You are currently not logged in! Enter your authentication credentials below to log in. You need to have cookies enabled to log in.

Login

Forgotten your password? Get a new one: Set new password

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

user:sei:roll_pitch_yaw [2015-07-31 20:43 SLT]
sei more wording
user:sei:roll_pitch_yaw [2017-08-17 08:30 SLT] (current)
sei note the order applies to extrinsic rotations
Line 1: Line 1:
-Since this seems to be a FAQ, here is a function to return classic roll/​pitch/​yaw (nautical angles). $lfn[llRot2Euler] can't be used because classic roll/​pitch/​yaw requires XYZ rotation order, and SL uses ZYX rotation order.+Since this seems to be a FAQ, here is a function to return classic roll/​pitch/​yaw (nautical angles). $lfn[llRot2Euler] can't be used because classic roll/​pitch/​yaw requires ​(extrinsic) ​XYZ rotation order, and SL uses ZYX rotation order.
  
 <code lsl2> <code lsl2>
 vector Rot2EulerXYZ(rotation rot) vector Rot2EulerXYZ(rotation rot)
 { {
-    return <​llAtan2(2*(rot.s*rot.x + rot.y*rot.z), ​2*(rot.x*rot.x + rot.y*rot.y)),​+    return <​llAtan2((rot.s*rot.x + rot.y*rot.z), ​0.5 - (rot.x*rot.x + rot.y*rot.y)),​
             llAsin (2*(rot.s*rot.y - rot.x*rot.z)),​             llAsin (2*(rot.s*rot.y - rot.x*rot.z)),​
-            llAtan2(2*(rot.s*rot.z + rot.x*rot.y), ​2*(rot.y*rot.y + rot.z*rot.z))>;​+            llAtan2((rot.s*rot.z + rot.x*rot.y), ​0.5 - (rot.y*rot.y + rot.z*rot.z))>;​
 } }
 </​code>​ </​code>​
 It assumes SL avatar coordinate conventions (X=forward, Y=left, Z=up). Unlike LSL functions, it also assumes the input rotation is normalized. The //x// component of the returned vector is roll (bank), the //y// component is pitch (elevation),​ and the //z// component is yaw (heading). It assumes SL avatar coordinate conventions (X=forward, Y=left, Z=up). Unlike LSL functions, it also assumes the input rotation is normalized. The //x// component of the returned vector is roll (bank), the //y// component is pitch (elevation),​ and the //z// component is yaw (heading).
  
-The following is another version, perhaps easier to remember and to inline but less precise (rotations are not normalized to save memory, but that doesn'​t change the result):+The following is another version, perhaps easier to remember and to inline but less precise (rotations are not normalized to save memory ​under Mono, but that doesn'​t change the result):
 <code lsl2> <code lsl2>
 vector Rot2EulerXYZ(rotation rot) vector Rot2EulerXYZ(rotation rot)