Difference between revisions of "LlAngleBetween"

From Second Life Wiki
Jump to navigation Jump to search
(I've copied this from lslwiki but I'm the author so it's all cool.)
m
Line 12: Line 12:
|helpers
|helpers
|also_functions={{LSL DefineRow||[[llRotBetween]]}}
|also_functions={{LSL DefineRow||[[llRotBetween]]}}
{{LSL DefineRow||[[llRot2Angle]]|Similar functionality used for the Axis-Angle format}}
|also_events
|also_events
|also_tests
|also_tests
Line 18: Line 19:
|deepnotes=<lsl>float AngleBetween(rotation a, rotation b)
|deepnotes=<lsl>float AngleBetween(rotation a, rotation b)
{
{
     return 2 * llAcos((a.x * b.x + a.y * b.y + a.z * b.z + a.s * b.s)
     return 2.0 * llAcos((a.x * b.x + a.y * b.y + a.z * b.z + a.s * b.s)
                  / llSqrt((a.x * a.x + a.y * a.y + a.z * a.z + a.s * a.s) *  
              / llSqrt((a.x * a.x + a.y * a.y + a.z * a.z + a.s * a.s)
                          (b.x * b.x + b.y * b.y + b.z * b.z + b.s * b.s)));
                      * (b.x * b.x + b.y * b.y + b.z * b.z + b.s * b.s)));
}</lsl>
}</lsl>
|cat1=Math/3D
|cat1=Math/3D

Revision as of 23:50, 15 March 2009

Summary

Function: float llAngleBetween( rotation a, rotation b );

Returns a float that is the angle between rotation a and b.

• rotation a start rotation
• rotation b end rotation

Examples

See Also

Functions

•  llRotBetween
•  llRot2Angle Similar functionality used for the Axis-Angle format

Deep Notes

<lsl>float AngleBetween(rotation a, rotation b) {

   return 2.0 * llAcos((a.x * b.x + a.y * b.y + a.z * b.z + a.s * b.s)
              / llSqrt((a.x * a.x + a.y * a.y + a.z * a.z + a.s * a.s)
                     * (b.x * b.x + b.y * b.y + b.z * b.z + b.s * b.s)));

}</lsl>

Search JIRA for related Issues

Signature

function float llAngleBetween( rotation a, rotation b );