Game Development Reference
In-Depth Information
Summarizing the known vectors and substituting gives us
v = v + v ,
v = ( v
n ) n ,
v
= v
= v v
= v − ( v n ) n ,
v
= k v
= k ( v n ) n ,
= v − ( v n ) n + k ( v n ) n
= v + (k − 1) ( v n ) n .
+ v
v
= v
Now that we know how to scale an arbitrary vector, we can compute the
value of the basis vectors after scale. We derive the first 2D basis vector;
the other basis vector is similar, and so we merely present the results. (Note
that column vectors are used in the equations below strictly to make the
equations format nicely on the page.):
p =
1
0
,
1
0
1
0
n x
n y
n x
n y
p
= p + (k − 1) ( p n ) n =
+ (k − 1)
(k − 1)n x 2
(k − 1)n x n y
1
0
n x
n y
1
0
=
+ (k − 1)n x
=
+
1 + (k − 1)n x 2
(k − 1)n x n y
=
,
q =
0
1
,
(k − 1)n x n y
1 + (k − 1)n y 2
q
=
.
Forming a matrix from the basis vectors, we arrive at the 2D matrix to
scale by a factor of k in an arbitrary direction specified by the unit vector n :
1 + (k − 1)n x 2
p
(k − 1)n x n y
2D matrix to scale in an
arbitrary direction
S ( n ,k) =
=
.
1 + (k − 1)n y 2
q
(k − 1)n x n y
Search WWH ::




Custom Search