
2~ CHAPTER 3 Vectors
$v = unit( $v )-
$1en = mag( $v ).
print $1en" // Prints 1.0
FLOAT ARRAY
If the vector is a float array, the
normalize
command can be used.
float $v[] = {2.4, 4.6, 7.3}-
float $1en = normalize( $v )-
print $1en-
3.8.2
C++ API
To normalize the vector, call the normalize function. This will perform an in-place
normalization.
MVector v"
v.normal ize( ) •
To get a copy of the vector, but with unit length, use the normal function. This
makes a copy of the vector, normalizes it, and returns it. The original vector is left
untouched.
MVector v-
MVector norm = v.normal()- ...