Game Development Reference
In-Depth Information
q
0
0
0
x
0
q
0
0
y
S
q
0
0
q
0
z
0
0
0
1
The D3DX function to build a scaling matrix is:
D3DXMATRIX *D3DXMatrixScaling(
D3DXMATRIX* pOut,
// Result.
FLOAT sx,
// Number of units to scale on the x-axis.
FLOAT sy,
// Number of units to scale on the y-axis.
FLOAT sz
// Number of units to scale on the z-axis.
);
The inverse of a scaling matrix is found by taking the reciprocal of each
scaling factor:
1 000
q
x
1
0
0
0
111
,
1
q
SS
,
y
qqq
x
y
z
1
00 0
q
z
0001
Combining Transformations
Often we apply a sequence of transformations to a vector. For instance,
we may scale a vector, then rotate it, and finally translate it into its
desired position.
Example : Scale the vector p = [5, 0, 0, 1] by one-fifth on all axes, then
rotate it /4 radians on the y-axis, and finally translate it 1 unit on the
x-axis, 2 units on the y-axis, and -3 units on the z-axis.
Solution: Note that we must perform a scaling, a y-axis rotation, and a
translation. We set up our transformation matrices S , R y , T for scaling,
rotating, and translating, respectively, as follows:
1 000
5
.
707
0
.
707
0
1
0
1
0
0
0
0
0
111
,
S
,
R
5
y
555
4
.
707
0
.
707
0
1
00 0
5
0001
0
0
0
1
Search WWH ::




Custom Search