Game Development Reference
In-Depth Information
The D3DX function to build a translation matrix is:
D3DXMATRIX *D3DXMatrixTranslation(
D3DXMATRIX* pOut,
// Result.
FLOAT x,
// Number of units to translate on x-axis.
FLOAT y,
// Number of units to translate on y-axis.
FLOAT z
// Number of units to translate on z-axis.
);
Exercise
:Let
T
(
p
) be a matrix representing a translation transforma-
tion, and let
v
=[
v
1
,
v
2
,
v
3
, 0] be any vector. Verify
vT
(
p
)=
v
(that is,
verify the vector is not affected by translations if
w
= 0).
The inverse of the translation matrix is found by simply negating
the translating vector
p
.
1
0
0
0
0
1
0
0
T
1
T
p
0
0
1
0
p
p
p
1
x
y
z
The Rotation Matrices
Figure 9: Rotating
30 degrees coun-
terclockwise
around the z-axis
from our
perspective
We can rotate a vector
radians around the x-, y-, and z-axis using the
following matrices. Note that angles are measured clockwise when
looking down the axis of rotation toward the origin.
1
0
0
0
0
cos
sin
0
X
0
sin
cos
0
0
0
0
1
The D3DX function to build an x-axis rotation matrix is:
D3DXMATRIX *D3DXMatrixRotationX(
D3DXMATRIX* pOut,
// Result.
Search WWH ::
Custom Search