# OpenGL LH vs. RH Coordinates

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

## Recommended Posts

I am considering taking the plunge and learning DirectX. My prior experience is in OpenGL with a lot of training in mathematics and engineering, so I am quite familiar with and used to right handed coordinate systems. I find LHCSs to be "unnatural". My question is this... In DX (or LHCS in general) what, specifically, is affected by the selected handedness? I get the impression that it is only the View matrix and polygon winding order that is LH (I am still not sure about the Model matrices). Is anything else affected? For example, do normals still face outward? Do mathematical operations, such as vector cross product and quaternion operations, yield the same results? When I rotate an object (in Model matrix space) about Z, do I rotate about the RH or LH Z axis? Thanks!!

##### Share on other sites
Quote:
 I am considering taking the plunge and learning DirectX. My prior experience is in OpenGL with a lot of training in mathematics and engineering, so I am quite familiar with and used to right handed coordinate systems. I find LHCSs to be "unnatural".My question is this... In DX (or LHCS in general) what, specifically, is affected by the selected handedness? I get the impression that it is only the View matrix and polygon winding order that is LH (I am still not sure about the Model matrices). Is anything else affected? For example, do normals still face outward? Do mathematical operations, such as vector cross product and quaternion operations, yield the same results? When I rotate an object (in Model matrix space) about Z, do I rotate about the RH or LH Z axis?
I don't use D3D, but I will try to answer some of your questions based on what I know of it. Please don't take anything I say as the final word, though, as my knowledge of D3D is all second-hand.

If you're trained in math and engineering, you probably already know most of what I'm going to say. (Others might find it useful, though, as this material is confusing...)

First of all, although LH is strongly associated with +z into the screen, and RH with -z into the screen, handedness and which axis goes into the screen are really unrelated issues. I mention this because a lot of people think that LH means '+z into the screen', which isn't really accurate.

D3D and OpenGL 'lookat' matrices are set up differently, but again this is due to the +z/-z issue, not coordinate system handedness. What it comes down to in practice is that the first step in building a D3D lookat matrix is to find the forward vector as target - pos, but in OpenGL it's pos - target.

The cross product is defined the same way mathematically, but has a different geometric result depending on handedness. You can use a variation of the 'hand' trick to visualize this. Stick out your thumb on either hand and wrap the rest of your fingers around. If the thumb is the cross product, C = AxB, your other fingers wrap from A to B. You can see from this that cross products computed from the same vectors in a LH and RH system will point in opposite directions.

Another issue is rotations. You can use the same rotation matrix in either API, but the direction of positive rotation will be opposite. You can use the same hand trick as before, except in this case the thumb represents the axis of rotation, and the fingers indicate the direction of positive rotation.

I can't say much about how models are affected, but from my experience, changing handedness will change polygon winding order.

There are other differences in convention between D3D and OpenGL that people often find confusing. From an implementation standpoint, D3D matrices are row-major while OpenGL is column-major. Also, D3D uses row vectors (transformations are applied from left to right) while OpenGL uses column vectors (transformations are applied from right to left). I believe that in D3D quaternion multiplication is reversed so that, contrary to mathematical convention, they are applied from left to right rather than right to left. This is to match the row-vector convention used with D3D matrices.

##### Share on other sites
Just thought I'd point out that as far as I'm aware, just because you're using D3D doesn't mean you have to use a left handed coordinate system. Clip space is the same in D3D and OpenGL. The handedness of the coordinate system largely depends on what you choose to call "further into the screen". Because of the perspective transformation the Z axis in clip space doesn't really relate to the Z axis in object space, it's either +1/Z or -1/Z (with some other factors). Usually the choice is to call more positive depth values further away, and so the handedness of the coordinate system is decided by whether the transformation and projection matrices flip the coordinate system or not, and your chosen convention of depth values.

So in the end, you can arrange object space to have the handedness of your choice. And also being a scientist, I think RHS should be standard for the sake of consistency with everything else (except MS that is). Of course being picky the usual mathematical convention is like the Quake coordinate system where X is to the right, Y is into the screen/page, and Z is up.

1. 1
2. 2
Rutin
16
3. 3
4. 4
5. 5

• 26
• 11
• 9
• 9
• 11
• ### Forum Statistics

• Total Topics
633709
• Total Posts
3013481
×