Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

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.

share|improve this question
1  
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. –  John Calsbeek May 6 '12 at 18:17
    
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. –  gardian06 May 6 '12 at 18:32
    
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. –  John Calsbeek May 6 '12 at 18:37

1 Answer 1

up vote 2 down vote accepted

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.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.