[comp.lang.postscript] Non-orthogonal coordinates?

CXT105@psuvm.psu.edu (Christopher Tate) (05/11/91)

Is it possible, in PostScript, to set up a non-orthogonal coordinate
system (i.e. one in which the x and y axes are not oriented 90 degrees
from each other)?

-------
Christopher Tate                   |
                                   | "Idle lawyers tend to become politicians,
cxt105@psuvm.psu.edu               |    so there is a certain social value
{...}!psuvax1!psuvm.bitnet!cxt105  |          in keeping them busy."
cxt105@psuvm.bitnet                |

glenn@heaven.woodside.ca.us (Glenn Reid) (05/11/91)

Christopher Tate writes
> Is it possible, in PostScript, to set up a non-orthogonal coordinate
> system (i.e. one in which the x and y axes are not oriented 90 degrees
> from each other)?

Sure.  In order to get the one you want, you'll need to study the red
book pages on coordinate transformations.  The "concat" operator lets
you apply arbitrary two-dimensional transformations (including skew
transformations) to the coordinate system.  To illustrate this, here
is a sample program (comment out the "concat" line for orthogonal lines):

%!
[1 .5 .5 1 0 0] concat

100 100 moveto 200 0 rlineto stroke
100 100 moveto 0 200 rlineto stroke

the axes are not rectilinear.

--
 Glenn Reid				RightBrain Software
 glenn@heaven.woodside.ca.us		NeXT/PostScript developers
 ..{adobe,next}!heaven!glenn		415-326-2974 (NeXTfax 326-2977)

lee@leo (Bill Lee) (05/15/91)

In article <91130.171855CXT105@psuvm.psu.edu> Christopher Tate <CXT105@psuvm.psu.edu> writes:
>Is it possible, in PostScript, to set up a non-orthogonal coordinate
>system (i.e. one in which the x and y axes are not oriented 90 degrees
>from each other)?
>
>-------
>Christopher Tate                   |
>                                   | "Idle lawyers tend to become politicians,
>cxt105@psuvm.psu.edu               |    so there is a certain social value
>{...}!psuvax1!psuvm.bitnet!cxt105  |          in keeping them busy."
>cxt105@psuvm.bitnet                |

Yes. Here's a little routine that does just what you suggest.

Bill Lee		lee@shell.com
Shell Oil Co.

-------------------------cut here-------------------------------------------
%* _________________________ Oblique __________________________________________
%* Procedure to modify the (normally) rectangular coordinate system of the
%* page to a non-right angle. When used, all x and y dimensions are
%* measured parallel to the new x and y axese. This results in squares
%* becoming parallelograms, circles becoming ellipses, etc. It also means that
%* moving off into the page will often run off the edge of the paper, so
%* be careful of the positining on the page.
%*
%*	angle Oblique
%*		where angle is the off-vertical of the Y axis in degrees.
%*		A positive angle is clockwise rotation of the Y axis 
%*		relative to existing axis.

/Oblique {
  /angle exch def
  [ 1 0 angle sin angle cos 0 0 ] concat
  } def