Difference between revisions of "LlVecNorm"

From Second Life Wiki
Jump to navigation Jump to search
m (Replaced old <LSL> block with <source lang="lsl2">)
 
(10 intermediate revisions by 5 users not shown)
Line 1: Line 1:
{{LSL_Function
{{LSL_Function
|inject-2={{Issues/SVC-4711}}
|func=llVecNorm
|func=llVecNorm
|func_id=13|func_sleep=0.0|func_energy=10.0
|func_id=13|func_sleep=0.0|func_energy=10.0
|func_footnote
|p1_type=vector|p1_name=vec|p1_desc=Any valid vector
|p1_type=vector|p1_name=vec|p1_desc=Any valid vector
|return_type=vector
|return_type=vector
|return_text=that is the normal of the vector ('''vec''' / {{LSLG|llVecMag}}('''vec''')).
|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=
<pre>
<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) );
     }
     }
}
}
</pre>
</source>
|helpers
|helpers
|also_functions={{LSL DefineRow||{{LSLG|llVecMag}}|}}
|also_functions={{LSL DefineRow||[[llVecMag]]|}}
{{LSL DefineRow||{{LSLG|llVecDist}}|}}
{{LSL DefineRow||[[llVecDist]]|}}
|also_events
|also_events
|also_tests
|also_tests
|also_articles
|also_articles
|notes
|notes=
* Mathematically equivalent to:
** vec / [[llVecMag]]( vec )
** vec / llSqrt( vec.x * vec.x + vec.y * vec.y + vec.z * vec.z )
|cat1=Math/3D
|cat1=Math/3D
|cat2
|cat2=Vector
|cat3
|cat3
|cat4
|cat4
}}
}}

Latest revision as of 10:59, 22 January 2015

Summary

Function: vector llVecNorm( vector vec );
0.0 Forced Delay
10.0 Energy

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.

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

Signature

function vector llVecNorm( vector vec );