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

StackOverflow https://stackoverflow.com/questions/19747082

Pergunta

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.

Foi útil?

Solução

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.

Outras dicas

Sometimes, a picture paints a thousand words...

enter image description here

Actually, there are several valid right-hand configurations, so pick one and stick with it:

alternatives

Left/Right handed coordinate systems and their respective vertex rotation are distinct conventions. Rotation of the vertices matters because it determines which direction the normal faces.

These normals are used in everything from light calculations to rendering determination. If the normal of the triangle is pointing in the same direction as the view vector, then it is facing away from the camera and will not be drawn.

If the normal vector of the triangle is facing the opposite direction of the view vector(in other words, facing the camera), then the triangle is visible and it will be drawn.

Because the z direction(z is usually assumed to be the "front to back" direction in computer graphics, it can also be x or y) flips in a right handed and left handed system, the "rotation" the vectors are loaded in definitely matters.

To answer your third question: If you have a couple of vertices to go off of, and you know which axis is front-to-back, you can easily tell if it is a right or left handed system. In a right handed system, z decreases as you move away from the camera. In a left handed system, z increases.

You can see how to position your hands at this website: Right/Left handed coordinate systems

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top