Microsoft DirectX 9.0 SDK Update (October 2004)

Rotation

Language:

Note: This documentation is preliminary and is subject to change.

The transformations described here are for left-handed coordinate systems, and so might be different from transformation matrices that you have seen elsewhere. For more information, see 3-D Coordinate Systems.

The following transformation rotates the point (x, y, z) around the x-axis, producing a new point (x', y', z').

Matrix X Rotation

The following transformation rotates the point around the y-axis.

Matrix Y Rotation

The following transformation rotates the point around the z-axis.

Matrix Z Rotation

In these example matrices, the Greek letter theta (?) stands for the angle of rotation, in radians. Angles are measured clockwise when looking along the rotation axis toward the origin.

In a managed application, use the Matrix.RotationX, Matrix.RotationY, and Matrix.RotationZ methods to create rotation matrices. The following C# code example demonstrates how the Matrix.RotationX method performs a rotation.

          [C#]
          
private Matrix MatrixRotationX(float angle) { double sin, cos; sin = Math.Sin(angle); cos = Math.Cos(angle); Matrix ret; ret.M11 = 1.0f; ret.M12 = 0.0f; ret.M13 = 0.0f; ret.M14 = 0.0f; ret.M21 = 0.0f; ret.M22 = (float)cos; ret.M23 = (float)sin; ret.M24 = 0.0f; ret.M31 = 0.0f; ret.M32 = (float)-sin; ret.M33 = (float)cos; ret.M34 = 0.0f; ret.M41 = 0.0f; ret.M42 = 0.0f; ret.M43 = 0.0f; ret.M44 = 1.0f; return ret; }

© 2004 Microsoft Corporation. All rights reserved. Terms of use.

Feedback? Please provide us with your comments on this topic.
For more help, visit the DirectX Developer Center