dos_unitize - dalefugier/DOSLib GitHub Wiki

Unitizes, or normalized, a 2D or 3D vector. A unitized vector maintains its direction but its length becomes 1. The resulting vector is often called a unit vector.

Syntax

(dos_unitize vector)

Parameters

vector

The vector.

Returns

The unitized vector, if successful.

nil on error.

Example

Command: (dos_unitize '(2 1))
(0.894427 0.447214)
Command: (dos_unitize '(2 1 -3))
(0.534522 0.267261 -0.801784)