# Matrix Transformation... Need Help !

This topic is 5189 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

Hi guys... I am facing a little problem, quite complex for me, not for others I hope... I am converting an Old G Engine using Non-Left-Handed Coordinates to DXs.. Basically, dnt ask me what Coords handling this system uses, Seems Y and Z are reversed btw them, both in poosition and direction... When transforming object to a new DX compatible DB I just exchange Z and Y items in vectors the following way : Y=-Z , Z=-Y This works good, I see the models at right positions... The problem asises when I encounter some parts of the Models... These parts are built in the model at the coords origin ( dnt ask me why ), still not fitted at right place, then the Engine should Rotate & Transpose them to the right position... but now, the Rotation and Transposition Matrices settled up for each part of the model are no more working in the new Coord System... For Transposition, well, no problem, just Z=-Y and Y=-Z method, but what about rotation Matrix...? Can Anyone tell me how could I fit the Matrices to the new system... this is not a simple rotation on axis I suppose... so have to work directly on the Rotation Matrix... can Any1 Help plz...? tnx [R]ed

##### Share on other sites
You could decompose the transform matrix in general into its transitional, rotational and scaling subparts. You would for example obtain a 3D vector for translation, a quaternion for rotation and a 3D vector for scaling. These can then be converted individually and a new transformation matrix can be constructed from them, which is valid in the new system.

Greetz,

Illco

##### Share on other sites
Tnx Illco...
I already have them as separated items...
Only I dunno how to transform to the new system the rotation matrix ( it's an original 3x3 Matrix but easy to make it as D3DX Matrix)...
I have tried with axis rotations with no success... I can't swap Z & Y both in sign and position leaving unaltered X... so... it's a matter to chage the Matrix another way...
and I am not figuring out how....

[R]ed

##### Share on other sites
If you have them as separate items and you transform a position vector P = (Px,Py,Pz) to the new coordinate system as P' according to:
P' = (Px,-Pz,-Py)

Then you can transform a quaternion R = (Rx, Ry, Rz, Rw) by
R' = (Rx,-Ry,-Rz,Rw)

The scaling goes exactly like the first vector but without the negative values. I don't see what the problem is after this. If you are using D3DX you can simply build three matrices (translation, rotation, scaling) and multiply them together to find the new transform matrix.

Illco

##### Share on other sites
Tnx Again... but may be I was not so clear...
The rotation Matrix is already the product of rotations on all the X, Y, Z axis, and I only got it...
Is there a way to decompose it...? and getting back the original Rotation Vector / Matrix / Angle on Axis?

I'll be very glad if u could tell me...

tnx

[R]ed

##### Share on other sites
Quote:
 I already have them as separated items...

I thought you meant here you already had the separate translation, rotation and scale items.

Quote:
 The rotation Matrix is already the product of rotations on all the X, Y, Z axis, and I only got it...

But from this I get you only have the transformation resulting from some translation, rotation and scaling.

Yes you can decompose it. Have a look here, it comes with code.

Good luck! Illco.

##### Share on other sites
Yep...
I have separated Translation, Scale, Rotation...

but Rotation is already the product of at least 2 rotation ( if not 3 ) Matrices on their X, Y, Z axis...
that I meant... if I could decompose the rotation ( or find how to 'translate' it to the other axis ) everything could be fine...

however... going to take a look...

[R]ed

##### Share on other sites
I think I see now and by doing so recall from memory your original post mentioning this. You probably have:
a) a translation vector
b) a scaling vector
c) a rotation matrix (3x3)

I'd suggest disregarding all and taking the 4x4 transform matrix and then apply an ordinay decomposition method. The rotation will preferrably be represented by a quaternion, which you can convert as said above. This is regardless of how the rotation was achieved, because quaternions are not axis-angle. What I mean is it does not matter whether the original rotation was achieve by doing such-and-such around this-and-that axis; the resultant rotation is just represented at once by the quaternion. Converting it and building a new transform matrix will preserve the rotation.

##### Share on other sites
yep... tnx Illco...
already tried this... transformed a 3x3 Matrix in a Quaternion...
then read the axis angles in it to transform...
but seemed not consistent...
however... tnx again for interest...
I'll check better later or tomorrow...
howevere...I am wondering if there is a trigonometric way to work directly on matrix components... to transform it directly...
the old Coord System dnt let me use any rotation, as finally it needs to rotate the X axis too, and it's already good...

bye

[R]ed

• ### Game Developer Survey

We are looking for qualified game developers to participate in a 10-minute online survey. Qualified participants will be offered a \$15 incentive for your time and insights. Click here to start!

• 11
• 23
• 36
• 16
• 75