Differences

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

Link to this comparison view

Both sides previous revision Previous revision
wiki:scripting_portal:lsl_types:rotation [2019/11/02 15:35]
Royale Mobian [Another way to think about combining rotations]
wiki:scripting_portal:lsl_types:rotation [2019/11/02 15:38] (current)
Royale Mobian [Local vs Global (World) rotations]
Line 89: Line 89:
  
 ===== Local vs Global (World) rotations ===== ===== Local vs Global (World) rotations =====
 +It is important to distinguish between the **rotation** relative to the world, and the **rotation** relative to the local object itself. In the editor, you can switch back and forth from one to the other. In a script, you must convert from one to the other to get the desired behavior.\\ 
 +\\ 
 +**Local** rotations are ones done around the axes embedded in the object itself forward/​back,​ left/right, up/down, irrespective of how the object is rotated in the world. Global rotations are ones done around the world axes, North/​South,​ East/West, Higher/​Lower. You can see the difference by rotating a prim, then edit it and change the axes settings between local and global, notice how the colored axes arrows change.\\ 
 +\\ 
 +In LSL, the difference between doing a **local** or **global** rotation is the order the **rotations** are evaluated in the statement.\\ 
 +\\ 
 +This does a **local** 30 degree rotation by putting the constant 30 degree **rotation** to the left of the object'​s starting **rotation** (myRot). It is like the first operation in the first example above, just twisting the dart 30 degrees around its own long axis.\\ 
 +<code ossl> 
 +rotation localRot = rot30X * myRot;// ​ do a local rotation by multiplying a constant rotation by a world rotation 
 +</​code>​ 
 +To do a **global** rotation, use the same **rotation** values, but in the opposite order. This is like the second operation in the second example, the dart rotating up and to the right around the world X axis. In this case, the existing rotation (myRot) is rotated 30 degrees around the global X axis.\\ 
 +<code ossl> 
 +rotation globalRot = myRot * rot30X;// do a global rotation by multiplying a world rotation by a constant rotation 
 +</​code>​
 ===== Another way to think about combining rotations ===== ===== Another way to think about combining rotations =====
 You may want to think about this **local** vs **global** difference by considering that **rotations** are done in evaluation order, that is left to right except for parenthesized expressions.\\ You may want to think about this **local** vs **global** difference by considering that **rotations** are done in evaluation order, that is left to right except for parenthesized expressions.\\
QR Code
QR Code wiki:scripting_portal:lsl_types:rotation (generated for current page)