5

As you likely know, in c#, the origin (0,0) of a plane is the upperleft corner. Going to the right and/or under is regarded as +, while going to the left and/or up is -. Opposed to this is the regular math coordsystem:

(0,0)=mid of plane, going up/right = +, down/left = -.

It's kinda counter-intuitive and can be annoying sometimes, since we're used (for years) to using the regular math coords, and you have to recalculate coords as well.

Is this a fundamental design flaw? And do you get used to it after a while? And which other languages use a different coord system like c#?

user2864740
  • 60,010
  • 15
  • 145
  • 220
carrotcake
  • 97
  • 1
  • 5

3 Answers3

9

It is not C# but the display that uses a inverse coordinate system, this comes from the days back when the display was drawn in using a CRT and the image was drawn in top to bottom, left to right. That is why the coordinate system OS's use match that.

Languages like C# are just wrapping the underlying OS's API and that is why C# uses it too.

Scott Chamberlain
  • 124,994
  • 33
  • 282
  • 431
  • Had the same answer almost word for word but you beat me to it :) – DavidG Jul 19 '15 at 03:21
  • CRTs could have swept bottom to top just as easily -- the origin of the top to bottom numbering system is line numbers on a page of text. – Ben Voigt Jul 19 '15 at 03:35
  • @BenVoigt Maybe, maybe not. I was under the impression it was because VGA defined its data stream as top down. – Scott Chamberlain Jul 19 '15 at 03:46
  • I think it goes back even earlier than CRTs, to line printers, essentially automated typewriters. They printed in page-reading order, from left to right then from top to bottom. CRTs inherited their coordinate system, and from there so did many applications. – Edward Doolittle Jul 19 '15 at 04:03
  • @EdwardDoolittle: Exactly. – Ben Voigt Jul 19 '15 at 04:10
  • @ScottChamberlain: VGA was a late comer to the world of computer displays. – Ben Voigt Jul 19 '15 at 04:11
  • 1
    Early display output (CGA, VGA, whatever) were effectively just 'bitmaps' onto some prespecified memory region. When viewing these regions (and after being exposed as such) as simple 2D arrays a top-left origin and ascending x/y make sense wrt pixel/cell indexing. – user2864740 Jul 19 '15 at 04:13
  • @user2864740 Thats what I was trying to convey with my last comment. – Scott Chamberlain Jul 19 '15 at 16:30
1

The mathematical graph plane is a virtual thing, which expands in all directions without limits.

The screen is a real thing, which can not really expand at all.

Instead we use the concept of scrolling and we are used to doing it from a starting point down.

So conceptually the graphics systems all use the same system as a (left-to-right & top-to-bottom) textblock or page in a book . It is about how we scroll to expand/advance the display area.

But it could be defined in any other way; after all e.g. negative coordinates do make sense as opposed to a negative line number..

TaW
  • 53,122
  • 8
  • 69
  • 111
0

If you don't like the coordinate system on the screen, you can create wrapper methods to re-map the coordinates any way you like.

Edward Doolittle
  • 4,002
  • 2
  • 14
  • 27