Game Development Reference
In-Depth Information
2.8
Vector Magnitude (Length)
As we have discussed, vectors have magnitude and direction. However, you
might have noticed that neither the magnitude nor the direction is expressed
explicitly in the vector (at least not when we use Cartesian coordinates).
For example, the magnitude of the 2D vector [3,4] is neither 3 nor 4; it's
5. Since the magnitude of the vector is not expressed explicitly, we must
compute it. The magnitude of a vector is also known as the length or norm
of the vector.
2.8.1 Official Linear Algebra Rules
In linear algebra, the magnitude of a vector is denoted by using double
vertical bars surrounding the vector. This is similar to the single vertical
bar notation used for the absolute value operation for scalars. This notation
and the equation for computing the magnitude of a vector of arbitrary
dimension n are shown in Equation (2.2):
n
Magnitude of a vector of
arbitrary dimension
v =
v i 2 =
v 1 2 + v 2 2 + + v n−1 2 + v n 2 .
(2.2)
i=1
Thus, the magnitude of a vector is the square root of the sum of the
squares of the components of the vector. This sounds complicated, but
the magnitude equations for 2D and 3D vectors are actually very simple:
v =
v x 2 + v y 2
(for a 2D vector v ),
(2.3)
Vector magnitude for 2D
and 3D vectors
v =
v x 2 + v y 2 + v z 2
(for a 3D vector v ).
The magnitude of a vector is a nonnegative scalar quantity. An example
of how to compute the magnitude of a 3D vector is
5 2 + (−4) 2 + 7 2 =
5
−4
7
=
25 + 16 + 49 =
90
≈ 9.4868.
Some topics use a single bar notation to indicate vector magnitude: | v |
 
Search WWH ::




Custom Search