Difference between revisions of "Angle Between Two Vectors"

From Second Life Wiki
Jump to navigation Jump to search
m (<lsl> tag to <source>)
m (Replaced <source> with <syntaxhighlight>)
 
Line 1: Line 1:
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.


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


See [[llAngleBetween]] for angle between rotations.
See [[llAngleBetween]] for angle between rotations.


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

Latest revision as of 03:06, 29 November 2024

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.

angle = llAtan2( llVecMag(A % B), A * B )
angle = llAcos( A * B )

See llAngleBetween for angle between rotations.