Game Development Reference
In-Depth Information
or points. Due to this, it is very important that the vectors are named in a sensible
manner, such as this:
Click here to view code image
Vector4 playerPosition // This is a point
Vector4 playerFacing // This is a vector
Transforming 4D Vectors by Matrices
The matrices we use to transform objects will often be 4×4 matrices. But in order
tomultiplyavectorbya4×4matrix,thevectorhastobe4D,aswell.Thisiswhere
homogenous coordinates come into play.
Multiplying a 4D vector by a 4×4 matrix is very similar to multiplying a 3D vector
by a 3×3 matrix:
Once you understand how to transform a 4D homogenous coordinate by a matrix,
you can then construct matrices in order to perform the specific transformations
you want in world space.
Transform Matrices
A transform matrix is a matrix that is able to modify a vector or point in a spe-
cific way. Transform matrices are what allow us to have model space coordinates
transformed into world space coordinates.
As a reminder, all of these transform matrices are presented in row-major repres-
entations. If you are using a library that expects a column-major representation
(such as OpenGL), you will need to transpose these matrices. Although the
matrices that follow are presented in their 4×4 forms, the scale and rotation
matrices can have their fourth row/column removed if a 3×3 matrix is desired in-
stead.
Search WWH ::




Custom Search