From what I've seen almost all things use coordinates where (0, 0) is at the top left and the positive Y-axis goes in the downwards direction of your screen.

Why is it like this? Why not the conventional positive Y-axis going upwards like shown in graphs in simple math classes?

  • 7
    I would argue that starting at the top and increasing as you go down makes more sense than the mathematical convention, as it more closely relates to the way in which indo-european languages are read and written. – Panda Pajama Sep 17 '14 at 12:18
  • 3
    I think that the Y+ up makes sense when drawing physical objects, as the ground is your origin, and most of your world is above the ground. However, for displays, I hypothesize that it is related to mimic the way indo-european languages are written. – Panda Pajama Sep 17 '14 at 12:36
  • And I assume the reason pretty much every language (that I know of) is written top down is because of the way the human hand is designed. Writing from bottom to top makes you hide the information you've previously written. – Panda Pajama Sep 17 '14 at 12:38
  • 1
  • 4
    Don't the normalized device coordinates of OpenGL have an upwards Y axis? – Ray Koopa Sep 18 '14 at 10:46
up vote 40 down vote accepted

This is caused in the history. Early computers had Cathode Ray Tubes (CRTs) which "draw" the image with a cathode ray from the upper left corner to the lower right.

To ease the interface between the graphics card memory and the CRT the memory was read from the beginning and the image was drawn from the top left (with the lowest memory address) to the lower right (with the highest memory address).

Extension (based on the comments)

The CRTs are based on analog TV sets that were available at that time.

The TV sets create the image line by line first from left to right and then from top to bottom. The reason for this can only be assumed to be based on the writing style in western contries.

  • 7
    Sure, but why do CRTs draw from the top left (viewed from the spectator)? Why not vertically? Why not from right to left? Why not from bottom to top? – Panda Pajama Sep 17 '14 at 12:27
  • 1
    You can find the image creation of a CRT here. Basically this is for analog television but a CRT for a computer has the same technology. – Uwe Plonus Sep 17 '14 at 12:31
  • 12
    @PandaPajama computer CRTs do it because that's the way analog TV standards are, and initially for home computers often the TVs were used instead of specialized monitors. Why the first TVs transmitted information by splitting it in scanlines and drawing scanlines left to right - I'm not sure, but that would be consistent with the way we write, so that might be a good enough reason to choose between arbitrary options. – Peteris Sep 17 '14 at 19:50
  • 2
    @Peteris: The way Europeans write – Mooing Duck Sep 17 '14 at 20:54
  • 1
    Technically, the CRT draws from Stage Top Right to Stage Bottom Left. – ps2goat Sep 17 '14 at 21:09

This is a great question that I've thought of many times. The simple answer to "why" is because TV formats also drew their lines from left-to-right then top-to-bottom. Original computer monitors were CRT screens (small TVs), so the format naturally stayed the same. When monitors became flat screens (and TVs became flat screens too), it was equally natural to keep the same format for easy compatibility.

Of course you can then ask: why do TVs draw this way? They were invented in the early 20th century so you can imagine how much thought or lack thereof went into the design, if it was even questioned. Note: not meant to be disrespectful as it is incredibly more challenging to get equations for magnetically deflecting rays to the proper lines on a screen, as opposed to a simple matrix of tiny "light bulbs". (This kinda brings up the question of how on Earth did they invent CRTs before the simple matrix of dots, way back in the early 20th century?)

Nevertheless, my guess is that probably it was never questioned (a bad thing) since the Western languages write words left-to-right and top-to-bottom. Probably no one conceived of the possibility of doing it differently.

Personally, I dislike this format. I gained this attitude as I programmed games and other simulations involving elliptical orbits. Whenever you look up drawing equations involving sin, cos, or tan, you have to carefully invert the signs that deal with the y-axis parameters...or you will get the wrong thing drawn. An example would be the parametric equations for an ellipse drawn at any 2D angle. It can be a real nightmare dissecting the sinsin, sincos, and similar things.

Succinctly speaking in mathematical terms, the screen is in Quadrant 4 instead of Quadrant 1. This is unnecessarily complicated.

BTW when you get to 3 dimensions, the z axis is considered to go "upwards" in the positive direction. Kinda ironic. [EDIT]: Maybe not, see my comment below.

2 more things I realized/came across:

Sundials in the northern hemisphere (that have north-facing pointers and disks parallel to the ground) always rotate clockwise. So if we put the zero hour at the top of the "clock face", then the shadow pointer starts moving to the right. This could be the origin of left-to-right direction in western languages, propagating down to Cartesian coordinates and TV/computer screens.

Old computers did not draw graphical objects so much. They drew text in a command prompt. So it is natural to put line 0 at y=0. If we had a bottom-left origin, the math of drawing textlines would be a bit more involved, and it could've been a big deal to those old slow computers (who even made a shortcut for incrementing by 1, for goodness sakes, called "++"). Plus you need to know the resolution of the screen, whereas if you just do line 0 at y=0, you don't need to know the resolution.

  • 2
    You make it sound like the early 20th century was populated by Neanderthals ;) – bummzack Sep 18 '14 at 9:03
  • Aw, I was just trying to emphasize the stark contrast in complexity between CRTs and a matrix of LEDs. CRTs have amazingly complex math involved in the magnetic deflection of rays of light. A dot matrix is way easier to wrap your head around: just send electric current to the right LEDs at the right time. If anything, this vast magnitude of greater complexity suggests that the early 20th century was populated by more or better geniuses, as they had to do this more complex thing in a much more limited era. – DrZ214 Sep 18 '14 at 10:33
  • LED-matrices were used to display information, they never became popular for TV's and computer monitors. The modern flat screens are not LED matrices, but backlit LCD. LEDs are just used for backlighting in some screens, but the image is not created by LEDs. LCD is a simple technique, but improving the resolution from the old watch display to hundreds or thousands of pixels across the screen (and then some, as you need three subpixels to add colour!) is not necessarily a lot easier than modulating a wave signal controlling an EM beam (which is in a way comparable to radio broadcasting) – oerkelens Sep 18 '14 at 12:02
  • Z-axis up isn't ironic -- it's math. The coordinate system needs to be right-handed, so if +X is to the right and +Y is into the screen, that makes +Z up. Just like if we retain +X to the right, +Y down, +Z is into the screen. – tpg2114 Sep 18 '14 at 12:14
  • 1
    @tgp2114 Why does the coordinate system need to be right-handed? – Taemyr Sep 18 '14 at 13:54

Addendum: Early graphics were done on vector monitors, just one step up from the oscilloscopes seen in the lab where (0,0) would be in the exact middle of the screen, subject to some knob turning to set X/Y scale, X/Y offset, and possibly X/Y inversion.

The dedicated hardware of Atari "Asteroids" (1979) for example used a vector screen; it would be interesting to know what it thought its program coordinate system was.

Ivan Sutherland's "Sketchpad" system (1963) was based on a TX-2 vector display, and in "Sketchpad: A Man-Machine Graphical Communication System" (PhD thesis, January 1963), he writes on page 70ff:

The coordinate system of the TX-2 display system has origin at the center of the scope and requires ten bits of deflection information located at the left of 18 bit computer subwords for each axis.

...

For convenience in representing many component variables and for more than 18 bit precision, Sketchpad uses an internal coordinate system for drawing representation divorced from the representation required by the display system. This internal system is called the "page" coordinate system. In thinking of the drawings in Sketchpad, the page coordinates are considered as fixed. A page to scope transformation gives the ability to view on the scope any portion of the page desired, at any degree of magnification, as if through a magnifying glass (...) A scale factor for the display controls the size of the square which will appear on the scope. The actual number saved is the half-length of the side of the square, called SCSZ for SCope SiZe) as shown in Figure 5.2. Also saved are the page coordinates of the center of the scope square. By changing these numbers the portion of the page shown on the scope may be changed in size and moved, but not rotated.

Diagram 5.2 on page 73 shows that the "page coordinate system" uses the mathematical convention of the X/Y cartesian coordinate system. (One might ask why that convention is the way it is...)

  • but: vector screens were only used because memory was too rare to represent a whole displayable image and vector lists + presentation duration + connections needs much less memory (like polygons vs. voxels) – Micka Jul 28 at 7:28

Not everything is top-left.

OpenGL, for example, specifies that the origin is at bottom-left, and this is pervasive throughout the API: texture coordinates, viewports, texel rectangles, the standard ortho projection: it's bottom-left all the way.

There is a difference in thinking here.

On computer screens, as with books, when people read (and I'm assuming a language like English here) they read from left-to-right and top-to-bottom. You did it yourself when you wrote this question and you're doing it when you're reading answers to it.

In mathematics and design when you plot a graph, you have an X and a Y axis with positive X going left and positive Y going up.

If you're building something like a 2D GUI in a game it can be easier and more intuitive to many people to lay it out in a "top-left is the origin" manner.

If you're building something to mimic a design or layout on graph paper it can be easier and more intuitive to many people to lay it out in a "bottom-left is the origin" manner.

In fact both of these are quite informal conventions, and if you're setting up an ortho projection you can actually choose to have your origin at any arbitrary point on (or off) the screen, with positive X going either left or right and positive Y going either up or down. It's just a matter of adjusting your projection matrix accordingly.

The only important thing is therefore to choose which convention you're going to use and use it consistently.

Because screens start rendering the image from top left corner. It would be easier to co-relate the rendering or drawing of co-ordinate axis when (0,0,0) is at the top left corner with + Y-axis going into the screen.

An argument FOR: (By Example)

var R uint32 = 0xFF0000FF; //:Red pixel
var W uint32 = 0xFFFFFFFF; //:White Pixel.
var Pixels []uint32 = { 
W,W,W,R,R,W,W,W,
W,W,R,R,R,R,W,W,
W,R,R,R,R,R,R,R,
W,W,W,R,R,W,W,W,   //:8x8 pixel image of " ↑ "
W,W,W,R,R,W,W,W,
W,W,W,R,R,W,W,W,
W,W,W,R,R,W,W,W,
W,W,W,R,R,W,W,W, }

Code matches results on screen:

enter image description here

Red arrow would be upside-down if you did NOT use top-left origin.

I can't say if this is "why". Just that, it's a good reason for top-left origin.

  • 2
    "Red arrow would be upside-down if you did NOT use top-left origin" Yeah, so? Do game developers write graphics via 2d arrays in code most of the time? – Alexandre Vaillancourt Mar 5 at 20:52
  • I can't speak for all game developers. I do: newgrounds.com/portal/view/706067 Adam Atomic does as well, from reading the source code of flixel. OpenGL and SFML libraries definitely do . OpenCL allows you to abstract the data-points into X/Y, ( get_global_id(dim) ) but the initial memory allocation is 1D. – J MADISON Mar 7 at 0:17

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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