54

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?

7
  • 7
    This seems like asking why Arabic and Hebrew are written right-to-left, while every other language is left-to-right.
    – Gabe
    Commented Mar 27, 2011 at 3:19
  • 21
    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
    Commented Mar 28, 2011 at 1:23
  • 4
    This question was referenced in Why we don’t hire .NET programmers (2011-03-25). Commented Aug 23, 2011 at 10:50
  • 2
    Neither OpenGL nor Direct3D is purely right or left-handed. Former changes to left handed in clip space while the later's screen space is right-handed i.e. in D3D's screen space the rotation from X to Y when viewed from +Z side is a counter-clockwise rotation. AND both systems allows developers to employ spaces of either chirality.
    – legends2k
    Commented Apr 3, 2013 at 15:04
  • 1
    @PeterMortensen It's pretty funny how all haters of .NET don't even know what it is. What they're probably referring to is ASP.NET Webforms, the framework. .NET can be described as the base class library and the CLR. Commented Jul 23, 2013 at 23:02

14 Answers 14

65

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.

9
  • 14
    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!) Commented Mar 27, 2011 at 13:36
  • 9
    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
    Commented Aug 23, 2011 at 10:56
  • 3
    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.
    – Mauricio
    Commented Aug 24, 2011 at 4:46
  • 4
    a) So you call my answer, which is a simple list of provable facts and what I explicitly call my own personal speculation, "superstitious" and "ungrounded in facts", when your own offering is an accusation of corporate misbehavior with no citation or backing whatsoever? b) If you dislike my answer, you can always give your own. When I gave this answer, the accepted answer was already a year old. You are free to add more knowledge, if you feel you have something to contribute. c) It's hard to create a monopoly when your foothold on the market is shaky. This ain't the modern multinational MS.
    – Mauricio
    Commented Jun 22, 2012 at 3:34
  • 2
    @Kyte 3Dfx had proprietary APIs for a specific reason, to lock you into their hardware. They forced end users to buy their hardware because developers were "bribed" to write games that only worked with 3Dfx. Microsoft wanted locked you into their API so that developers would only write games for Windows, this ultimately killed 3Dfx. Plain and simple business decisions, not misbehavior. This is still going on today. Nvida wants you lock you into their cards with CUDA, AMD wants to use OpenCL, 2012 same reasoning behind the behavior. This is history, I was in the industry at the time.
    – user7519
    Commented Jun 30, 2012 at 14:58
41

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.

12
  • 4
    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
    Commented Jul 1, 2011 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.
    – hultqvist
    Commented Apr 22, 2012 at 7:26
  • 1
    Intriguing. Look at viewport depth transformation: z_wiewport = z_clip*(far-near)/2 + (near+far)/2. That makes clip space's -1 be mapped to near and +1 to far. Hence clip space itself can be considered LEFT‑handed, even though you can still reverse how it's mapped to the viewport later.
    – Kos
    Commented Dec 11, 2012 at 9:31
  • 1
    @NicolBolas: Did you notice that even Direct3D isn't purely left-handed since it's screen space is right-handed? X left to right, Y top to bottom and Z away from the viewer i.e. X to Y is a counter-clockwise rotation when viewed from opposite to Z axis.
    – legends2k
    Commented Apr 3, 2013 at 15:02
  • 1
    @bobobobo "I noted the view matrix generated by gluLookAt can change the handedness as well" - No, it doesn't. That's just how the forward vector is computed, but this matrix is nevertheless an ordinary rigid body trasnformation in right-handed space (and in fact +z is indeed "backward" in right-handed space). Negating the forward vector doesn't have anything to do with changing the handedness of the coordinate space. Commented May 13, 2013 at 16:09
16

The lead developer of DirectX (and Direct3D) Alex St. John recently commented on that. In an article on the history of Direct3D he wrote:

I [...] was asked to choose a handedness for the Direct3D API. I chose a left handed coordinate system, in part out of personal preference. [...] it was an arbitrary choice.

Source: http://www.alexstjohn.com/WP/2013/07/22/the-evolution-of-direct3d/

4
  • It is an arbitrary choice only if you do not have a clue what the rest of the world is doing, that the rest of the world has de facto standardized on right-handed coordinate systems for graphics. Commented Jul 24, 2013 at 12:32
  • 1
    @JohnR.Strohm - did you even read the article linked? Commented Jul 26, 2013 at 17:24
  • 1
    Link-rot has eaten that page. Here's the latest working snapshot: web.archive.org/web/20161101112002/http://www.alexstjohn.com/WP/… Commented Dec 9, 2018 at 12:06
  • Even the updated link is gone: "Sorry. This URL has been excluded from the Wayback Machine."
    – Sz.
    Commented Jul 28, 2023 at 14:50
11

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.

8
  • 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
    Commented Nov 7, 2010 at 22:02
  • 6
    @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. Commented Nov 12, 2010 at 4:43
  • 3
    @John: Hey, guess what, the physicists have the same secret handshake too!
    – timday
    Commented Nov 12, 2010 at 12:20
  • 1
    @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. Commented Aug 23, 2011 at 12:07
  • @ChristianRau, which hand you use depends on what kind of coordinate system you are trying to describe, right- or left-handed. Commented Jan 22, 2014 at 19:05
11

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.

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

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.

9
  • 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
    Commented Nov 8, 2010 at 17:21
  • 3
    @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? Commented Nov 9, 2010 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
    Commented Nov 9, 2010 at 14:06
  • 2
    Uh, so this is 100% speculation then? Why is it marked as the answer? Commented Mar 25, 2011 at 21:38
  • 3
    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. Commented Mar 27, 2011 at 1:26
6

The real answer to Direct3D's early left handedness is a lot less sinister than some of you are speculating. DirectX got its start when Microsoft bought RenderMorphics back in 1995.

At that time the standard graphics text used in the RenderMorphics offices was "Principles of Interactive Computer Graphics" by Newmann and Sproul which does everything using left handed coordinates. It's the same book that I used in college. Looking at the D3D code you could even see them using variable names which matched the equations in the book.

It's not some Microsoft conspiracy. The decision was made before Microsoft even came into the picture.

3
  • I agree with a comment here that this sounds like an urban legend, but it's nice to get your personal perspective. Commented Jan 13, 2017 at 16:24
  • @JosiahYoder link dead?
    – Sz.
    Commented Jul 28, 2023 at 15:04
  • @Sz. Try internet archive. I've forgotten this discussion. Commented Jul 28, 2023 at 15:16
5

To all those who think there is no advantage to right- or left-handedness, you are absolutely wrong. The right-handedness of Cartesian co-ordinate systems comes from the definition of the vector cross product. For XYZ basis vectors u, v and w, w = u X v.

This definition is fundamental to vector mathematics, vector calculus and much of physics. Suppose that you are trying to simulate electromagnetic interactions. You have a magnetic field vector, M, and a charged particle moving in that field with velocity v. Which way does the charge accelerate? Easy - in the direction of M X v. Except some idiot thought it'd be fun to make your display system left-handed, so it accelerates in the direction of -M X v.

Basically any physical interaction between two vector quantities is defined as right-handed, and so any time you need to simulate that interaction, you'd better hope your graphics system is right-handed or you will need to remember to cart around negative signs in all your math.

6
  • Electromagnetics are not the only place that cross product comes up. It also shows up in aerodynamics and orbital mechanics. Flight simulation has to deal with it, and this is where physics coordinate systems and graphics coordinate systems collide. See Minkler & Minkler, cited in my answer above. Commented Jun 20, 2012 at 20:33
  • @Tom: I'm not sure if this is true; take 3 vectors say (1, 0, 0), (0, 1, 0) and (0, 0, 1), performing i x j gives k since the formula for cross product is well-defined and numbers don't've any chirality/handedness; it's only the human who interprets the three vectors in some handedness, even then we may choose to interpret it in both handedness and it will still be consistent i.e. in a left-handed i x j = k will be away while in the right-handed i x j = k will be towards. Mind you, I'm a right-handed guy too, but still this is the fact.
    – legends2k
    Commented Apr 3, 2013 at 14:55
  • @legends2k: Yes, I guess that is true, so long as you don't want your numbers to mean anything at all. As soon as you want your numbers to represent a physical interaction, or the co-ordinates in a display system, or actually anything at all then it matters very much.
    – Tom
    Commented Apr 4, 2013 at 14:56
  • @Tom You are right that we must give meaning to number. That really matter. But that still not the reason to say that left hand is over right hand. I could give a meaning to 0,0,1 as going forward and that is lefthand so 1,0,0 X 0,1,0 make 0,0,1 is left hand
    – Thaina
    Commented Dec 28, 2016 at 3:22
  • 1
    @Tom Actually when doing Physics in a left-handed coordinate system the formula is still M X v but the magnetic field M is considered to point in the opposite direction because it is a pseudovector. You can use the same equations in either system: the only thing that changes is your interpretation of which way the pseudovectors "point". Proper vectors like acceleration will always work out the same in either coordinate system. en.wikipedia.org/wiki/Pseudovector#The_right-hand_rule Commented Mar 8, 2018 at 20:36
3

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.

3

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 stuff is important and it's nowhere near the huge issue that you sometimes see it made out to be.

0

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.

0

Providing this as supplementary material to my previous answer here. From an old OpenGL spec from the 1990s:

OpenGL does not force left-or right-handedness on any of its coordinates systems.

(source: http://www.opengl.org/documentation/specs/version1.2/opengl1.2.1.pdf).

So, since neither D3D nor OpenGL enforce any handedness the real question is: why do people see this as being anything of a big deal?

1
  • 1
    why did you post it in separate answer? I mean you could edit your previous answer to add this couldn't you?
    – gnat
    Commented Jul 1, 2012 at 19:41
-1

I hate to tell ya, but the 'hand' of a set of coordinates is actually subjective -- it depends on which way you imagine you are looking at things. An example, from the OpenGL cube map spec: if you imagine being inside the cube looking out, the coordinate system is left-handed, if you think of looking in from the outside it is right handed. This simple fact causes endless grief, because to get a numerically correct answer all of your assumptions have to be consistent, even though locally it doesn't actually matter which assumption you make.

The OpenGL spec is officially "handedness neutral" and goes to great lengths to avoid this issue -- that is, to put it off onto the programmer. However there is a "hand change" between eye coordinates and clip coordinates: in model and eye space we are looking in, in clip and device space we are looking out. I'm always struggling with the consequences of this no doubt accidental complication.

The cross-product is our friend, because it lets you generate a definitely right handed or left handed 3D coordinate system from a pair of vectors. But which hand it is depends on which of those vectors you call "X".

2
  • 3
    The cross product is anticommutative. A x B == - B x A. As such, a cross product is defined to take a noncollinear first vector and a second vector, written in that order, and produce a third vector, normal to the plane containing the first and second vectors, and of a direction appropriate to create a right-handed coordinate system when the vectors are enumerated in the order (first, second, result). If you choose to pervert this, feel free, BUT BE WARNED: If you do it around me, you'd better enjoy tar, feathers, and splinters in your butt from your rail ride out of town. Commented Jan 10, 2013 at 21:53
  • Quite right, John; but you still have to face the fact that such perversion is possible, meaning there is no such thing as "absolute right handedness", meaning that it is still up to you and me to get the signs right. Commented Jan 11, 2013 at 14:31
-3

I could said that industry standard is wrong from the first place

Industry standard of coordinate actually came from desk coordinate, when people draw everything on desk, which is horizontal plane. X is left/right and Y is front/back, so it just make Z be upward and that was born Right-Handed Coordinate System

But You know We now using with monitor screen It is Vertical plane. X is still left/right but Y is the up and down instead

So what Right-Handed Coordinate System would cause? It make +Z be backward and -Z be forward What the hell is this? Up is + and Down is - Right is + and Left is - BUT Forward is - and Backward is + ??? It so stupid if we making game that character running in 3D world but we need to minus z to go forward. That's why game programmer most appreciate DirectX

To grab a standard that came from desk and use it on monitor is so wrong in many level from the first place. And now we should admit it that they, OpenGL and Industry, is wrong. They just use what they think it would make them comfortable but they are wrong and Right-Handed Coordinate System is just a junk legacy that should be thrown away as fast as possible

2
  • 2
    -1 for ignorance. The right-hand convention comes from physics and mathematics, specifically the vector cross product operation, which is fundamental to electromagnetic field theory and to mechanics. Computing adopted it because the original use of computers was to crunch numbers. Commented Jul 26, 2013 at 19:38
  • Should -1 for your ignorance instead. As I said "desk coordinate" physics and mathematics in the old time always work on desk, not monitor, so I called it "desk coordinate" because you calculate physics and math on horizontal desk
    – Thaina
    Commented Aug 11, 2013 at 0:35

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