Sign in to follow this  

Matrix help

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

If you intended to correct an error in the post then please contact us.

Recommended Posts

I'm having matrix issues that I hope someone can help me out with... I have a 3x3 rotation matrix, I must reverse the z-axis rotation ONLY, keeping x- and y- intact. I have noticed that a z-axis rotation effects the x- and y- axes, and a x-axis rotation effects the z- and y- axes, thus when I tried reversing the z-axis rotation by simply transposing the first 2x2 section I am effecting the x-axis rotation too. Hope this makes sense... eg. M = [ a b c ] [ d e f ] [ g h i ] I did this... M' = [ a d c ] [ b e f ] [ g h i ] But I am convinced this isn't correct. Thanks for any help.

Share this post


Link to post
Share on other sites
I think we could help better if you told us what you REALLY want to do. I have a feeling you're going down the wrong path based on limited understanding of matrices. If you are trying to negate the Z axis without affecting the x and y axes, then you're basically switching between left-handed and right-handed coordinate systems. I suspect this isn't what you want to do. If you really want to change the rotation about the Z axis, then a bunch of new questions arise. It'll just help a whole bunch if you put this into context for us!

It would also help if you'd label your matrix better. As you've written it, I can't tell whether your basis vectors are rowwise or columnwise. But, its really not a good idea to touch only the upper-left 2x2 portion. You will more often than not break something when you do that.

Share this post


Link to post
Share on other sites
Thanks for the reply, switching between the right and left handed coordinate systems is what I want to do. I have a rotation matrix from a left handed system that I need to use in a OpenGL right handed system.

I have already taken the translation vector and inverted the z- translation. However my rotation matrices appear to be wrong, hence the question.

Thanks

Share this post


Link to post
Share on other sites
Can nobody help me with this?

It may also help if I say that I am using this matrix to setup projective texturing, and the texture is currently upside down. I take camera rotation and translation from a LH system, setup the projector in the OpenGL RH system, and the texture is upside down, and it seems to be misaligned.

I have also tried the following:

[ a b c ]
[ d e f ]
[ g h i ]

changing to

[ a b -c]
[ d e -f ]
[-g-h i ]

but this also seems to be the wrong projector position.

Please help!

Thanks again

Share this post


Link to post
Share on other sites
So basically you want the +Z axis to become the -Z axis, and vice versa, without changing the X and Y axis?
So like
|100|
|010|
|001|
would become
|1 0 0|
|0 1 0|
|0 0-1|

Can't you just negate the Z axis?
|x1 x2 x3|
|y1 y2 y3|
|z1 z2 z3|
becomes
| x1 x2 x3|
| y1 y2 y3|
|-z1 -z2 -z3|

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
The solution is actually very simple. It has nothing to do with how the basis was written or putting anything into context and it does not open any new questions.

Essentially what you want is to apply a general transformation to a set of points, but you want to keep your graphics system consistent. Specifically you want to convert a model for one coordinate system (left handed) to another (right handed), like a mirroring a model.

Here is the solution, but first you need to know that the rotation part of a transformation matrix is always orthonormal, what ever transformation you applied to then should not change that property. In that regard all answer you have been given are incorrect because they violate that property. Here we go.

An object in global space is represented by the transformation and a set pf points in local obeying the following expression.

Pw = Pl * M

To change the handedness of the object you need you apply and transformation to each size of the equation

Pw * H = Pl * M * H
Pwh = Pl * M * H

Were H is a general but invertible matrix. For a left to right convesion it will be:

1 0 0 0
0 1 0 0
0 0 -1 0
0 0 0 1

Notice that even H look is orthonormal it is not a transfomation matrix as the determinant is -1, and all transformation matrices should have a positive determinant to preserve volume, therefore you cannot multiply H to M directly. Instead you need to apply a algebraic manipulation that leave M orthonormal.

If H in invertible then

H * H’ = I

Matrix H time its inverse in the identity, if this is the case then we can apply the matrix to the above expression in any place and it will not change the result. We chose:

Pwh = Pl * H * H’ * M * H
Pwh = (Pl * H) * (H’* M * H)

Pwh = Plh * Mh

The expression (H’* M * H) is called similar transformation and it will leave Mh othonormal,

When implementing this you do not have to perform the actual multiplication, so can do it by just changing the sign of the values the need to be changed. For example

Plh = [x, y, -z]

And you can work out the sign of the elements of Mh

Notice that this is also a recurrent transformation, meaning it apply to hierarchies of objects. For example and point at a grand child level in a hierarchy can be expressed by:

Pw = Pl * M2 * M1

Then applying the trick

Pw * H = Pl * M2 * M1 * H
Pw * H = Pl * H * H’ * M2 * H * H’ * M1 * H
Pw * H = (Pl * H) * (H’ * M2 * H) * (H’ * M1 * H)

Leading to
Phl = Plh * M2h * M1h

This means you can used the method with any high level graphics API for which you do not even have assess to the low level rendering system.

You can also use the method to transform whole set of key frames animations, or anything that required rotation or transformation on a graphical object.

Share this post


Link to post
Share on other sites

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

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this