Help end child hunger

Vector Length

 
Prev: Catmull-Rom Spline Next: Cross Product
 

The length of a vector v(x,y,z) can be computed as

mag = \sqrt[]{x^{2} + y^{2} + z^{2}}

In CG, we normally need a vector which is unit length, aka a normalized vector. To obtain a normalized vector just divide its components by the vector’s magnitude.

  \displaystyle n = \frac{v}{|v|}

i.e., the components of vector n will be:

\displaystyle n = (\frac{x}{mag}, \frac {y}{mag}, \frac{z}{mag})

 

Prev: Catmull-Rom Spline Next: Cross Product
 

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this: