Sign in to follow this  
Raeldor

LH and RH Matrix Building... Are They Different?

Recommended Posts

Raeldor    254
Is a matrix (say for rotation around the x-axis) different in a left handed system compared to a right handed system? I am having to convert between the two, and it's hard to find reference material explaining the differences. Thanks

Share this post


Link to post
Share on other sites
jyk    2094
Quote:
Is a matrix (say for rotation around the x-axis) different in a left handed system compared to a right handed system?
Basically, no. However, the same matrix, while correct in both cases, will appear to rotate in a different direction if you change coordinate systems.

The standard convention is that if you hold up your right or left hand, stick out your thumb, and curl your other fingers around, the direction of the curl is the direction of positive rotation about an axis aligned with your thumb for a coordinate system of that handedness. You can reverse that convention if you wish by transposing the rotation matrix, but I don't know that this is commonly done.

Of more concern is the difference between row- and column-vector form, as references will often present rotation matrices without specifying which convention is being used. Also, from an implementation point of view, it may be an issue whether the matrix is row or column major. As all of these things - vector convention, majorness, and 'forward' or 'backward' rotation - are transposes of each other, it can be easy to get confused. In fact, it's quite easy to get correct results with incorrect code, as two errors will cancel each other out.

Matrices having to do with viewing and projection do differ between LH and RH systems. Given that +x to the right and +y up is an accepted convention, the handedness of the system determines whether +z is into or out of the screen, which in turn affects the construction of those particular matrices.

Share this post


Link to post
Share on other sites
Raeldor    254
Can I assume that a right handed system will have the basis vectors and columns and a left handed system the basis vectors as rows? If I want to convert from one system to another, do I multiply by something like...

[1 0 0]
[0 -1 0]
[0 0 1]

Or do I translate the original matrix?

Share this post


Link to post
Share on other sites
jyk    2094
Quote:
Can I assume that a right handed system will have the basis vectors and columns and a left handed system the basis vectors as rows?
As I understand it at least, the answer is no. However, due to the predominance of two particular graphics APIs, in practice the answer is often yes :)

To elaborate, coordinate system handedness and row or column vector convention aren't connected in any particular way. You could write your own software engine that used a RH system with row vectors, or vice versa. However, as you probably know, OpenGL uses a RH system and column vectors, and D3D uses a LH system (usually) and row vectors. This causes a lot of people to equate vector convention with handedness, but it's really just incidental. That said, things will be much easier if you adopt the conventions of your chosen API for your own math library.

Share this post


Link to post
Share on other sites
Raeldor    254
Quote:
Original post by jyk
Quote:
Can I assume that a right handed system will have the basis vectors and columns and a left handed system the basis vectors as rows?
As I understand it at least, the answer is no. However, due to the predominance of two particular graphics APIs, in practice the answer is often yes :)

To elaborate, coordinate system handedness and row or column vector convention aren't connected in any particular way. You could write your own software engine that used a RH system with row vectors, or vice versa. However, as you probably know, OpenGL uses a RH system and column vectors, and D3D uses a LH system (usually) and row vectors. This causes a lot of people to equate vector convention with handedness, but it's really just incidental. That said, things will be much easier if you adopt the conventions of your chosen API for your own math library.


Thanks. My problem is that I am writing an animation exporter from a right handed system (max) into a left handed system (d3d). For vertices, I just negate the y component, but for rotations it seems to be quite a different story. I am exporting them as quaternions, but I have euler angles as my starting point. At the moment I convert them into a rotation matrix and then multiply by

[1 0 0]
[0 -1 0]
[1 0 1]

and then extract the rotation part back out as a quaternion. Doesn't seems to work though as my transforms are mangling my model :(

Share this post


Link to post
Share on other sites

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