Difference between revisions of "LlVecNorm"

From Second Life Wiki
Jump to navigation Jump to search
m (upgrading to the footnote)
m (Replaced old <LSL> block with <source lang="lsl2">)
 
Line 10: Line 10:
|caveats
|caveats
|examples=
|examples=
<lsl>
<source lang="lsl2">
default {
default {
     state_entry()
     state_entry()
Line 18: Line 18:
     }
     }
}
}
</lsl>
</source>
|helpers
|helpers
|also_functions={{LSL DefineRow||[[llVecMag]]|}}
|also_functions={{LSL DefineRow||[[llVecMag]]|}}

Latest revision as of 11:59, 22 January 2015

Summary

Function: vector llVecNorm( vector vec );

Returns the vector that is vec normalized (a unit vector sharing the same direction as vec).

• vector vec Any valid vector

If vec is a ZERO_VECTOR, than the value returned is a ZERO_VECTOR.

Caveats

Important Issues

~ All Issues ~ Search JIRA for related Bugs
   llVecNorm returns zero vector as result when input is below a certain magnitude

Examples

default {
    state_entry()
    {
        vector input = <1.0,2.0,3.0>;
        llSay(0,"The unit vector on "+(string)input+" is: "+(string)llVecNorm(input) );
    }
}

Notes

  • Mathematically equivalent to:
    • vec / llVecMag( vec )
    • vec / llSqrt( vec.x * vec.x + vec.y * vec.y + vec.z * vec.z )

See Also

Functions

•  llVecMag
•  llVecDist

Deep Notes

All Issues

~ Search JIRA for related Issues
   llVecNorm returns zero vector as result when input is below a certain magnitude

Signature

function vector llVecNorm( vector vec );