Translation

The following transformation translates the point (x, y, z) to a new point (x', y', z'):

You can create a translation matrix by hand, or by using the Translate helper function in the D3dutil.cpp file that is included with this documentation. The following example shows the source code for the Translate function:

D3DMATRIX Translate(const float dx, const float dy, const float dz)
{
    D3DMATRIX ret = IdentityMatrix();
    ret(3, 0) = dx;
    ret(3, 1) = dy;
    ret(3, 2) = dz;
    return ret;
}    // end of Translate()