Tone

05-15-2001, 08:32 AM

I know this is a basic quaestion, but does anyone know how to convert a right-handed matrix into a left-handed matrix. Thanks in advance.

Tone

Tone

View Full Version : Matrix Math

Tone

05-15-2001, 08:32 AM

I know this is a basic quaestion, but does anyone know how to convert a right-handed matrix into a left-handed matrix. Thanks in advance.

Tone

Tone

Hull

05-15-2001, 10:11 AM

I am no matrix expert, but I think you only have to change the sign of one of the axes:

right,up and forward.

This is simply done by setting one of the top three 1's in the identity matrix to -1.

// Righthanded system

1,0,0,0,

0,1,0,0,

0,0,1,0,

0,0,0,1

// Lefthanded system using left vector instead of right vector

-1,0,0,0,

0,1,0,0,

0,0,1,0,

0,0,0,1

// I dont know if this is general but:

// In a column major matrix (GL matrix):

rx, ux, ax, px,

ry, uy, ay, py,

rz, uz, az, pz,

sx, sy, sz, D

Then

(rx,ry,rz) is the rightvector

(ux,uy,uz) is the upvector

(ax,ay,az) is the 'at' vector (forward)

and

(px,py,pz) is the position (translation)

I don't know for sure, but I think that:

(sx,sy,sz) is the shear of the matrix

I have no clue of what D is, it is usually set to 1.

// For rotations, I do believe you also have to change sign of all the sin components.

(Maybe multiplying a righthand rotationmatrix with a lefthand identity matrix will do this for you, anyone?)

Tell me if I am wrong.

[This message has been edited by Hull (edited 05-15-2001).]

[This message has been edited by Hull (edited 05-15-2001).]

right,up and forward.

This is simply done by setting one of the top three 1's in the identity matrix to -1.

// Righthanded system

1,0,0,0,

0,1,0,0,

0,0,1,0,

0,0,0,1

// Lefthanded system using left vector instead of right vector

-1,0,0,0,

0,1,0,0,

0,0,1,0,

0,0,0,1

// I dont know if this is general but:

// In a column major matrix (GL matrix):

rx, ux, ax, px,

ry, uy, ay, py,

rz, uz, az, pz,

sx, sy, sz, D

Then

(rx,ry,rz) is the rightvector

(ux,uy,uz) is the upvector

(ax,ay,az) is the 'at' vector (forward)

and

(px,py,pz) is the position (translation)

I don't know for sure, but I think that:

(sx,sy,sz) is the shear of the matrix

I have no clue of what D is, it is usually set to 1.

// For rotations, I do believe you also have to change sign of all the sin components.

(Maybe multiplying a righthand rotationmatrix with a lefthand identity matrix will do this for you, anyone?)

Tell me if I am wrong.

[This message has been edited by Hull (edited 05-15-2001).]

[This message has been edited by Hull (edited 05-15-2001).]

jwatte

05-15-2001, 10:22 AM

Either swap the Y and Z lines, or negate one of them (typically the Z).

Tone

05-15-2001, 02:46 PM

So for example, I created a matrix emulating what gluLookAt does. It goes as follows:

rightX upX fwdX posX

rightY upY fwdY posY

rightZ upZ fwdZ posZ

0 0 0 1

Are you saying that the left-handed version would look like this?

rightX fwdX upX posX

rightY fwdY upY posY

rightZ fwdZ upZ posZ

0 0 0 1

[This message has been edited by Tone (edited 05-15-2001).]

rightX upX fwdX posX

rightY upY fwdY posY

rightZ upZ fwdZ posZ

0 0 0 1

Are you saying that the left-handed version would look like this?

rightX fwdX upX posX

rightY fwdY upY posY

rightZ fwdZ upZ posZ

0 0 0 1

[This message has been edited by Tone (edited 05-15-2001).]

Hull

05-15-2001, 03:47 PM

A left-isometry is like a mirroring of the entire 3D space, because one axis of the three axes in 3D space will point in the opposite direction. This is a consequence of changing the way all matrix transformations are made. But that is not all.

In a left-isometric environment, ALL transformations, such as rotations and shearing, are done in opposite direction (I think) because of the mirroring effect.

I don't really know if changing the identity matrix (the one you always start with before doing any transformations on it) by either negating one axis or swapping two of the axes will suffice, or if you have to alter the transformations themselves to suit the new isometry (such as rotations rotating the other way around).

Try it out!

-----------

Note that if you change

the axes like this:

// Swapped at with up.

rx, atx, upx, 0,

rx, atx, upx, 0,

rx, atx, upx, 0,

0, 0, 0, 1,

It would be a left-isometry,

if the previous isometry was

a right one, but the matrix

would still have its right,

forward, up and whatever at

the locations I previously stated.

[This message has been edited by Hull (edited 05-15-2001).]

In a left-isometric environment, ALL transformations, such as rotations and shearing, are done in opposite direction (I think) because of the mirroring effect.

I don't really know if changing the identity matrix (the one you always start with before doing any transformations on it) by either negating one axis or swapping two of the axes will suffice, or if you have to alter the transformations themselves to suit the new isometry (such as rotations rotating the other way around).

Try it out!

-----------

Note that if you change

the axes like this:

// Swapped at with up.

rx, atx, upx, 0,

rx, atx, upx, 0,

rx, atx, upx, 0,

0, 0, 0, 1,

It would be a left-isometry,

if the previous isometry was

a right one, but the matrix

would still have its right,

forward, up and whatever at

the locations I previously stated.

[This message has been edited by Hull (edited 05-15-2001).]

T2k

05-16-2001, 02:20 AM

glScaled(-1.0, 1.0, 1.0); ?!?

Powered by vBulletin® Version 4.2.3 Copyright © 2018 vBulletin Solutions, Inc. All rights reserved.