Angle Between Two Vectors: Difference between revisions

From Second Life Wiki
Jump to navigation Jump to search
Qu Qi (talk | contribs)
No edit summary
Gwyneth Llewelyn (talk | contribs)
m Added Template:LSL Header
 
(3 intermediate revisions by 3 users not shown)
Line 1: Line 1:
{{LSL Header}}
Two methods for finding the angle between two vectors. The advantage of the first is that the vectors need not be normalized. If you know you have normal vectors then you can use the second method.
Two methods for finding the angle between two vectors. The advantage of the first is that the vectors need not be normalized. If you know you have normal vectors then you can use the second method.


<lsl>angle = llAtan2( llVecMag(A % B), A * B )</lsl>
<syntaxhighlight lang="lsl2">angle = llAtan2( llVecMag(A % B), A * B )</syntaxhighlight>
<lsl>angle = llAcos( A * B )</lsl>
<syntaxhighlight lang="lsl2">angle = llAcos( A * B )</syntaxhighlight>


What's the difference between this and [[llAngleBetween]]?
See [[llAngleBetween]] for angle between rotations.


{{LSLC|Examples|Angle Between Two Vectors}}
{{LSLC|Examples|Angle Between Two Vectors}}

Latest revision as of 18:01, 28 January 2025

Two methods for finding the angle between two vectors. The advantage of the first is that the vectors need not be normalized. If you know you have normal vectors then you can use the second method.

<syntaxhighlight lang="lsl2">angle = llAtan2( llVecMag(A % B), A * B )</syntaxhighlight> <syntaxhighlight lang="lsl2">angle = llAcos( A * B )</syntaxhighlight>

See llAngleBetween for angle between rotations.