3D Lingo Dictionary > L-N > normalize

 

normalize

Syntax

normalize(vector)
vector.normalize()

Description

3D command; normalizes a vector by dividing the x, y, and z components by the vector's magnitude. Vectors that have been normalized always have a magnitude of 1.

Example

This statement shows the value of the vector MyVec before and after being normalized.

MyVec = vector(-209.9019, 1737.5126, 0.0000)
MyVec.normalize()
put MyVec
-- vector(-0.1199, 0.9928, 0.0000)
put MyVec.magnitude
-- 1.0000

This statement shows the value of the vector ThisVector before and after being normalized.

ThisVector = vector(-50.0000, 0.0000, 0.0000)
normalize(ThisVector)
put ThisVector
-- vector(-1.0000, 0.0000, 0.0000)

See also

getNormalized, randomVector, magnitude