# llVecNorm

*LSL function*

```lsl
vector vector llVecNorm(vector vec);
```

- `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](/constants/ZERO_VECTOR/), than the value returned is a [ZERO_VECTOR](/constants/ZERO_VECTOR/).

```lsl title="How to use" frame="terminal"
vector result = llVecNorm(ZERO_VECTOR);
```

## Examples

<details open>
<summary>Example 1</summary>

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

</details>

## Notes

- Mathematically equivalent to:
- **vec** / [llVecMag](/functions/llVecMag/)( **vec** )
- **vec** / `llSqrt( vec.x * vec.x + vec.y * vec.y + vec.z * vec.z )`

## Known issues

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

## See also

### Functions

- [llVecMag](/functions/llVecMag/)
- [llVecDist](/functions/llVecDist/)

---

*Source: [LlVecNorm](https://wiki.secondlife.com/wiki/LlVecNorm) on the Second Life Wiki. Content from the Second Life Wiki articles LlVecNorm (revision 1194325, 2015-01-22) and Template:Issues/SVC-4711 (revision 455822, 2009-08-11), CC BY-SA 3.0.*

---

From lsl.dev: https://lsl.dev/functions/llVecNorm/
