Historic reasons for Left-Handed Coordinate System
Asked Answered
H

5

7

I find it a bit non-intuitive that the (0,0) maps to the left-top of the screen. Is there a historic reason for using a left-handed coordinate system in Java Swing?

While mapping this to a right-handed system is not too difficult, I'm curious to know if there is any hidden benefit in having a left-handed system.

Hydrocephalus answered 14/7, 2011 at 19:24 Comment(1)
Not every system is using this system, BTW. PostScript and therefor NeXT and today Mac OS X use (0,0) in the lower left.Backstay
B
9

According to “Why is the origin at the upper left corner?” by Raymond Chen that's simply because that's the way it always was with television sets (which hasn't changed, BTW). So it seems that this early design decision still has an impact today.

Early home computers often were connected to the TV, so naturally they used this coordinate system. I guess a lot of monitors worked the same way simply because the manufacturers could partly recycle electronics/logic. And since this was then the "natural" coordinate system which programmers used (remember, we had to access the video system on a much lower level back then) it simply stuck as most people were used to it.

The exception to this model is PostScript and it successor, PDF. They model a paper and therefor weren't tied to use the screen's coordinate system for efficiency. They use (0,0) in the lower left, like mathematicians usually do. The NeXT used a video system called Display PostScript which is an extension to PostScript for drawing on-screen and thus used PostScripts system with (0,0) in the lower left. Todays Mac OS X derived from NeXT and thus also uses this system. On iOS, the Apple engineers decided to flip the system to the more common model with (0,0) in the upper left to make it easier for developers migrating from others systems.

Backstay answered 14/7, 2011 at 19:38 Comment(2)
Sadly I can't seem to find the article link...Prevocalic
@hiroga: I found its new location and named the link according to the article's title so we can find it more easily should it move again.Backstay
U
7

I don't know any historical reason for it, but I think it actually makes sense. Or, rather, it makes sense given that we are in a culture that reads left to right and top to bottom.

Take a look, for example, at a web page--it extends to the right and downwards, so you never really know exactly where the bottom left-hands corner (for example) will be. On the other hand, if you take the top left-hand corner to be the origin, it will always be in the same place when you open page and you will never have to deal with negative numbers.

As such, it is my theory that the placement of the origin in the top left-hand corner is a product of the way we read.

Upbuild answered 14/7, 2011 at 19:35 Comment(0)
C
4

Historically, TV pictures and fax machines scan from left-to-right, top-to-bottom. It's probably because most written languages are written that way, so if you're going to choose a scan direction, it's not surprising that people would choose to scan the same way.

Most written languages are left-to-right because most people are right-handed and there's less chance of smudging the ink of what you've already written.

Custodial answered 14/7, 2011 at 19:38 Comment(0)
S
3

It's arbitrary; GL, for example, puts (0, 0) at the bottom-left. In Java the relevant transformation is

protected void paintComponent(Graphics g) {
    super.paintComponent(g);
    Graphics2D g2d = (Graphics2D) g;
    ....
    AffineTransform at = g2d.getTransform();
    g2d.scale(1, -1);
    ...
    g2d.setTransform(at);
}
Systematics answered 14/7, 2011 at 19:29 Comment(3)
There's a related example here.Systematics
Thanks. I see your point about the transformation. However I'm wondering why the initial designers chose to keep it that way. Maybe there was a hidden benefit or a limitation they were trying to address?Hydrocephalus
I'm sure there was a bias toward Cartesian coordinates, but affine geometry is more general.Systematics
S
3

after doing some research, I could find nothing but statements that point out that in previous computers systems, the 0,0 was always the left upper corner, 'cause it's where one would begin writing.

And, as the text would continue to flow, it would go to the bottom, increasing the line number.

Some system have a convention to being like the cartesian plane: 0,0 is in the left, bottom. In general, drawing programs do that, because you would, in general, draw from that position.

Shephard answered 14/7, 2011 at 19:36 Comment(1)
I've actually used drawing programs that are even more mathematical--the origin is in the middle. Personally, I found this more confusing than having it at either corner, but people with no programming experience seemed to find it more intuitive.Upbuild

© 2022 - 2024 — McMap. All rights reserved.