How does coordinate system handedness relate to rotation direction and vertices ordering?

jcxz picture jcxz · Nov 2, 2013 · Viewed 10.6k times · Source

While trying to understand different coordinate systems I came across this website, which states: RenderMan uses left-handed coordinate system and the positive rotation is clockwise, while OpenGL uses right-handed coordinate system and the positive rotation is counter-clockwise.

My question is whether the rotation direction and the coordinate system handedness are just two distinct conventions or this results from maths itself ?

Similarly, I know that the front facing vertices of triangles have to be ordered in counter-clokwise direction in OpenGL. Does this too relate to coordinate system handedness or it's just another unrelated convention ?

And thirdly, when a picture of random coordinate system with axes labeled as x, y, z is thrown before me, how do I tell which one is left handed and which one is right handed ? I know there is a rule with right hand and the middle and the index fingers and the thumb, but everyone seems to use it differently. How should I align my fingers with these axes ?

Sorry for probably mixing a lot of unrelated stuff together, but after reading all kinds of internet sources, things start to blend together in my head.

Answer

Rethunk picture Rethunk · Nov 3, 2013

A fairly common method for either left or right hand:

  1. With your hand flat, point your fingers in the direction of X.
  2. Curl all fingers but your index finger to point towards Y.
  3. Raise your thumb. That's Z.

Again that's:

  • +x = Index finger
  • +y = middle finger (and/or ring and pinky fingers) bent 90 degrees inward
  • +z = thumb sticking out

Given an XYZ coordinate frame, determine positive rotations:

  1. Point your thumb in the direction of +X, or +Y, or +Z.
  2. The direction in which your fingers curl and point is the direction of positive rotation.

In most cases with which I'm familiar (YMMV), the right-hand rule is the norm. Graphics can be a little screwy in using the left-hand rule sometimes. In the cases with which I'm familiar, which are by no means exhaustive, the left-hand rule is chosen because the programmer/designer wants Z to point in some "natural" direction. Some people don't like the notion of Z pointing into or out of the screen, perhaps.

Once a certain handedness has been chosen, then there are consequences for vector directions. Although I'm not sure this is the right example since I deal with image processing rather than graphics, if a polygon is defined using oriented segments, then the cross product of successive segments will point out of or into the screen. It's important to know which side of the 2D polygon is facing "out" to the viewer, because the polygon may represent some 2D object that has different colors on opposite sides.

More generally speaking, the choice of handedness will determine how cross products are handled. "X cross Y equals Z" is what you're doing when you point your fingers and thumb using your hand.

Try holding out both hands and do this:

  1. Point left and right hand fingers straight ahead, away from your body. That's X.
  2. Curl your fingers to your left--flip one hand over to do so. That's Y.
  3. Now stick out your thumbs. They point in opposite directions.