Game Development Reference
In-Depth Information
Example : Find the transpose for the following two matrices:
a
b
c
2
1
8
A
B
d
e
f
3
6
4
g
h
i
To reiterate, the transposes are found by interchanging the rows and
columns. Thus:
2
3
a
d
g
T
T
A
1
6
B
b
e
h
8
4
c
f
i
D3DX Matrices
When programming Direct3D applications, we typically use 4 4 matri-
ces and 1 4 row vectors exclusively. Note that using these two sizes
of matrices implies the following matrix multiplications are defined:
Vector-matrix multiplication . That is, if v isa1 4 row vector
and T isa4 4 matrix, the product vT is defined and the result is a
1 4 row vector.
Matrix-matrix multiplication . That is, if T isa4 4 matrix and
R isa4 4 matrix, the products TR and RT are defined and both
result in a 4 4 matrix. Note that the product TR does not neces-
sarily equal the product RT because matrix multiplication is not
commutative.
To represent 1 4 row vectors in D3DX, we typically use the
D3DXVECTOR3 and D3DXVECTOR4 vector classes. Of course,
D3DXVECTOR3 only has three components, not four. However, the
fourth component is typically an understood one or zero (more on this
in the next section).
To represent 4 4 matrices in D3DX, we use the D3DXMATRIX
class, defined as follows:
typedef struct D3DXMATRIX : public D3DMATRIX
{
public:
D3DXMATRIX() {};
D3DXMATRIX(CONST FLOAT*);
D3DXMATRIX(CONST D3DMATRIX&);
D3DXMATRIX(FLOAT _11, FLOAT _12, FLOAT _13, FLOAT _14,
FLOAT _21, FLOAT _22, FLOAT _23, FLOAT _24,
FLOAT _31, FLOAT _32, FLOAT _33, FLOAT _34,
FLOAT _41, FLOAT _42, FLOAT _43, FLOAT _44);
Search WWH ::




Custom Search