I considered posting on Stack Overflow, but the question strikes me as being far too subjective since I can't think of a reasonable technical explanation for Microsoft's choice in this matter. But this question has bugged me for so long and the issue keeps coming up in one of my projects, and I have never actually seen an attempt at explaining this:

OpenGL uses a right-handed coordinate system, where the +Z part of the world coordinate system extends toward the viewer.

DirectX uses a left-handed system where the +Z part of the world coordinate extends into the screen, away from the viewer.

I never used the Glide API, so I don't know how it worked, but from what I can gather, it uses a left-handed system as well.

Is there a technical reason for this? And if not, is there some conceptual advantage to a particular handedness of a coordinate system? Why would one choose one over the other?

link|improve this question
3  
This seems like asking why Arabic and Hebrew are written right-to-left, while every other language is left-to-right. – Gabe Mar 27 '11 at 3:19
3  
I'm just trying to understand why there is such a glaring inconsistency among graphics APIs, which share a solid foundation in mathematics. The direction of Semitic alphabets is decidedly not founded in immutable rules. – greyfade Mar 28 '11 at 1:23
1  
This question was referenced in Why we don’t hire .NET programmers (2011-03-25). – Peter Mortensen Aug 23 '11 at 10:50
feedback

8 Answers

up vote 23 down vote accepted

I know this is an old post, but I saw this post being referenced and dislike the chosen answer's tone.

So I did a bit of investigation!

  1. DirectX is old. It was first released in 1995, when the world had much more than Nvidia and ATI, DirectX vs OpenGL. That's over 15 years, people.
  2. 3dfx Interactive's Glide (one of DirectX's competitors back in the day. OpenGL wasn't meant for gaming back then) used a left-handed coordinate system.
  3. POV-Ray and RenderMan (Pixar's rendering software), also use a left-handed coordinate system.
  4. DirectX 9+ can work with both coordinate systems.
  5. Both WPF and XNA (which work with DirectX under the scenes) use a right-handed coordinate system.

From this, I can speculate about a couple things:

  • Industry standards aren't as standard as people like.
  • Direct3D was built in a time everyone did things their own way, and the developers probably didn't know better.
  • Left-handedness is optional, but customary in the DirectX world.
  • Since conventions die out hard, everyone thinks DirectX can only work with left-handedness.
  • Microsoft eventually learned, and followed the standard in any new APIs they created.

Therefore, my conclusion would be:

When they had to choose, they didn't know of the standard, chose the 'other' system, and everyone else just went along for the ride. No shady business, just an unfortunate design decision that was carried along because backward compatibility is the name of Microsoft's game.

link|improve this answer
2  
DirectX is an infant in swaddling clothes compared to 3D computer graphics, and that's relatively young compared to computer programs having to manage multiple 3D coordinate systems, and transform among them. It was the mid-1970s when I took the graphics class the first time, and EVEN THEN the instructor (Frank Crow) was very strongly pushing us to use right-handed coordinate systems exclusively. In 1983, I was working a job that did no graphics, but did have coordinate transformations going on, and a mandatory right-hand-rule was the FIRST project memo issued. (And I didn't issue it!) – John R. Strohm Mar 27 '11 at 13:36
I'm talking mostly 3D graphics in the context of gaming. It's positively new compared to all other 3D applications, yes, but from the consumer and gaming perspective, DX has been around for longer than they think. That said, the "standards aren't standard" thing still applies. (See POV-Ray and RenderMan). – Kyte Mar 27 '11 at 18:21
2  
I'm not sure that age has anything to do with it. Don't most physical sciences used a right-handed coordinate system, and have for many, many more years than computers have been around? I would say that is a much older convention than the ones being followed by Glide and then DX. – Thomas Owens Aug 23 '11 at 10:56
Just because a standard's used in academics doesn't mean it'll be the same in industrial/other applications. People follow whatever's being used in their own field, after all. Otherwise graphic systems would have their origin in the lower-left corner of the screen rather than top-left. In addition, the point about age is that DX was born when the whole "3D rendering for the desktop" thing was still new, and "standards" & "best practices" were yet to be fully hammered out. – Kyte Aug 24 '11 at 4:46
feedback

They are both essentially equivalent, as one can be easily transformed into the other. The only advantage I can find for the left-handed system is: as objects are farther away from the observer, in any direction (x, y, or z), the distance is a higher value. But I have no idea if this is why Microsoft chose one over the other.

POV-Ray also uses a left-handed corridnate system.

link|improve this answer
5  
Yes I think a lot of graphics newbies find z increasing with depth into the screen more natural. But they also want x increasing rightwards and y upwards, "graph axes" style. This gets them a left handed coordinate system. Only later when they try to do more complex things do they realize they are out-of-step with the right handed world of science/mathematics/engineering. – timday Nov 7 '10 at 22:02
4  
@Timday, you have to teach the newbies the secret 3-D graphics non-handshake. Hold out your right hand, with thumb, index finger, and middle finger extended, all at right angles to each other. Thumb is X, index finger is Y, middle finger is Z. Now move your hand around, to align with whatever coordinates you want, and you immediately know how the motion is going to affect the transformations. – John R. Strohm Nov 12 '10 at 4:43
2  
@John: Hey, guess what, the physicists have the same secret handshake too! – timday Nov 12 '10 at 12:20
@John Although I completely agree with the advantages of a right-handed system, you know that your handshake rule (that everybody should have learned in school) also can be used with the left hand for the left-handed system. – Christian Rau Aug 23 '11 at 12:07
feedback

It's pure history. In ancient days the early cave-graphics programmers thought of the monitor (teletype? stonetype?) viewing surface as two dimensional graph paper. In math and engineering the usual conventions for plotting data points on graph paper is: x=right, y=up. Then one day, about a week after the invention of the silicon wheel, someone thought of 3D graphics. When the candle-bulb of this idea blinked on above their head, for whatever reason, they choose to add Z= away from viewer. (Ouch, my right hand hurts just imagining that.)

They had no idea that someday their far descendants would become engineers, scientists, fine artists, commercial artists, animators, product designers etc and find 3D graphics useful. All these fine modern people use right-handed coordinate systems to be consistent with each other and the more established math texts and physics conventions.

It is foolish to base the 3D coordinate system on the display surface. It's the model that counts - the triangles and polygons and planes describing a house, chair, overweight green ogre or galaxy. Nowadays we all design and model stuff in right-handed XYZ systems, and do so in terms of the model's world, even before thinking how it'll be rendered. The camera is added at some point, possibly made to fly around in crazy ways, and it's invisible infrastructure that converts the model to pixels that within its bowels must twerk around with coordinated system transforms.

Just to add to the confusion, some graphics libraries recognize that CRTs scan the image from top to bottom, and so have Y=down. This is used even today in all windowing systems and windows managers - X11, fvwm, gtk+, Win31 API, etc. How new-fangled 3D GUI systems like Clutter, Beryl etc deal with Z, is a separate issue from 3D graphics modeling. This need concern only applications programmers and GUI designers.

link|improve this answer
All very interesting, and it certainly explains the rationale behind SGI's GL. ... But how does this explain DirectX being left-handed? – greyfade Dec 7 '10 at 5:39
Several 2D and 3D systems all derived their conventions from a common history. – DarenW Mar 28 '11 at 4:17
feedback

I'm surprised nobody mentioned something: OpenGL works in a left-handed coordinate system too. At least, it does when you're working with shaders and use the default depth range.

Once you throw out the fixed-function pipeline, you deal directly with "clip-space". The OpenGL Specification defines clip-space as a 4D homogeneous coordinate system. When you follow the transforms through normalized device coordinates, and down to window space, you find this.

Window space is in the space of a window's pixels. The origin is in the lower-left corner, with +Y going up and +X going right. That sounds very much like a right-handed coordinate system. But what about Z?

The default depth range (glDepthRange) sets the near Z value to 0 and the far Z value to one. So the +Z is going away from the viewer.

That's a left-handed coordinate system. Yes, you can change the depth test from GL_LESS to GL_GREATER and change the glDepthRange from [0, 1] to [1, 0]. But the default state of OpenGL is to work in a left-handed coordinate system. And none of the transforms necessary to get to window space from clip-space negate the Z. So clip-space, the output of the vertex (or geometry) shader is a left-handed space (kinda. It's a 4D homogeneous space, so it's hard to pin down the handedness).

In the fixed-function pipeline, the standard projection matrices (produced by glOrtho, glFrustum and the like) all transform from a right-handed space to a left-handed one. They flip the meaning of Z; just check the matrices they generate. In eye space, +Z moves towards the viewer; in post-projection space, it moves away.

I suspect Microsoft (and GLide) simply didn't bother to perform the negation in their projection matrices.

link|improve this answer
1  
Interesting indeed. I'll confess I never looked that closely. While my question concerns world space specifically, your answer gives me food for thought. – greyfade Jul 1 '11 at 15:59
I found that changing either the depth range or the depth test made it right-handed but using both cancelled eachother out giving me a left-handed system. – phq Apr 22 at 7:26
feedback

The thing to understand is that a HUGE amount of programmer time has been wasted converting between left-handed and right-handed coordinate systems, and even more programmer time has been wasted remembering which system was needed at any particular instant.

All of that went away when right-handed coordinate systems became the industry standard.

There are enough coordinate systems in common use already, without doubling the number by introducing a handedness question. See Minkler & Minkler, "Aerospace Coordinate Systems and Transformations". If you are in the aerospace coordinate business, doing e.g. flight simulation, you NEED that book.

My guess is that Microsoft didn't have ANYONE on the DirectX project who knew anything about the industry standards, didn't realize that there WAS an industry standard, and figured it didn't matter.

The other possibility, that they knew right-handed systems were the industry standard, and they deliberately made DirectX left-handed, so as to make it HARD for people to convert code that used DirectX to use OpenGL instead, does not bear consideration. Were I to discover that this was indeed the case, I would find it necessary to embark on a new and presumably short-lived career as an axe-murderer in Redmond.

link|improve this answer
I didn't want to come off as bashing Microsoft in my question, so I didn't want to mention the possibility that it was incompatibility with OpenGL they had in mind. – greyfade Nov 8 '10 at 17:21
2  
@greyfade: OK, then let me put it this way. There is no technical reason whatsoever to prefer left-handed coordinates over right-handed coordinates, or vice versa. However, there are very, very good reasons nowadays to prefer right-handed coordinates, and to tar, feather, and ride out of town on a rail anyone who even whispers a hint of implementing anything at all using left-handed coordinates. Does that make it simpler? – John R. Strohm Nov 9 '10 at 13:08
I don't know that I could muster any amount of righteous indignation over it. I work with PostScript fairly regularly as part of my job (where coordinates start with [0, 0] as the lower left corner and max out at the top right), so coordinate conversion is just sort of a fact of life around here. – Inaimathi Nov 9 '10 at 14:06
1  
Uh, so this is 100% speculation then? Why is it marked as the answer? – Factor Mystic Mar 25 '11 at 21:38
1  
Beats me, it's just a pointless rant and, ironically, like the left-handed coordinate system, a lot of people just went along with it for some reason. – Quick Joe Smith Mar 27 '11 at 1:26
show 3 more comments
feedback

Neither is ultimately better than the other - you're mapping 3D coordinates to a 2D surface, so the third dimension (which actually makes things 3D) can be chosen arbitrarily, pointing at the viewer or into the screen. You're going to put things through a 4x4 matrix anyway, so there is no technical reason to choose one over the other. Functionally, one could argue:

  • There is a fairly broad consensus in computing and other fields to have the X axis run from left to right (aviations apparently being a notable exception).
  • In mathematics, the Y axis points up. (Also, Up Is Where The Bubbles Go).
  • On computer displays, the Y axis points down (because that's how CRT screens work, and also because that's the order in which most human scripts arrange rows).
  • When you look at the "visible" side of a surface in the X/Y plane, the normal should point toward the viewer (such as when you look at satellite footage; the "height above sea level" points at the satellite, not at the center of the Earth). Since the normal for the X/Y plane is the Z axis vector, it follows that the Z axis should also point toward the viewer.
  • When you look at 3D images on a computer screen, points that are further away from the viewer should have a larger Z component. Hence, the Z axis should point into the screen.

Conclusion: There is some consensus for the X axis, but for the other two, both directions can be argued for, yielding two right-handed and two left-handed configurations, and they all make sense.

link|improve this answer
feedback

Interesting fact.

Direct3D (not DirectX - DirectX also covers input, sound, etc) actually doesn't have a left-handed co-ordinate system.

It's perfectly capable of supporting both RH and LH systems. If you look in the SDK documentation you'll see functions such as D3DXMatrixPerspectiveFovLH and D3DXMatrixPerspectiveFovRH. Both work, and both produce a projection matrix that can be used successfully with your co-ordinate system of choice. Hell, you can even use column-major in Direct3D if you wish; it's just a software matrix library and you are not required to use it. On the other hand, if you want to use it with OpenGL you'll find that it also works perfectly well with OpenGL too (which is perhaps the definitive proof of the matrix library's independence from Direct3D itself).

So if you want to use an RH system in your program, just use the -RH version of the function. If you want to use an LH system, use the -LH version. Direct3D doesn't care. Likewise, if you want to use an LH system in OpenGL - just glLoadMatrix an LH projection matrix. None of this is stuff important and it's nowhere near the huge issue that you sometimes see it made out to be.

link|improve this answer
feedback

There is no technical advantage to either handedness, it's completely arbitrary. Both work fine as long as you're consistent.

Because of the advantages of consistency, ideally one should just "use what everybody else is using"—but that's quite difficult in many cases, because there's no overwhelmingly "preferred" convention in practice either: both handednesses are widely used. At best, there's some consistency within certain communities (e.g. OpenGL).

So I think the basic answer to this question is: They chose what they chose because it felt right (no doubt they had some previous experience with that handedness) and there was little reason not to.

In the end it makes little difference—anybody who seriously wants to exchange assets/code with other systems/communities is going to have to be prepared to deal with handedness conversion anyway, because it's a fact of life in 3D graphics.

link|improve this answer
feedback

Your Answer

 
or
required, but never shown

Not the answer you're looking for? Browse other questions tagged or ask your own question.