My game entities currently hold a quaternion for their orientation with the ability to return either a 3X3 full rotation matrix (based on that quaternion), or a full 4X4 transform matrix. though what I have come to find is that I am not able to convert from my matricies to DirectX matricies directly, so my next thought would be to force the conversion by hand. which of the following methods would work best/easiest/accurate?

  • take the quaternion, and break it down into the individual axis-aligned rotations
  • take either the full rotation matrix, or the full transform matrix and break it down

for either approach it would need to yield the component rotations (theta about X, phi about Y, rho about Z).

I have a feeling that breaking the quaternion down might be the easier rout, but I am not sure as to the actual operations to do this break down.

  • 1
    \$\begingroup\$ Can you elaborate on "I am not able to convert my matrices to DirectX matrices directly"? I'm fairly skeptical of that. Quaternion-to-matrix is definitely the "right" way to do what I think you're trying to do. \$\endgroup\$ May 6, 2012 at 18:17
  • \$\begingroup\$ I store my matricies for my GameObjects as linear arrays of floats gamedev.stackexchange.com/questions/28625/…, and I currently have no direct conversion from this to DirextX matrix. \$\endgroup\$
    – gardian06
    May 6, 2012 at 18:32
  • \$\begingroup\$ DirectX matrices are linear arrays of floats, as long as you tack on the final [0 0 0 1] row. The D3DXMATRIX class has a constructor that takes an array of floats, as well. \$\endgroup\$ May 6, 2012 at 18:37

1 Answer 1


which of the following methods would work best/easiest/accurate?

The first step in the most efficient angle/axis->matrix transform is converting the angle/axis matrix into a quaternion. So if you already have a quaternion, there's no point in turning it into angle/axis, only to give it to someone else who's going to turn it back into a quaternion to make it into a matrix.

The D3DXMATRIX class has several constructors, one of which takes an array of floats. If your array and D3D's array order their components the same way, then you can just use that. If not, then you can use it anyway and simply transpose the matrix afterwards.


You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .