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.

In XNA there is only one Matrix class which is actually 4x4 matrix. How to use it to represent a 3x3 matrix?

I am trying to represent the inertia tensor of a body which is a 3x3 matrix, so I have data for only a 3x3 matrix. How can I store that in a 4x4 matrix and still have operations on it be valid?

share|improve this question
    
Why not quickly roll your own Matrix3 class? This sounds like data that has nothing to do with XNA and therefore it makes little sense to use XNA classes for it. –  Patrick Hughes Jan 28 '12 at 0:59
    
i want to be able to transform a Matrix3 by a Matrix4 (this is very important to me) –  MhdSyrwan Jan 28 '12 at 1:03
    
I see, Nicol's answer is what you need in that case. –  Patrick Hughes Jan 28 '12 at 1:10
add comment

1 Answer

up vote 12 down vote accepted

Put zeros in the last column and row, except for the lower-left value which should be 1. Like this:

V  V  V  0
V  V  V  0
V  V  V  0
0  0  0  1

Where V are the actual values you use.

share|improve this answer
    
XNA operations still valid in this state ? –  MhdSyrwan Jan 28 '12 at 1:01
    
@MhdSyrwan: Unless XNA's matrix math code is completely broken, yes. Matrix math is matrix math; a matrix of all zeros is still a matrix. –  Nicol Bolas Jan 28 '12 at 1:02
    
Really he is asking you to make an identity matrix then copy your matrix 3x3. –  Matt Jensen Jan 28 '12 at 2:53
    
note : XNA Matrix is stored as a row vector matrix (each vector is a row ) so if our Matrix3x3 is column vector , we should transpose it. –  MhdSyrwan Feb 7 '12 at 17:52
add comment

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.