Why are graphics coordinates measured from the upper left?
Asked Answered
I

4

9

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?

Ingold answered 23/10, 2012 at 19:54 Comment(2)
duplicate of #5307454Padriac
Gah, I guess that answer didn't show up when I searched because it was labelled Java specific.Ingold
F
4

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.

Fret answered 23/10, 2012 at 20:6 Comment(2)
Interesting, the analogue TV background didn't occur to me. Two-dimensional coordinate convention is to have Z out, but it is true that that does work for "fixing it". It's always fun developing math on paper normally, and then having it flip once programmed.Ingold
Exactly. CRT's standardized on drawing top-down, left-to-right, so video hardware standardized the screen buffer layout in the same order as it is drawn.Snore
L
1

No idea. I don't think there is a definitive answer. It's likely that when people still had console based machines it made sense to go from the top left corner down to the bottom right. It's how a lot of people in the world read, as you've said. It makes sense to put the origin there.

http://en.wikipedia.org/wiki/Memory-mapped_I/O

The wikipedia article has some information about memory mapped displays. Say for example we dedicate a part of our memory to turning off and on pixels on the screen. And we let address 0 be the upper left hand part of the screen and move over in chunks turning on and off pixels depending on if they're in the memory. That's basically what the first article is saying.

I don't know if they let address 0 be the upper left hand side of a display but it makes sense and it might have just carried over.

Libido answered 23/10, 2012 at 20:31 Comment(0)
H
1

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

Hirundine answered 15/11, 2015 at 18:57 Comment(0)
K
1

I was also wondering about the same question. Here is another source:

The origin is always in the upper left. And that comes from the fact that, kind of TVs when they're first built, scan from left to right and then top to bottom. So it doesn't work he same way you saw kind of at high school geometry where the origin wasn't always in the lower left....

An Introduction to Interactive Programming in Python

Karachi answered 5/1, 2019 at 22:27 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.