53

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?

Peter Mortensen
  • 1,050
  • 2
  • 12
  • 14
greyfade
  • 11,103
  • 2
  • 40
  • 43
  • 7
    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 03: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 Mar 28 '11 at 01:23
  • 4
    This question was referenced in *[Why we don’t hire .NET programmers](http://blog.expensify.com/2011/03/25/ceo-friday-why-we-dont-hire-net-programmers/)* (2011-03-25). – Peter Mortensen Aug 23 '11 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 Apr 03 '13 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. – The Muffin Man Jul 23 '13 at 23:02
  • @Gabe left-to-right is the Right Thing in computer graphic since the old days as pixel rasterization was performed "following" the beam on a CRT monitor, thus avoiding flickering. Search for "Racing the beam" on Google.Moreover, since lower video memory locations map to higher parts of the screen and also left part of the screens, it's way more natural (and less computationally expensive) to have a left-to-right coordinate system – Gianluca Ghettini Jun 26 '15 at 14:01
  • @Peter Mortensen [Expensify Hiring a .NET Programmer](https://blog.expensify.com/2011/08/30/expensify-hiring-a-net-programmer-seriously/) – Josiah Yoder Jan 13 '17 at 16:30

14 Answers14

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.

Peter Mortensen
  • 1,050
  • 2
  • 12
  • 14
Mauricio
  • 774
  • 6
  • 5
  • 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!) – 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). – Mauricio Mar 27 '11 at 18:21
  • 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 Aug 23 '11 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 Aug 24 '11 at 04:46
  • this is a superstitious answer and not founded in an creditable facts. the people that created 3D api's in the early 90's were students of the academics that were already using the right handed system. gaming or no gaming there was already momentum in place for RHS. A more likely business explanation is that 3Dfx and MS wanted their systems to be **incompatible on purpose** to discourage porting to the competitions hardware and API's like OpenGL. And monopolize the games to Windows and 3Dfx hardware. This worked better for MS than 3Dfx, as history shows. It hurt the consumer the most. –  Jun 20 '12 at 17:27
  • 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 Jun 22 '12 at 03:34
  • 1
    d) The consumer never gave a shit. They just played their games. It's only the developers that had to deal with this, and apparently it didn't discourage them at all. And if you're gonna say "cross-platform compatibility", I'm gonna laugh at you. That notion was unthinkable back then. The entire point of the unified 3D APIs was to make steps to such, instead of needing specific configurations for each video card. Remember those manuals that told you how to mess with CONFIG.SYS for each different brand? – Mauricio Jun 22 '12 at 03:34
  • @Jarrod Roberson - that's utter rubbish. D3D has never enforced any co-ordinate system on you; you could always use whichever you wanted. If you read the D3D docs you will know this. LH is just an *informal* convention used by *examples* that seems to have stuck but don't read anything more into it, because it's just not there. – Maximus Minimus Jun 30 '12 at 14:37
  • 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. –  Jun 30 '12 at 14:58
40

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.

Nicol Bolas
  • 11,813
  • 4
  • 37
  • 46
  • 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 Jul 01 '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. – hultqvist Apr 22 '12 at 07: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 Dec 11 '12 at 09:31
  • The default GL depth range is [-1, 1]. For Direct3D it is [0, 1]. – bobobobo Dec 12 '12 at 22:46
  • I noted the [view matrix generated by `gluLookAt`](http://stackoverflow.com/a/12336360/111307) can change the handedness as well (by using `-forward`). I'm not sure what is correct now. – bobobobo Dec 12 '12 at 23:05
  • @bobobobo No, the default depth range in OpenGL is [0, 1], please see [this man page](http://www.opengl.org/sdk/docs/man/xhtml/glDepthRange.xml) and confirm with the state tables in the spec. Normalised device coords' range is [-1,-1,-1] .. [1,1,1], you might have confused the two. – Kos Dec 27 '12 at 22:40
  • Yes, I meant the size of the canonical view volume. "After clipping and division by w, depth coordinates range from -1 to 1" (ie canonical) – bobobobo Dec 28 '12 at 03:40
  • 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 Apr 03 '13 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. – Christian Rau May 13 '13 at 16:09
  • Hmm, it appears that the reason the forward vector is negated is because OpenGL's default forward vector is (0,0,-1). For that reason it may be true that the lookAt matrix does not change the handedness of the coordinate system. – bobobobo May 13 '13 at 17:16
  • @bobobobo: Negating the Z-axis is precisely what changes the handedness. But that is actually done in the projection matrix. In fixed-function GL, eye-space is right-handed, but the projection matrix flips the Z-axis and produces left-handed clip-space coordinates as required by GL. From that point on in GL, all of the fixed-function coordinate spaces are left-handed. D3D does something kind of annoying, and uses left-handed clip/NDC spaces but negates the Y-axis during viewport mapping to produce right-handed window-space so that (0,0) is at the top-left corner of the window. – Andon M. Coleman Apr 21 '14 at 16:36
  • I came across this question while facing the same problem in a course where I use matlab. I chose to use i and j (i pointing down and j pointing right as matlab does for matrices) as my coordinate system, and this would force k (or z, if you prefer) to point toward the user, which is very inconvenient. I think I'll use a right-handed coordinate system, but sometimes it's hard to find a perfect standard. After all, Matlab is motivated by another long-standing mathematical convention! – Josiah Yoder Jan 13 '17 at 16:49
15

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/

Daniel Rikowski
  • 449
  • 1
  • 6
  • 9
  • 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. – John R. Strohm Jul 24 '13 at 12:32
  • 1
    @JohnR.Strohm - did you even read the article linked? – Maximus Minimus Jul 26 '13 at 17:24
  • 1
    Link-rot has eaten that page. Here's the latest working snapshot: https://web.archive.org/web/20161101112002/http://www.alexstjohn.com/WP/2013/07/22/the-evolution-of-direct3d/ – Max Barraclough Dec 09 '18 at 12:06
  • Even the updated link is gone: "Sorry. This URL has been excluded from the Wayback Machine." – Sz. Jul 28 '23 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.

tcrosley
  • 9,541
  • 1
  • 25
  • 41
  • 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 07 '10 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. – John R. Strohm Nov 12 '10 at 04:43
  • 3
    @John: Hey, guess what, the physicists have the same secret handshake too! – timday Nov 12 '10 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. – Christian Rau Aug 23 '11 at 12:07
  • @ChristianRau, which hand you use depends on what kind of coordinate system you are trying to describe, right- or left-handed. – John R. Strohm Jan 22 '14 at 19:05
  • @JohnR.Strohm Of course it does, that's what I was saying. – Christian Rau Jan 22 '14 at 19:31
  • @ChristianRau, the idea I was trying to get across is that newbies should be taught to revere right-handed coordinate systems, and do unspeakable things to anyone who proposes left-handed systems. The critical part of this training is teaching them WHY life is simpler when the left hand knows what the right hand is doing. – John R. Strohm Jan 22 '14 at 20:34
  • @JohnR.Strohm I absolutely agree with this attitude. I was just saying, that this right hand trick works equally well for the left hand (and thus left-handed coordinate systems) and thus doesn't make right-handed systems more intuitive on its own. – Christian Rau Jan 22 '14 at 20:50
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.

DarenW
  • 4,433
  • 3
  • 22
  • 43
  • 1
    All very interesting, and it certainly explains the rationale behind SGI's GL. ... But how does this explain DirectX being left-handed? – greyfade Dec 07 '10 at 05:39
  • Several 2D and 3D systems all derived their conventions from a common history. – DarenW Mar 28 '11 at 04: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.

John R. Strohm
  • 18,043
  • 5
  • 46
  • 56
  • 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 08 '10 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? – John R. Strohm Nov 09 '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 09 '10 at 14:06
  • @John R. Strohm: I like your proposal, really, but I have a hard time getting passionate about it. I just don't like the idea of having two code paths in a single program that do their work in opposing handedness. :P I would, one day, like to be able to support multiple APIs in my software. – greyfade Nov 10 '10 at 02:31
  • For a while I was one of those developers you refer to in your first paragraph. – ChrisF Dec 06 '10 at 23:40
  • 2
    Uh, so this is 100% speculation then? Why is it marked as the answer? – Factor Mystic Mar 25 '11 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. – Quick Joe Smith Mar 27 '11 at 01:26
  • This seems a very silly answer, as there _isn't_ any "industry concensus" on handedness... plenty of examples exist of both types. – snogglethorpe Jan 22 '12 at 02:31
  • This answer is all very nice and paranoid but it fails to account for the existence of D3DXMatrixPerspectiveFovRH. – Maximus Minimus Jun 30 '12 at 14:41
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.

gnat
  • 21,442
  • 29
  • 112
  • 288
Stephen Coy
  • 61
  • 1
  • 1
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.

Tom
  • 159
  • 1
  • 1
  • 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. – John R. Strohm Jun 20 '12 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 Apr 03 '13 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 Apr 04 '13 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 Dec 28 '16 at 03: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. https://en.wikipedia.org/wiki/Pseudovector#The_right-hand_rule – Oscar Benjamin Mar 08 '18 at 20:36
  • Yes, if you're prepared to compound the stupidity of defining your display system the wrong way by also defining your physical quantities the opposite way to everyone else, then the math still works out the same. I shouldn't need to explain why this would be a bad idea. – Tom Mar 09 '18 at 11:34
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.

tdammers
  • 52,406
  • 14
  • 106
  • 154
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.

Maximus Minimus
  • 1,498
  • 10
  • 11
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?

Maximus Minimus
  • 1,498
  • 10
  • 11
  • 1
    why did you post it in separate answer? I mean you could edit [your previous answer](http://programmers.stackexchange.com/a/148941) to add this couldn't you? – gnat Jul 01 '12 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".

  • 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. – John R. Strohm Jan 10 '13 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. – Thomas Sharpless Jan 11 '13 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

Thaina
  • 109
  • 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. – John R. Strohm Jul 26 '13 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 Aug 11 '13 at 00:35