Game Development Reference
In-Depth Information
would multiply the vector by 2. If k < 0, then the direction of the vector
is flipped. Figure 2.9 illustrates a vector multiplied by several different
scalars.
2.7
Vector Addition and Subtraction
We can add and subtract two vectors, provided they are of the same dimen-
sion. The result is a vector quantity of the same dimension as the vector
operands. We use the same notation for vector addition and subtraction as
is used for addition and subtraction of scalars.
2.7.1
Official Linear Algebra Rules
The linear algebra rules for vector addition are simple: to add two vectors,
we add the corresponding components:
2
4
3
5 +
2
4
3
5 =
2
4
3
5 .
Adding two vectors
a 1
a 2
.
a n−1
a n
b 1
b 2
.
b n−1
b n
a 1 + b 1
a 2 + b 2
.
a n−1 + b n−1
a n + b n
Subtraction can be interpreted as adding the negative, so a b = a +
(− b ):
2
4
3
5
2
4
3
5 =
2
4
3
5 +
0
@
2
4
3
5
1
A =
2
4
3
5 .
Subtracting two vectors
a 1
a 2
.
a n−1
a n
b 1
b 2
.
b n−1
b n
a 1
a 2
.
a n−1
a n
b 1
b 2
.
b n−1
b n
a 1
− b 1
− b 2
.
a n−1 − b n−1
a n − b n
a 2
For example, given
2
3
2
3
2
3
1
2
3
4
5
6
−3
0
4
5
4
5
4
5
a =
,
b =
,
c =
,
 
Search WWH ::




Custom Search