Unofficial LSL Reference

[[types:rotation]]


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

types:rotation [2015-03-28 08:58 SLT]
sei Fix copy/paste typo
types:rotation [2015-09-22 10:16 SLT] (current)
sei change tutorial link to point to articles
Line 2: Line 2:
  
 <WRAP round info>​**IMPORTANT:​**\\ <WRAP round info>​**IMPORTANT:​**\\
-Please note that this is **NOT** an introductory text on rotations, but a reference on the usage of the rotation type in LSL. If you want to learn on rotations, you may want to check the [[/​rotations]] tutorial.+Please note that this is **NOT** an introductory text on rotations, but a reference on the usage of the rotation type in LSL. If you want to learn on rotations, you may want to check the $lart[Rotations] tutorial.
 </​WRAP>​ </​WRAP>​
 ===== Rotation type ===== ===== Rotation type =====
Line 9: Line 9:
  
 A $ty[rotation] literal is written as four comma-separated float expressions enclosed in angle brackets. As usual, integer expressions are automatically cast to float. Note, however, that it's unusual to write a rotation literal yourself; more commonly, rotation values come from the result of functions such as $lfn[llGetRot],​ $lfn[llEuler2Rot],​ $lfn[llList2Rot],​ etc. While functions that accept rotation values are somewhat permissive, writing a //valid// rotation (one which when applied to a vector, returns a vector of the same length) is not a trivial task and you're not recommended to do it unless you have a good understanding of the underlying rules. A $ty[rotation] literal is written as four comma-separated float expressions enclosed in angle brackets. As usual, integer expressions are automatically cast to float. Note, however, that it's unusual to write a rotation literal yourself; more commonly, rotation values come from the result of functions such as $lfn[llGetRot],​ $lfn[llEuler2Rot],​ $lfn[llList2Rot],​ etc. While functions that accept rotation values are somewhat permissive, writing a //valid// rotation (one which when applied to a vector, returns a vector of the same length) is not a trivial task and you're not recommended to do it unless you have a good understanding of the underlying rules.
 +
 +In particular, ''<​0,​ 0, 0, 0>''​ is **not** a valid rotation. It can work in some situations but will utterly fail in others. The null rotation (a rotation that doesn'​t alter the original object'​s orientation) is written as ''<​0,​ 0, 0, 1>''​ and has the associated constant $lct[ZERO_ROTATION].
  
 As with vectors, the components of a quaternion can only be accessed individually when they are in a variable, and in that case, the syntax is the name of the variable followed by a dot and then the letter **x**, **y**, **z** or **s** (the components of a literal appear in that order). For example, ''​rotation_var.s''​ is the fourth (**s**) component of a quaternion. As with vectors, the components of a quaternion can only be accessed individually when they are in a variable, and in that case, the syntax is the name of the variable followed by a dot and then the letter **x**, **y**, **z** or **s** (the components of a literal appear in that order). For example, ''​rotation_var.s''​ is the fourth (**s**) component of a quaternion.
Line 39: Line 41:
 === Inverse of a rotation === === Inverse of a rotation ===
  
-The rotation that cancels a given rotation can be obtained by negating the **s** component. Unfortunately,​ LSL does not support an operand ​that does this, so it has to be done by hand. For example: ''<​q.x,​ q.y, q.z, -q.s>''​ is the inverse rotation of **q**, or if you want to invert the variable you can do: ''​q.s = -q.s;''​+The rotation that cancels a given rotation can be obtained by negating the **s** component. Unfortunately,​ LSL does not support an operator ​that does this, so it has to be done by hand. For example: ''<​q.x,​ q.y, q.z, -q.s>''​ is the inverse rotation of **q**, or if you want to invert the variable you can do: ''​q.s = -q.s;''​
  
 === Type casting a quaternion === === Type casting a quaternion ===
Line 47: Line 49:
   * ''​(rotation)rotation_value''​ does nothing special to the value, as expected.   * ''​(rotation)rotation_value''​ does nothing special to the value, as expected.
   * ''​(rotation)string_value''​ is supported; see $lty[string#​Type casting of strings] for details.   * ''​(rotation)string_value''​ is supported; see $lty[string#​Type casting of strings] for details.
-  * ''​(string)rotation_value''​ is supported too; see $lty[float#Precision] for details.+  * ''​(string)rotation_value''​ is supported too; see $lty[float#Type casting a float to string] for details.
   * ''​(list)rotation_value''​ results in a list with one single element of type $ty[rotation].   * ''​(list)rotation_value''​ results in a list with one single element of type $ty[rotation].