Vector Unitze
''' ---------------
''' Unitize a 3D vector
''' ---------------
Function VectorUnitize(v)
VectorUnitize = Null
Dim dist, x, y, z, x2, y2, z2
x = v(XX) : y = v(YY) : z = v(ZZ)
x2 = x * x : y2 = y * y : z2 = z * z
dist = x2 + y2 + z2
If dist <= 0.0 Then Exit Function
dist = Sqr(dist)
x = x / dist
y = y / dist
z = z / dist
VectorUnitize = Array(x, y, z)
End Function
page revision: 0, last edited: 03 Aug 2008 18:05