Game Development Reference
In-Depth Information
If we multiply any arbitrary vector by this matrix, then, as expected,
each component is scaled by the appropriate scale factor:
2
3
k x
0
0
4
5
x y z
0 k y
0
=
k x x k y y k z z
.
0
0 k z
5.2.2
Scaling in an Arbitrary Direction
We can apply scale independent of the coordinate system used by scaling
in an arbitrary direction. We define n to be the unit vector parallel to the
direction of scale, and k to be the scale factor to be applied about the line
(in 2D) or plane (in 3D) that passes through the origin and is perpendicular
to n . We are scaling along n , not about n .
To derive a matrix that scales along an arbitrary axis, we'll use an
approach similar to the one used in Section 5.1.3 for rotation about an
arbitrary axis. Let's derive an expression that, given an arbitrary vector
v , computes v
in terms of v , n , and k. As before, we separate v into two
values, v and v , which are parallel and perpendicular to n , respectively,
such that v = v + v . The parallel portion, v , is the projection of v
onto n . From Section 2.11.2, we know that v = ( v n ) n . Since v is
perpendicular to n , it will not be affected by the scale operation. Thus
v
= v
+ v , and all we have left to do is compute the value of v
. Since
v is parallel to the direction of scale, v
is trivially given by k v . This is
shown in Figure 5.7.
Figure 5.7
Scaling a vector along an arbitrary
direction
 
Search WWH ::




Custom Search