Difference between revisions of "LlVecNorm"

From Second Life Wiki
Jump to navigation Jump to search
 
m (Replaced old <LSL> block with <source lang="lsl2">)
 
(19 intermediate revisions by 5 users not shown)
Line 1: Line 1:
{{lowercase|llVecNorm}}
{{LSL_Function
__NOTOC__
|inject-2={{Issues/SVC-4711}}
 
|func=llVecNorm
{| width="100%"
|func_id=13|func_sleep=0.0|func_energy=10.0
|-
|p1_type=vector|p1_name=vec|p1_desc=Any valid vector
|<div id="box">
|return_type=vector
== [[LSL_Type_vector|vector]] llVecNorm( [[LSL_Type_vector|vector]] vec); ==
|Return_text=that is {{LSLP|vec}} normalized (a unit vector sharing the same direction as {{LSLP|vec}}).
<div style="padding: 0.5em">
|func_footnote=If {{LSLP|vec}} is a [[ZERO_VECTOR]], than the value returned is a [[ZERO_VECTOR]].
* vec - Any valid vector value
|spec
</div>
|caveats
</div>
|examples=
|-
<source lang="lsl2">
|
<div id="box">
 
== Specification ==
<div style="padding: 0.5em">
Returns the vec normalized
{|  
|-
| [[LSL_Energy|Energy]]:
| 10.0
|-
| [[LSL_Sleep|Sleep]]:
| 0.0
|-
| [[LSL_Function_ID|Function ID]]:
| 13
|}
</div>
</div>
|-
|
<div id="box">
 
== Caveats ==
<div style="padding: 0.5em">
</div>
</div>
 
|-
|
<div id="box">
== Examples ==
<div style="padding: 0.5em">
<lsl>
default {
default {
     state_entry()
     state_entry()
     {
     {
         vector input = <1.0,2.0,3.0>;
         vector input = <1.0,2.0,3.0>;
         llSay(0,"The normalize of "+(string)input+" is: "+(string)llVecNorm(input) );
         llSay(0,"The unit vector on "+(string)input+" is: "+(string)llVecNorm(input) );
     }
     }
}
}
</lsl>
</source>
</div>
|helpers
</div>
|also_functions={{LSL DefineRow||[[llVecMag]]|}}
|-
{{LSL DefineRow||[[llVecDist]]|}}
|
|also_events
<div id="box">
|also_tests
== Helper Functions ==
|also_articles
<div style="padding: 0.5em">
|notes=
<lsl>
* Mathematically equivalent to:
</lsl>
** vec / [[llVecMag]]( vec )
</div>
** vec / llSqrt( vec.x * vec.x + vec.y * vec.y + vec.z * vec.z )
</div>
|cat1=Math/3D
|-
|cat2=Vector
|
|cat3
<div id="box">
|cat4
== See Also ==
}}
<div style="padding: 0.5em">
</div>
</div>
|-
|
<div id="box">
== Notes ==
<div style="padding: 0.5em">
</div>
</div>
|}
 
[[Category:LSL_Functions]]
[[Category:LSL_Math]]

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 );