vec_normalize (VECTOR* vector, var length);
Scales the vector to the magnitude given by length, while keeping
it's direction.
Parameters:
vector |
any vector |
length |
new magnitude |
Returns:
vector
Modifies:
vector - magnitude set to length.
Speed:
Fast
Algorithm:
vector[0] *= length / vec_length(vector);
vector[1] *= length / vec_length(vector);
vector[2] *= length / vec_length(vector);
Example:
vec_normalize(vector,1); // The vector is set to the magnitude 1.
See also:
Vectors, vec_add, vec_sub,
vec_scale, vec_set,
vec_inverse, vec_diff
► latest
version online