Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why are graphics coordinates measured from the upper left?

I have noticed that every computer graphics system I have ever used uses a left-handed coordinate system with its origin in the upper left corner. Cairo, Java, Microsoft XYZ, and most graphics programs all use this system. I assume they all date back to a common ancestor, but I can't find any references about this.

If I had to guess I'd say it came from VGA graphics mode, using the same coordinates as text, which were naturally based on how the English language is read top-down, left-right, with the "second line" below the "first line"... but I'm making that up.

Was anyone around to tell the tale, or can point me in the direction of the correct history book?

like image 922
zebediah49 Avatar asked Oct 23 '12 19:10

zebediah49


People also ask

Where is the origin of the screen coordinate system?

The system and applications specify the position of a window on the screen in screen coordinates. For screen coordinates, the origin is the upper-left corner of the screen.

How do you read pixel coordinates?

In terms of coordinates, a pixel can be identified by a pair of integers giving the column number and the row number. For example, the pixel with coordinates (3,5) would lie in column number 3 and row number 5. Conventionally, columns are numbered from left to right, starting with zero.

What is coordinate in graphics?

17.2 Coordinates for Graphics Most device coordinate systems are defined in terms of pixels, and usually the upper-left-hand corner is the origin of the coordinate system, with x coordinates increasing to the right and y coordinates increasing downwards.


2 Answers

It's an old convention, and the reasons might be a bit apocryphal. Here are some hypotheses I've found:

It's derived from CRT electron beam sweep behavior.

Scanning from top to bottom means you don't have to wait for an entire frame to be sent first, you just begin scanning as soon as you begin receiving data. (Which raises the question again, why scan from top to bottom)

It allows a right-handed coordinate system with the Z axis going into the screen rather than coming out of it.

Annoyingly, Cocoa and Quartz use lower-left origin.

like image 66
smcg Avatar answered Oct 06 '22 10:10

smcg


I doubt that is an old convention that is kept due to legacy reasons. UpperLeft has the advantage, that is no language writing system that goes from bottom to up. So in UpperLeft is easier:

  • To place multiline text
  • Work with pages of unknown or infinite height
  • If the page height is changed (ie bigger or smaller device), in BottomLeft you have to translate every object coordinate, while in UpperLeft you don't.

The last one extends also to dynamic placement and layouts, where a graphics object's coordinates are offsets to their parent

like image 27
Panos Theof Avatar answered Oct 06 '22 09:10

Panos Theof