[comp.windows.news] Is "transform" in NeWS 1.1 OK ?

ronb@natmlab.dms.oz (Ron Baxter) (01/24/89)

	The following session with psh puzzles me and I wonder
	what I am missing.

		executive
		Welcome to NeWS Version 1.1
		matrix currentmatrix pstack
		[1 0 0 1 0 0] 
		clear 100 200 transform pstack
		100 700 
		clear -20 -40 transform pstack
		-20 940 
		clear 50 70 itransform pstack
		50 830 

	Since the CTM is an identity matrix I would have expected
	transform, itransform, etc to make no change to x and y.
	The LaserWriter behaves as I expected, so is this a NeWS 1.1
	funny?
-- 
____           ____           Ron Baxter, CSIRO Div Maths & Stats,
 |  } /\ |\ |   |  }          PO Box 218, Lindfield, NSW, Australia.
 |-< {  }|\\|   |-<           Phone:	+61 2 467 6059		
 |  \ \/ | \|  _|__}          Email:	ronb@natmlab.oz.au
D

don@BRILLIG.UMD.EDU (Don Hopkins) (01/26/89)

The reason transform is giving unexpected results is that it takes
into account the height of the canvas you're on, flipping the
y-coordinate to pixrect "device" coordinates. The pixrect origin is
the upper left corner, while the default NeWS origin is the lower
left. This is a pain, and probably the reason why the matrix args to
transform, scale, etc, are not implemented. A transformation matrix
for one canvas will not work the same on a another canvas of a
different height, because there is this implicit transformation and y
scale flip. 

I've recently run into a bug with setting the /XLocation and
/YLocation fields of events. When I am on a canvas other than the
frame buffer, and I set them to some value, then immediatly read them
back, THEY'RE DIFFERENT!! To correctly set the event coordinates to a
position relative to my canvas, I have to setcanvas to the frame
buffer, manually subtract my canvas's offset from the lower left
corner of the framebuffer from my coordinates, and THEN def the
/XLocation and /YLocation fields.

I think my problem is also related to the pixrect origin -vs-
PostScript origin problem. Pixrects are *EVIL*.

	-Don

liam@cs.qmc.ac.uk (William Roberts) (01/30/89)

The problem stems from a mistaken belief that the default CTM
should have 0 0 at bottom left and y increasing up the page.
Sun turned themselves inside out to make this true for
pixrects, which have 0 0 as top left and y increasing down the
page. If they hadn't done that then an awful lot of current
faults (e.g. movecanvas) would not be there...
-- 

William Roberts         ARPA: liam@cs.qmc.ac.uk  (gw: cs.ucl.edu)
Queen Mary College      UUCP: liam@qmc-cs.UUCP
LONDON, UK              Tel:  01-975 5250

msc@ramoth.SGI.COM (Mark Callow) (01/31/89)

In article <4495@natmlab.dms.oz>, ronb@natmlab.dms.oz (Ron Baxter) writes:
> 
> 	The following session with psh puzzles me and I wonder
> 	what I am missing.
> 
> 		executive
> 		Welcome to NeWS Version 1.1
> 		matrix currentmatrix pstack
> 		[1 0 0 1 0 0] 
The preceding line does nothing since the next thing you do is clear the
stack
> 		clear 100 200 transform pstack
> 		100 700 
> 		clear -20 -40 transform pstack
> 		-20 940 
> 		clear 50 70 itransform pstack
> 		50 830 
> 
> 	Since the CTM is an identity matrix I would have expected
> 	transform, itransform, etc to make no change to x and y.
> 	The LaserWriter behaves as I expected, so is this a NeWS 1.1
> 	funny?
The default CTM isn't the identity matrix.  It is the default matrix that
gives the user a coordinate system with a lower left origin and 72 units to
the inch on the output device.  Sun ignores the 72/inch requirement but
they do use the matrix to invert to get an upper left origin hence the
result you see.

N.B., If you had used the 3 operand transform

	100 200 [1 0 0 1 0 0] transform

on your Sun you would have got a typecheck error.  The 3 operand form isn't
implemented.  I recently implemented it on the Iris and it will be in our
next release.
--
	-Mark

sjs@spectral.ctt.bellcore.com (Stan Switzer) (01/31/89)

Never make any assumptions about the device coordinates.

You might feel justified in expecting the default matrix to have the
form "[ n 0 0 -n 0 0 ]" because that is the way most framebuffers
(printers and screens alike) are laid out, but you'd be wrong.

I got a rude awakening one day when I discovered that a certain
printer's default matrix had the form "[ 0 n -n 0 0 0 ]".  This seemed
pretty wierd to me until I realized that the paper fed through the
printer sideways, right edge first.

In fact, if you were driving a wide aspect-ratio screen you might want
to turn the thing sideways and change the default matrix rather than
the modifying the beam scan pattern or framebuffer layout (but expect
people to scream when they try to hook up a projector).

Stan Switzer  sjs@ctt.belllcore.com
    "NeWS -- the windowing system for the other half of your brain."
      		 -- Don Hopkins