tags:

views:

1205

answers:

3

I would like to change a 4x4 matrix from a right handed system where:
x is left and right, y is front and back and z is up and down

to a left-handed system where:
x is left and right, z is front and back and y is up and down.

For a vector it's easy, just swap the y and z values, but how do you do it for a matrix?

A: 

Since this seems like a homework answer; i'll give you a start at a hint: What can you do to make the determinant of the matrix negative?

Further (better hint): Since you already know how to do that transformation with individual vectors, don't you think you'd be able to do it with the basis vectors that span the transformation the matrix represents? (Remember that a matrix can be viewed as a linear transormation performed on a tuple of unit vectors)

Thanks but actually it isn't homework and I don't really know any of the math behind matrices so I don't actually understand any of that.
cmann
Okay, to be more pragmatic and less mathematical, start with the fact you can treat the rotation and translation seperately..
(i'm assuming an affine transformation)
A: 

It depends if you transform your points by multiplying the matrix from the left or from the right.

If you multiply from the left (e.g: Ax = x', where A is a matrix and x' the transformed point), you just need to swap the second and third column. If you multiply from the right (e.g: xA = x'), you need to swap the second and third row.

If your points are column vectors then you're in the first scenario.

A: 

Let me try to explain it a little better. I need to export from Blender, in which the z axis is facing, to OpenGL where the y axis is facing up.

For every coordinate (x, y, z) it's simple, swap the y and z values: (x, z, y).
Because I have swapped the all of the y and z values any matrix that I use also needs to be flipped so that it has the same affect .

After a lot of searching I've eventually found a solution here:
http://www.gamedev.net/community/forums/topic.asp?topic_id=537664
If your matrix looks like this:
{ rx, ry, rz, 0 }
{ ux, uy, uz, 0 }
{ lx, ly, lz, 0 }
{ px, py, pz, 1 }

To change it from left to right or right to left, flip it like this:
{ rx, rz, ry, 0 }
{ lx, lz, ly, 0 }
{ ux, uz, uy, 0 }
{ px, pz, py, 1 }

cmann