[net.graphics] Y positive up or down?

bonham@calgary.UUCP (10/24/86)

We at the University of Calgary are implementing a graphics utility
as part of a larger project.  The utility is to support raster, vector
and text-oriented displays in 2-D.  The subject of picking a coordinate
system origin has come up.  Several designers propose putting pixel
<0,0> at the top left of the screen, with Y increasing downward;
others propose putting it at the bottom left, with Y increasing upward.

Both have advantages and disadvantages.  We think it a hard enough
and interesting enough philosophical question to put it to the net:
Should positive values represent upward or downward Y increments?

One advantage of a lower-left origin is that the coordinate system
is the familiar Cartesian space we learned our geometry with.
Using an upper-left origin means inverting our notion of up/down.

An upper-left origin seems better suited to text operations.
Homing to the top left of the screen (or window) is done much more often
than homing to the bottom left.  The address of the upper left corner
would be a constant <0,0> rather than change for different-sized windows.
We want to use a single coordinate system for drawing text-, vector-
and area-oriented graphics.

An upper left origin is more of a standard in display hardware,
due to the top-to-bottom/left-to-right scanning of raster lines
and the consecutive ordering in display memory of each line's bits.
This is a bit of a non-issue, as the primitive drawing routines can
adapt to negative scan line increments regardless of which high-level
coordinate system we adopt.

Has anyone had experience doing geometry/trigonometry programming
in an inverted (Y-positive-down) coordinate system?
Was it hard adjusting to it?

What ramifications does a normal (Y-positive-up) coordinate system
have on text processing?  On implementation with standard hardware?

Reply by email if these are old questions (with answers!), otherwise
I would like to see a discussion on the net.
-- 
    _|_    __/__
   __+__    /_	         Mike Bonham
    /__    |__|
   /\./     /|     ..!{ubc-vision,ihnp4}!alberta!calgary!bonham
   _/ \_  _/ |_|

majka@ubc-cs.UUCP (10/24/86)

I went through this debate with several users as I was implementing a set of
graphics utilities such as you mention.  I was gung-ho on Row-Column coordinate
systems (origin upper left, first coordinate increasing down).  Some users
concurred but others argued for cartesian X-Y spaces.  In the end I decided on
the philosophy of flexibility:

  Let The Users Choose The Coordinate System That They Are Happy Working With.

This solution caused me to do a bit more work in writing the coordinate 
transformation routines, but it was well worth the small amount of effort.
The users just begins with a specification of the coordinate space they want.
In fact, they can change to a new coordinate system anytime.  This can be very
handy if you are working with a mixed display.  For instance where you want to
do some x-y plotting, and add a lot of text annotation.

There are always some cases where you will want to work in different coordinate
systems.  You may want the origin anywhere on the display.  You may want the
coordinates to run in either direction.  It is not hard to let the utility do a
bit more work for you.  After all, computers should make life *easier* for
people!

---
Marc Majka  -  UBC Laboratory for Computational Vision

mink@cfa.harvard.edu (Doug Mink) (10/26/86)

In article <469@vaxb.calgary.UUCP>, bonham@calgary.UUCP writes:
> and text-oriented displays in 2-D.  The subject of picking a coordinate
> system origin has come up.  Several designers propose putting pixel
> <0,0> at the top left of the screen, with Y increasing downward;
> others propose putting it at the bottom left, with Y increasing upward.
> 
> Both have advantages and disadvantages.  We think it a hard enough
> and interesting enough philosophical question to put it to the net:
> Should positive values represent upward or downward Y increments?

As an applications programmer, I find it much easier to conceptualize a display
in standard, bottom-left origin coordinates because that is what the equations
before the programs assume.  A display holds far more bytes of graphics than of
text, and all of those bytes have to be processed by the display driver.  If
your system is going to be used for interactive graphics a significant amount
of the time, any speed you gain will be important.

When I wrote the Tektronix emulator part of xterm, the X Windo System's
terminal emulator, I had to handle the translation from bottom-left (Tek) to
Top-left (X).  It's not difficult; it just adds one more operation to every
point plotted.
				Doug Mink
				cfa.harvard.edu
				{ihnp4|seismo}!harvard!cfa!mink

bonham@calgary.UUCP (10/28/86)

Thanks to all net.graphics readers responding with opinions
on the relative merits of putting the coordinate origin for an
integrated 2-D text and graphics support system at the top left
versus the bottom left of the screen.

The consensus so far is overwhelmingly in favour of the normal
Cartesian coordinate system with <0,0> at bottom left.

However, there must be *some* reason Sun, and many other window
system developers, chose the upper left with Y increasing downward.
Perhaps it is because their systems were intended primarily for ease
in programming text  displays.  Most typesetting / page description
languages use the inverted, Y-positive-down coordinate system.

To obtain perhaps a wider representation of views, I am posting
my original message to net.text and net.cog-eng and am inviting
further discussion in all three newsgroups.  Thank you.
-- 
    _|_    __/__
   __+__    /_	         Mike Bonham
    /__    |__|
   /\./     /|     ..!{ubc-vision,ihnp4}!alberta!calgary!bonham
   _/ \_  _/ |_|

andrea@hp-sdd.HP.COM (Andrea K. Frankel) (10/28/86)

We debated this question in the context of graphics standards
(GKS, CGM, CGI), and came to the conclusion that it was best to
permit the client (i.e., the program or person using the system)
to SET the coordinate space, both to establish scaling and to
establish orientation.  In CGM and CGI this is done with the
"VDC EXTENT" function (VDC = Virtual Device Coordinates, the
space thus specified).

The default coordinate system for the graphics standards is always
first quadrant (i.e., (0,0) in lower left).

There are some nontrivial ramifications for changing; for example,
some circular arcs are specified in terms of a center point and
two rays, and the arc is drawn counter-clockwise from the first
to the second.  Now, what defines counter-clockwise?  The resolution
was "from the positive x-axis of VDC space to the positive y-axis
of VDC space".  Draw yourself some pictures, and you might be surprised
at what happens to arc specifications if the specifier assumes
counter-clockwise means "as I look at the screen" and the VDC space
is fourth-quadrant!


Andrea Frankel, Hewlett-Packard (San Diego Division) (619) 592-4664
 "every time that wheel goes round, bound to cover just a little more ground"
______________________________________________________________________________
UUCP  : {hplabs|hp-pcd|hpfcla|hpda|noscvax|gould9|sdcsvax}!hp-sdd!andrea
UUCP  : {cbosgd|allegra|decvax|gatech|sun|tektronix}!hplabs!hp-sdd!andrea
ARPA  : hp-sdd!andrea@nosc.arpa
CSNET : hp-sdd!andrea@hplabs.csnet
USnail: 16399 W. Bernardo Drive, San Diego CA 92127-1899 USA

henry@utzoo.UUCP (Henry Spencer) (10/29/86)

The Blit terminals at Bell Labs use Y-positive-down.  One of the things
those folks have said in discussing their software is that if they were
doing it over again, they would seriously consider changing this.  (Don't
remember the exact words, but that was the sense of it.)
-- 
				Henry Spencer @ U of Toronto Zoology
				{allegra,ihnp4,decvax,pyramid}!utzoo!henry

gwyn@brl-smoke.ARPA (Doug Gwyn ) (11/03/86)

In article <478@vaxb.calgary.UUCP> bonham@calgary.UUCP writes:
>However, there must be *some* reason Sun, and many other window
>system developers, chose the upper left with Y increasing downward.
>Perhaps it is because their systems were intended primarily for ease
>in programming text  displays.  Most typesetting / page description
>languages use the inverted, Y-positive-down coordinate system.

So far as adopting a convention goes, it really doesn't matter,
so you might as well provide programmers etc. with one that
follows mathematical/engineering conventions (1st-quadrant).
Whether this is appropriate for an end-user depends a lot on
what the user's background is.

HOWEVER, the order that bits are stored in a file DOES matter;
there are observable consequences, such as the order in which
an image is "painted" on the display.  It should be obvious
why text-oriented systems store the bits near the top of the
image first, and consequently tend to adopt 4th-quadrant address
conventions.  I also think that it's aesthetically more pleasing
for graphic images to roll onto the display from top to bottom,
but not everyone agrees with this.

Image storage order and coordinate conventions have only a loose
connection and can be chosen independently if desired.

Henry stated that the Blit was 4th-quadrant; I believe the Blit
was originally 1st-quadrant, changed to 4th-quadrant for the DMD
(which is NOT a Blit!).  There is evidence for this in some of
the older DMD software.

henry@utzoo.UUCP (Henry Spencer) (11/06/86)

> Henry stated that the Blit was 4th-quadrant; I believe the Blit
> was originally 1st-quadrant, changed to 4th-quadrant for the DMD
> (which is NOT a Blit!).  There is evidence for this in some of
> the older DMD software.

Tsk, tsk, Doug, obviously reading all the DMD software has affected your
mind!  :-)  To quote from "Hardware/Software Trade-offs for Bitmap Graphics
on the Blit", Pike/Locanthi/Reiser, Software-Practice&Experience Feb 1985:

" ... (The Teletype DMD 5620 is a commercial product based on the Blit,
but this paper is about the Blit itself.) ...  All bitmaps share a single
coordinate space, with (0,0) in the upper left.  (The orientation of the
y-axis is one thing we might change were we to do it again.)"
-- 
				Henry Spencer @ U of Toronto Zoology
				{allegra,ihnp4,decvax,pyramid}!utzoo!henry

gwyn@brl-smoke.ARPA (Doug Gwyn ) (11/08/86)

In article <7291@utzoo.UUCP> henry@utzoo.UUCP (Henry Spencer) writes:
>To quote from "Hardware/Software Trade-offs for Bitmap Graphics
>on the Blit", Pike/Locanthi/Reiser, Software-Practice&Experience Feb 1985:
>
>" ... All bitmaps share a single
>coordinate space, with (0,0) in the upper left. ... "

Ah, but in the ACM TOG, Apr 1983 Rob used 1st-quadrant.  It is worth
noting that almost all the algorithms are independent of this convention.
(Exercise:  Find the one that isn't.)

Note that I'm not arguing which is BETTER, since I've already pointed out
that that should be decided on the basis of observable consequences at
the user interface.  In my corner of the world, text-oriented stuff
should appear from left-to-right, top-down.  This argues fairly strongly
for at least STORING raster information in that order, but it has
somewhat less impact on the design of raster software/hardware internals.