Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why does software often use an inverse coordinate system compared to regular math coord system?

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#?

like image 404
carrotcake Avatar asked Jul 19 '15 03:07

carrotcake


2 Answers

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.

like image 153
Scott Chamberlain Avatar answered Sep 30 '22 08:09

Scott Chamberlain


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..

like image 34
TaW Avatar answered Sep 30 '22 08:09

TaW