Skip to content
lsl.devlsl.devLSL Dev

llVecNorm

function
Function syntax
vector llVecNorm(
  1. vector vec// Vector to normalize.
);
Returns
vector
Energy
10

Returns the normalized unit vector pointing the same direction as vec. If <0, 0, 0>, return <0, 0, 0>.

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

How to use
vector result = llVecNorm(ZERO_VECTOR);
Example 1
default {
state_entry()
{
vector input = <1.0,2.0,3.0>;
llSay(0,"The unit vector on "+(string)input+" is: "+(string)llVecNorm(input) );
}
}
  • Mathematically equivalent to:
  • vec / llVecMag( vec )
  • vec / llSqrt( vec.x * vec.x + vec.y * vec.y + vec.z * vec.z )

From the issue templates included by the wiki article:

  • SVC-4711 (bug): llVecNorm returns zero vector as result when input is below a certain magnitude
Original wiki source

Some wiki templates and tables need their original context. View this article on the Second Life Wiki. Technical wording and examples are retained from the source; historical guidance may differ from current behavior.

From the Second Life Wiki

Community documentation adapted from LlVecNorm, by Linden Research, Inc. and contributing residents.View contributors and history.

Built from these wiki pages, as imported:

Licensed under CC BY-SA 3.0. Last wiki edit: .Formatting and links have been adapted for this site; API metadata follows the LSL definitions.