Difference between revisions of "LlVecNorm"

From Second Life Wiki
Jump to navigation Jump to search
m (Replaced old <LSL> block with <source lang="lsl2">)
 
(15 intermediate revisions by 5 users not shown)
Line 1: Line 1:
{{LSLFunctionAll
{{LSL_Function
|inject-2={{Issues/SVC-4711}}
|func=llVecNorm
|func=llVecNorm
|func_id=13
|func_id=13|func_sleep=0.0|func_energy=10.0
|func_sleep=0.0
|p1_type=vector|p1_name=vec|p1_desc=Any valid vector
|func_energy=10.0
|func_footnote
|p1_type=vector
|p1_name=vec
|p1_desc=Any valid vector
|p2_type|p2_name|p2_desc
|p3_type|p3_name|p3_desc
|p4_type|p4_name|p4_desc
|p5_type|p5_name|p5_desc
|p6_type|p6_name|p6_desc
|p7_type|p7_name|p7_desc
|p8_type|p8_name|p8_desc
|p9_type|p9_name|p9_desc
|p10_type|p10_name|p10_desc
|p11_type|p11_name|p11_desc
|p12_type|p12_name|p12_desc
|return_type=vector
|return_type=vector
|return_text=that is the normal of the vector (val / {{LSLG|llVecMag}}(val)).
|Return_text=that is {{LSLP|vec}} normalized (a unit vector sharing the same direction as {{LSLP|vec}}).
|func_footnote=If {{LSLP|vec}} is a [[ZERO_VECTOR]], than the value returned is a [[ZERO_VECTOR]].
|spec
|spec
|caveats
|caveats
|examples=
|examples=
<lsl>
<source lang="lsl2">
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 normal of "+(string)input+" is: "+(string)llVecNorm(input) );
         llSay(0,"The unit vector on "+(string)input+" is: "+(string)llVecNorm(input) );
     }
     }
}
}
</lsl>
</source>
|helpers
|helpers
|related={{LSLG|llVecMag}}<br/>{{LSLG|llVecDist}}
|also_functions={{LSL DefineRow||[[llVecMag]]|}}
|also
{{LSL DefineRow||[[llVecDist]]|}}
|notes
|also_events
|also_tests
|also_articles
|notes=
* Mathematically equivalent to:
** vec / [[llVecMag]]( vec )
** vec / llSqrt( vec.x * vec.x + vec.y * vec.y + vec.z * vec.z )
|cat1=Math/3D
|cat2=Vector
|cat3
|cat4
}}
}}
[[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 );