Introducing a third dimension into the model of a
scene enhances its realism, admits motion of the
viewer relative to the scene, and allows for perspective
on the objects in the scene. In a twodimensional
model, sprites move along a flat surface, the viewer
is outside the scene, and there is no perspective. The
representations of sprite positions, orientations, rotations,
scalings, and translations across the surface are straightforward.
But once we add a third dimension, the mathematics becomes
more complex. There are two new degrees of freedom: the
objects in the scene can move around and in front of one another
and the observer can move towards, away from, and around the objects
in the scene.
In this chapter, we extend the concepts defined in the previous chapter
to three dimensional coordinate systems. We introduce the two system
for describing motion, the viewpoint transformation,
and the perspective transformation. We introduce the framework's
vector and matrix library, which defines the structures and operations
on them. We conclude by describing the Direct3D structures and
utilities available as alternatives to that library.
Coordinate Systems
Two rectangular coordinate systems for 3dimensional
representations follow directly from our 2dimensional
coordinate system. These systems differ from one
another by the direction of the added axis, which
identifies the system's handedness as illustrated
in the figure below:
 a lefthanded system  the added axis is directed into the page away from the observer
 a righthanded system  the added axis is directed out of the page towards the observer
The system axes are labelled x, y, and z. They
are perpendicular to one another (mathematicians use the
term orthogonal) and share a common point  the origin. The
triad itself can be oriented in any way. The convention
in 3d game programming is to keep the xy plane parallel to the
screen with the x axis directed horizontally towards the right
and the y axes vertically upwards.
Under this convention, the x and y axes define a plane that is identical in both
systems (as well as in twodimensional representations).
The thumb and forefinger of the hand associated with a system
determine the direction of its z axis. Aligning
the thumb with the positive xaxis and the forefinger with the
positive yaxis, the remaining fingers point in the
direction of the positive zaxis axis.
The handedness of a system is a property of the system.
No combination of rotation, scaling and translation transformations
can convert handedness. Engineering and scientific
applications typically use the righthanded system, which has been
the most written about given its predominance over the last 60
years. The lefthanded system is more convenient for
gaming applications.
The difference between the two systems appears in the symbolic
descriptions of vector transformations. The vectormatrixvector
form of multiplication is compatible with the righthanded system.
The vectorvectormatrix form of multiplication is compatible with the
lefthanded system.
We focus on the lefthanded system in this chapter and use it
throughout all of the remaining samples.
Vectors
A vector in a threedimensional coordinate system is completely
defined by three component values. Each value specifies a
distance along an axis of the system and describes the difference
between the vector's head and tail positions in the positive
direction of that axis:
p^{T} = [p_{x} p_{y} p_{z}]^{T}
^{ } = [h_{x}t_{x} h_{y}t_{y} h_{z}t_{z}]^{T}

The vector's magnitude or length follows from
Pythagoras' theorem:
p = √[(p_{x})^{2} + (p_{y})^{2} + (p_{z})^{2}]

The components of a vector's reverse are the
negative values of the original components:
r^{T} = p^{T} = [p_{x} p_{y} p_{z}]^{T}

Multiplying a vector by a scalar applies the
scalar multiplier to each component:
r^{T} = sp^{T} = [sp_{x} sp_{y} sp_{z}]^{T}

Adding two vectors produces a third vector
with components equal to the sum of the components
of the contributing vectors:
r^{T} = p^{T} + q^{T}
^{ } = [p_{x} p_{y} p_{z}]^{T} + [q_{x} q_{y} q_{z}]^{T}
^{ } = [p_{x}+q_{x} p_{y}+q_{y} p_{z}+q_{z}]^{T}

If, in an addition, the tail of the added vector coincides with the head of the reference,
vector, the result is a vector from the tail of the reference to the head of the added vector:
r^{T} = p^{T} + q^{T}
^{ } = [h_{px}t_{px} h_{py}t_{py} h_{pz}t_{pz}]^{T} + [h_{qx}h_{px} h_{qy}h_{py} h_{qz}h_{pz}]^{T}
^{ } = [h_{px}t_{px}+h_{qx}h_{px} h_{py}t_{py}+h_{qy}h_{py} h_{pz}t_{pz}+h_{qz}h_{pz}]^{T}
^{ } = [h_{qx}t_{px} h_{qy}t_{py} h_{qz}t_{pz}]^{T}

Subtracting one vector from another vector produces
a third vector with components equal to the difference
of the components of the two vectors:
r^{T} = p^{T}  q^{T}
^{ } = [p_{x} p_{y} p_{z}]^{T}  [q_{x} q_{y} q_{z}]^{T}
^{ } = [p_{x}q_{x} p_{y}q_{y} p_{z}q_{z}]^{T}

If, in a subtraction, the tails of the two vectors coincide, the result
is a vector from the head of the subtracted vector to the head of the
reference vector:
r^{T} = p^{T}  q^{T}
^{ } = [h_{px}t_{px} h_{py}t_{py} h_{pz}t_{pz}]^{T}  [h_{qx}t_{px} h_{qy}t_{py} h_{qz}t_{pz}]^{T}
^{ } = [h_{px}t_{px}(h_{qx}t_{px}) h_{py}t_{py}(h_{qy}t_{py}) h_{pz}t_{pz}(h_{qz}_{pz})]^{T}
^{ } = [h_{px}h_{qx}) h_{py}h_{qy} h_{pz}h_{qz}]^{T}

The scalar or dot product of the two vectors is given by
s = p∙q
= p^{T}q
_{ } q_{x}
= [p_{x} p_{y} p_{z}] q_{y}
_{ } q_{z}
= p_{x}q_{x} + p_{y}q_{y} + p_{z}q_{z}

The product of a row vector and a column vector is
the sum of the products of a column coefficient of
the row vector with the corresponding row coefficient
of the column vector:
[a b c]  d  = ad + be + cf
 e 
 f 

The dot product of a vector with itself is the square
of its magnitude:
s = p∙p
= p^{T}p
_{ }  p_{x} 
= [p_{x} p_{y} p_{z}]  p_{y} 
_{ }  p_{z} 
= (p_{x})^{2} + (p_{y})^{2} + (p_{z})^{2}
= p^{2}

The norm of the vector is a vector of unit magnitude with the same direction:
n = p / p
= p / (p ∙ p)^{1/2}

The vector or cross product of two 3dimensional vectors is given by:
r^{T} = p^{T} × q^{T}
^{ } = [p_{y}q_{z}  p_{z}q_{y} p_{z}q_{x}  p_{x}q_{z} p_{x}q_{y}  p_{y}q_{x}]^{T}

The direction of the cross product in a lefthanded
system is given by the lefthand rule. If the
thumb on the left hand points in the direction of the
left operand and the forefinger points in the direction
of the right operand, then the direction of the cross
product is the direction of the remaining fingers.
(For a righthanded system, we use the right hand for
the righthand rule.)
Basic Transformations
For compatibility across transformations 
rotations, scalings, and translations  matrices
in threedimensional space are 4 x 4 matrices.
We expand our component description of a vector to
include a fourth unit value:
p^{T} = [p_{x} p_{y} p_{z} 1]^{T}

A matrix describing any transformation in threedimensional
space has the general form:
 m_{11} m_{12} m_{13} m_{14} 
 m_{21} m_{22} m_{23} m_{24} 
 m_{31} m_{32} m_{33} m_{34} 
 m_{41} m_{42} m_{43} m_{44} 

The first index refers to the row number and the second
index to the column number.
To preserve the unit component of the expanded vector
in any vectorvectormatrix multiplication, the elements of the fourth
column are
 m_{11} m_{12} m_{13} 0 
 m_{21} m_{22} m_{23} 0 
 m_{31} m_{32} m_{33} 0 
 m_{41} m_{42} m_{43} 1 

Rotations
The direction of positive rotation depends upon the handedness
of the adopted system. The lefthand rule identifies the
positive direction of rotation for lefthanded systems.
Grasping the positive side of the axis of rotation with the
thumb directed away from the origin, the direction from the
palm towards the fingertips is the positive angular direction.
Rotation about the z axis
The transpose of the matrix for rotation about the z axis (R^{T}) takes the form:
 cos θ sin θ 0 0 
 sin θ cos θ 0 0 
 0 0 1 0 
 0 0 0 1 

θ is positivevalued measured counterclockwise about
the z axis when facing in the positive direction of that axis.
Rotation about the x axis
The transpose of the matrix for rotation about the x axis (R^{T}) takes the form:
 1 0 0 0 
 0 cos θ sin θ 0 
 0 sin θ cos θ 0 
 0 0 0 1 

θ is positivevalued counterclockwise about the x axis when facing
in the positive direction of that axis.
Rotation about y axis
The transpose of the matrix for rotation about the y axis (R^{T}) takes the form:
 cos θ 0 sin θ 0 
 0 1 0 0 
 sin θ 0 cos θ 0 
 0 0 0 1 

θ is positivevalued counterclockwise about the y axis when facing
in the positive direction of that axis.
Scaling
The transformation matrix for threedimensional scaling takes the form:
 m_{11} 0_{ } 0_{ } 0 
 0_{ } m_{22} 0_{ } 0 
 0_{ } 0_{ } m_{33} 0 
 0_{ } 0_{ } 0_{ } 1 

Translation
The transpose of the translation matrix (T^{T}) takes the form:
 1 0 0 0 
 0 1 0 0 
 0 0 1 0 
 ∆x ∆y ∆z 1 

where ∆x, ∆y, and ∆z denote
translations in positive directions along the x, y, and z axes respectively.
Math Library
The framework has its own library to support vectors, matrices, and
operations on them. The MathDecl.h
header file defines Vector
and Matrix structures.
The MathDef.h
header file defines the member operators, helper functions and helper operators.
All of the definitions are inline.
Vector
struct Vector {
float x;
float y;
float z;
Vector() : x(0), y(0), z(0) {}
Vector(float xx, float yy, float zz) : x(xx), y(yy), z(zz) {}
Vector operator+();
Vector operator();
Vector& operator+=(const Vector& a);
Vector& operator=(const Vector& a);
Vector operator*(const Matrix& m);
Vector operator*(const Matrix& m) const;
Vector operator*=(const Matrix& m);
float length() const;
};

Note that the library omits the fourth, unitvalue component. It does nevertheless
accounts for it in the matrix multiplications.
Matrix
struct Matrix {
float m11, m12, m13, m14;
float m21, m22, m23, m24;
float m31, m32, m33, m34;
float m41, m42, m43, m44;
Matrix() : m11(0), m12(0), m13(0), m14(0),
m21(0), m22(0), m23(0), m24(0),
m31(0), m32(0), m33(0), m34(0),
m41(0), m42(0), m43(0), m44(0) {}
Matrix(float x) : m11(x), m12(0), m13(0), m14(0),
m21(0), m22(x), m23(0), m24(0),
m31(0), m32(0), m33(x), m34(0),
m41(0), m42(0), m43(0), m44(1) {}
Matrix(const Vector& v) : m11(v.x), m12(0), m13(0), m14(0),
m21(0), m22(v.y), m23(0), m24(0),
m31(0), m32(0), m33(v.z), m34(0),
m41(0), m42(0), m43(0), m44(1) {}
Matrix(float i11, float i12, float i13, float i14,
float i21, float i22, float i23, float i24,
float i31, float i32, float i33, float i34,
float i41, float i42, float i43, float i44) :
m11(i11), m12(i12), m13(i13), m14(i14),
m21(i21), m22(i22), m23(i23), m24(i24),
m31(i31), m32(i32), m33(i33), m34(i34),
m41(i41), m42(i42), m43(i43), m44(i44) {}
Matrix& isIdentity();
Matrix& operator+=(const Matrix& a);
Matrix& operator=(const Matrix& a);
Matrix& operator*=(const Matrix& m);
Matrix transpose() const;
Matrix& translate(float x, float y, float z);
Matrix& rotatex(float rad);
Matrix& rotatey(float rad);
Matrix& rotatez(float rad);
Matrix& rotate(const Matrix& rot);
Matrix& scale(float sx, float sy, float sz);
Matrix& orient(const Matrix& rot);
Vector position() const;
Matrix rotation() const;
Vector direction(const Vector& v) const;
Vector direction(char c) const;
Matrix& operator*=(const Matrix& m);
Matrix transpose() const;
};

Vector Matrix Multiplication
The vectormatrix multiplication uses vectorvectormatrix
form for compatibility with a lefthanded coordinate system.
A Vector reads as
a row vector and a Matrix reads as
the transpose of the matrix written to the engineering and
scientific convention. For example, for the
following transformation of a vector by a matrix:
we would write
Vector p, q;
Matrix R;
q = p * R; // transpose symbols omitted

For brevity, the code throughout the framework omits the transpose symbols.
Rotation
The rotation of an object is typically a rotation about the
origin of its local frame of reference and not about the origin
of the world frame of reference. If the origin of the object's local frame of reference
does not coincide with the origin of the world frame of reference,
a rotation about the local frame of reference will differ from the
same rotation about world space.
To achieve a rotation about the origin of the local
frame of reference, the library functions perform a threepart
operation.
 translate the object to the origin of the world frame of
reference.
 rotate the object about the origin of the world/local frame.
 translate the object back to its position prior to the rotation.
This is simply done by extracting the coordinates of the fourth row of the object's world
matrix, rotating, and inserting them into the result.
For example, the rotatez() method on
a Matrix object applies a
rotation about the z axis of rad radians to the
current matrix and returns a reference to the
rotated matrix:
inline Matrix& Matrix::rotatez(float rad) {
float c = cosf(rad);
float s = sinf(rad);
Matrix rot(c, s, 0, 0,
s, c, 0, 0,
0, 0, 1, 0,
0, 0, 0, 1);
rotate(rot);
return *this;
}

inline Matrix& Matrix::rotate(const Matrix &rot) {
float x = m41, y = m42, z = m43;
m41 = m42 = m43 = 0; // translate to world origin
*this *= rot;
m41 = x; // translate back to original position
m42 = y;
m43 = z;
return *this;
}

Scaling
The scaling of an object is typically a scaling about the
origin of its local frame of reference and not about the
origin of the world frame of reference.
To achieve a pure scaling about the origin of the local
frame of reference, the library performs a threepart operation.
 translate the object to the origin of the world frame of
reference.
 scale the object about the origin of the world/local frame.
 translate the object back to its position prior to the scaling.
As with rotations, this is done by extracting the coordinates of the fourth row of the object's world
matrix, scaling, and inserting them into the result.
Frame
The framework uses the Frame
class to store the transformation matrix for any design
element. Classes for all design elements that
have positional or orientational properties derive from
this base class.
A Frame object holds
the matrix for transforming from the design element's
local frame of reference to its parent's frame of reference.
The parent frame of reference can be the child frame of
another parent. If no parent frame of reference is specified,
the frame of reference is world space.
The Frame class exposes thirteen virtual
methods:
 translate()  translates the Frame object
 scale()  scales the Frame object
 rotatex()  rotates the Frame object about an axis parallel to the x world axis
 rotatey()  rotates the Frame object about an axis parallel to the y world axis
 rotatez()  rotates the Frame object about an axis parallel to the z world axis
 rotate()  rotates the Frame object about a Vector
 position()  returns the world position of the Frame object
 rotation()  returns the world orientation of the Frame object
 orientation()  returns a Vector with the direction of a local axis of the Frame object
 world()  returns the world transformation for the Frame object
 attachTo()  attaches the current object to the parent pointed to by Frame*
The Frame class holds the address
of the parent object, if any, and the transformation matrix with respect
to the parent frame of reference (or world space):
// Frame.h
class Frame {
Matrix T; // transformation to parent frame
Frame* parent; // points to the parent frame, if any
public:
Frame();
virtual void scale(float sx, float sy, float sz) { T.scale(sx, sy, sz); }
virtual void rotatex(float rad) { T.rotatex(rad); }
virtual void rotatey(float rad) { T.rotatey(rad); }
virtual void rotatez(float rad) { T.rotatez(rad); }
virtual void rotate(const Vector& axis, float rad) { T.rotate(axis, rad); }
virtual void translate(float x, float y, float z) { T.translate(x, y, z); }
virtual void orient(const Matrix& rot) { T.orient(rot); }
virtual Vector position() const;
virtual Matrix rotation() const;
virtual Vector orientation(const Vector& v) const;
virtual Vector orientation(char c) const;
virtual Matrix world() const;
virtual void attachTo(Frame* newParent);
virtual ~Frame() {}
};

The inline methods call the equivalent methods on the
Matrix object.
Implementation
Construct
The Frame constructor initializes the
transformation matrix to the identity matrix with no parent:
Frame::Frame() : T(1), parent(0) {}

orientation
The orientation()
method takes a char returns the
normalized free vector that describes the direction of the
specified local axis:
Vector Frame::orientation(char axis) const {
Vector v;
switch(axis) {
case 'x': v = Vector(1, 0, 0); break;
case 'y': v = Vector(0, 1, 0); break;
case 'z': v = Vector(0, 0, 1); break;
}
return orientation(v);
}

The orientation()
method that takes a Vector reference
returns the coordinates of that Vector
in world space:
Vector Frame::orientation(const Vector& v) const {
return v * rotation();
}

position
The position() method returns
the position of the local frame of reference in world space:
Vector Frame::position() const {
return parent ? ::position(T) * parent>rotation() + parent>position() :
::position(T);
}

rotation
The rotation() method returns
the orientation of the local frame of reference in world space:
Matrix Frame::rotation() const {
return parent ? ::rotation(T) * parent>rotation() : ::rotation(T);
}

world
The world() method returns the
world transformation matrix:
Matrix Frame::world() const {
return parent ? T * parent>world() : T;
}

attachTo
The attachTo() method returns a
Matrix that holds the
world transformation matrix:
void Frame::attachTo(Frame* newParent) {
if (parent) T = world(); // detach from current parent, if any
parent = newParent; // attach to newParent
if (parent) {
Matrix m = parent>rotation(); // extract orientation
m = m.transpose();
T.rotate(m); // invert orientation
// express offset in local coordinates wrt to parent frame
Vector p = (::position(T)  parent>position()) * m;
T.m41 = p.x;
T.m42 = p.y;
T.m43 = p.z;
}
}

Note that the inverse of a rotation matrix is the same as
its transpose.
General Transformations
The position and orientation of each design element with respect to the screen
coordinates depends upon the element's position and orientation in world space,
the viewer's position and orientation, the perspective on the scene, and the
the reference frame of the screen. The game design itself describes the
position and orientation for each design element in world space. Four
transformations are involved in determining the position in screen space of
any point on a design element:
 world transformation  transforms local coordinates to world coordinates
 view transformation  transfroms world coordinates to camera space coordinates
 projection transformation  transfroms camera coordinates to clip space coordinates
 viewport transformation  transfroms clip space coordinates to screen coordinates
World Transformation
The graphic repesentation of a design element consists of points
identified by vectors bound to its centroid. The origin of
the local coordinate system is at the element's centroid.
We describe each point on the element in terms of the bound vector
to that point in the local coordinate system.
We assume that the element is rigid, so that its bound
vectors do not change throughout the element's lifetime.
Each design element has its own homogeneous matrix.
This matrix describes the element's position, orientation, and scaling with respect
to its parent; in the absence of any parent, with respect to world space.
To calculate the world position of a point on the element,
we multiply the bound vector with the element's world transformation matrix.
The graphics hardware performs this transformation.
As a design element translates or rotates, its world
matrix changes. Its current world matrix is a
concatenation of successive rotation, scaling, and
translation matrices (along with those of its parents):
W^{T}_{i+1} = W^{T}_{i} Q^{T}_{i}

where Q_{i} is the current
transformation (rotation, scaling, translation) matrix and
i is an index that identifies
the transformation in the sequence of successive world
transformations (i = 0, ..., i) from the original
position and orientation.
Camera Transformations
The view transformation defines the position and orientation of the
viewpoint in world space. An identity transformation describes
a viewpoint at the origin of world space with its local axis aligned
with the world axes, and the look at point along the positive world
z axis. We use three vectors to identify the current viewpoint
and its orientation in world space:
 position
 look at direction
 up direction
We convert these three vectors into the homogeneous view matrix
(V). The graphics hardware uses this
matrix to transform the world coordinates of each point on each
graphic representation into a cameraspace coordinates.
Given the position (p), the look at point
(d) and the up (u)
direction in world space, three normal vectors to determine the
view matrix:
z = (d  p) / (d  p) // lefthanded system
x = u × z / u × z
y = z × x

The transpose of the view matrix is
 x_{x} y_{x} z_{x} 0 
 x_{y} y_{y} z_{y} 0 
 x_{z} y_{z} z_{z} 0 
 _{ }r∙p _{ }y∙p _{ }z∙p 1 

The source code for this transpose is:
inline Matrix view(const Vector& p, const Vector& d, const Vector& u) {
Vector z = normal(d  p);
Vector x = normal(cross(u, z));
Vector y = cross(z, x);
return Matrix( x.x, y.x, z.x, 0,
x.y, y.y, z.y, 0,
x.z, y.z, z.z, 0,
dot(x, p), dot(y, p), dot(z, p), 1);
}

Projection Transformation
The projection transformation introduces perspective and scaling on
the different objects in a scene. Without perspective
objects that are further away appear larger than they should.
The projection transformation makes objects that are further away
appear smaller than they are and reduces objects that are sufficiently
far away to single points or invisible ones. The projection
transformation excludes objects that are too close or outside
the viewing angle. The result of a projection transformation
(P) is a conversion from a camera space view
to clip space view. Clip space is a right cuboid with its near
face centered on the origin and its far face centered on [0,0,1] and
the faces normal to the z axis square of side length 2 as shown below.
The projection matrix transforms any point in camera space
to a point in clip space. The transformation involves
a scaling and a perspective projection. We call the prism
that contains the points that map into the right cuboid
the frustum. Points outside this frustum are outside clip
space and will not appear on the screen. We define the persective in terms
of a field of view angle at the camera. This angle defines
the inclination of the frustum's sides.
Four values completely define the projection matrix:
 the z coordinate in camera space of the nearclipping plane  the cutoff
plane for points too close to the viewpoint
 the z coordinate in camera space of the farclipping plane  the cutoff
plane for points too far from the viewpoint
 the field of view angle
 the aspect ratio of the display
The source code for the transpose of the projection matrix is
inline Matrix projection(float fov, float aspect, float near_cp,
float far_cp) {
float sy = 1.0f / tanf(fov * 0.5f);
float sx = sy / aspect;
float sz = far_cp / (far_cpnear_cp);
return Matrix(sx, 0, 0, 0,
0, sy, 0, 0,
0, 0, sz, 1,
0, 0, near_cp * sz, 0);
}

Viewport Transformation
The viewport transformation converts clip space coordinates into screen
coordinates.
Screen coordinates are defined in two dimensions with the origin in
the top left corner and the x and y axis to the right and down respectively.
Six factors completely determine the coefficients of
this matrix (Y):
 w  width of the screen in pixels
 h  height of the screen in pixels
 x  pixel x coordinate of the top left corner (0)
 y  pixel y coordinate of the top left corner (0)
 minz  minimum of the range of depth values (0.0)
 maxz  maximum of the range of depth values (1.0)
The transpose of the viewport matrix is
 w/2 0 0 0 
 0 h/2 0 0 
 0 0 maxz  minz 0 
 x + w/2 y + h/2 minz 1 

The graphics hardware converts clip space coordinates to screen coordinates
using this transformation.
Composite Transformation
The composite transformation matrix for each point on each
object is the product of the world, view, projection, and
viewport matrices:
(X_{composite})^{T} = W^{T} V^{T} P^{T} Y^{T}

This matrix converts vectors that define points on drawable objects
in local coordinate system into points on screen space.
Direct3D Utilities
The Direct3D utility library provides declarations
and definitions for vectors and matrices, including the
view and projection matrices for DirectX applications.
The Direct3D syntax cannot be used with the OpenGL API.
The Direct3D identifiers are also uppercase, which makes coding
all the more difficult to read. The declarations
and definitions are part of the D3DX utility library.
The D3DX library functions operate on
D3DX structures. The structure types are:
 D3DXVECTOR3  3 component vector (.x, .y, .z)
 D3DXMATRIX  4 x 4 homogeneous matrix (._11, ._12, ._13, ._14, ._21, ... )
The D3DX functions corresponding to the operations
implemented in the framework's math library are listed below.
Operation

MathDefinitions.h Function

D3DX Function

Vector Operators and Functions 
reverse

Vector Vector::operator() const

D3DXVECTOR3 D3DXVECTOR3::operator() const

add

Vector& Vector::operator+=(const Vector&)

D3DXVECTOR3& D3DXVECTOR3::operator+=(const D3DXVECTOR3&)

subtract

Vector& Vector::operator=(const Vector&)

D3DXVECTOR3& D3DXVECTOR3::operator=(const D3DXVECTOR3&)

magnitude

float Vector::length() const

float D3DXVec3Length(const D3DXVECTOR3*)

add

Vector operator+(const Vector&, const Vector&)

D3DXVECTOR3 D3DXVECTOR3::operator+(const D3DXVECTOR3&) const

subtract

Vector operator(const Vector&, const Vector&)

D3DXVECTOR3 D3DXVECTOR3::operator(const D3DXVECTOR3&) const

multiply

Vector operator*(float, const Vector&)

D3DXVECTOR3 D3DXVECTOR3::operator*(float) const

divide

Vector operator/(const Vector&, float)

D3DXVECTOR3 D3DXVECTOR3::operator/(float) const

scalar product

float dot(const Vector&, const Vector&)

float D3DXVec3Dot(const D3DXVECTOR3*, const D3DXVECTOR3*)

normal

Vector normal(const Vector&)

D3DXVECTOR3* D3DXVec3Normalize(D3DXVECTOR3*, const D3DXVECTOR3*)

vector product

Vector cross(const Vector&, const Vector&)

D3DXVECTOR3* D3DXVec3Cross(D3DXVECTOR3*, const D3DXVECTOR3*, const D3DXVECTOR3*)

Matrix Operators and Functions 
transform

Vector& Vector::operator*=(const Matrix&)

D3DXVECTOR3* D3DXVec3TransformCoord(D3DXVECTOR3*, const D3DXVECTOR3*, const D3DXMATRIX*)

initialize

Matrix& Matrix::isIdentity()

D3DXMATRIX* D3DXMatrixIdentity(D3DXMATRIX*)

multiply

Matrix& Matrix::operator*=(const Matrix&)

D3DXMATRIX* D3DXMATRIX::operator*=(const D3DXMATRIX&)

transpose

Matrix Matrix::transpose()

D3DXMATRIX* D3DXMatrixTranspose(D3DXMATRIX*, const D3DXMATRIX*)

multiply

Vector operator*(const Vector&, const Matrix&)

D3DXVECTOR3* D3DXVec3TransformCoord(D3DXVECTOR3*, const D3DXVECTOR3*, const D3DXMATRIX*)

translate

Matrix Matrix::translate(float, float, float)

D3DXMATRIX* D3DXMatrixTranslation(D3DXMATRIX*, float, float, float)

rotate about x axis

Matrix Matrix::rotatex(float)

D3DXMATRIX* D3DXMatrixRotationX(D3DXMATRIX*, float)

rotate about y axis

Matrix Matrix::rotatey(float)

D3DXMATRIX* D3DXMatrixRotationY(D3DXMATRIX*, float)

rotate about z axis

Matrix Matrix::rotatez(float)

D3DXMATRIX* D3DXMatrixRotationZ(D3DXMATRIX*, float)

scale

Matrix Matrix::scale(float, float, float)

D3DXMATRIX* D3DXMatrixScaling(D3DXMATRIX*, float, float, float)

The D3DXMatrixLookAtLH() function returns
the transpose of the view matrix for a lefthanded system:
D3DXMATRIX view;
D3DXVECTOR3 at = viewpt + direction;
D3DXVECTOR3 up = D3DXVECTOR3(0, 1, 0);
D3DXMatrixLookAtLH(&view, &viewpt, &at, &up);

The D3DXMatrixPerspectiveFovLH()
function returns the transpose of the projection matrix for
a lefthanded system:
D3DXMATRIX projection;
D3DXMatrixPerspectiveFovLH(&projection, FIELD_OF_VIEW,
width/float(height), NEAR_CLIPPING, FAR_CLIPPING);

Exercises
 Read the DirectX Documentation on Transforms
 Read the Wikipedia article on
Transformations
