?/TD>
Microsoft DirectX 9.0

Translation and Scaling


Translation

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

Translation matrix

You can create a translation matrix by hand in C++. The following example shows the source code for a function that creates a matrix to translate vertices.

D3DXMATRIX Translate(const float dx, const float dy, const float dz) {
    D3DXMATRIX ret;

    D3DXMatrixIdentity(&ret);  // Implemented by Direct3D extensions (D3DX)
    ret(3, 0) = dx;
    ret(3, 1) = dy;
    ret(3, 2) = dz;
    return ret;
}    // End of Translate

For convenience, the Direct3D extensions (D3DX) utility library supplies the D3DXMatrixTranslation function.

Scaling

The following transformation scales the point (x, y, z) by arbitrary values in the x-, y-, and z-directions to a new point (x', y', z').

Scale matrix



© 2002 Microsoft Corporation. All rights reserved.