Article View: comp.lang.postscript
Article #2149invertmatrix (was: Optical Illusion)
From: Don Hopkins
Date: Wed, 02 May 1990 23:19
Date: Wed, 02 May 1990 23:19
55 lines
2726 bytes
2726 bytes
In article <5903@amelia.nas.nasa.gov> izen@amelia.nas.nasa.gov (Prof. Steven H. Izen) writes:
>For those of you who have been trying to run escher.ps on NeWS on SGI
>machines and have been having trouble, the problem is that 4sight 1.4
>doesn't implement invertmatrix, so the ps program bombs when it isused.
>
>If anyone wants to implement a version of invertmatrix for us SGI users,
>please post it.
>--
>Steve Izen: {sun,uunet}!cwjcc!skybridge!izen386!steve / Quote corner:
>or steve@izen386.math.cwru.edu /
>or izen@cwru.cwru.edu /-------------------------/ My second bike is a car.
> | Klein bottle for sale - Inquire within.
Here is an implementation of "invertmatrix" written by Greg Couch.
It's included in the collection of free NeWS software available via
anonymous ftp from tumtum.cs.umd.edu (128.8.128.49).
-Don
%!
% Date: Wed, 5 Apr 89 21:22:16 EDT
% To: NeWS-makers@brillig.umd.edu
% Subject: invertmatrix code supplied
% From: gregc@cgl.ucsf.edu (Greg Couch)
%
% The following is PostScript source for the invertmatrix operator that
% NeWS left out for some stupid reason. It even fails in the same ways
% as the real PostScript version. Enjoy...
%
% The following is an implementation of the PostScript invertmatrix for NeWS.
% No copyright allowed. Greg Couch, UCSF Computer Graphic Lab, April 1989
%
% [ a b c d x y ] ->
% [ d -b -c a (cy - dx) -(ay - bx) ] / (ad - bc)
systemdict /invertmatrix known not {
systemdict
/invertmatrix { % matrix1 matrix2 invertmatrix matrix2
7 dict begin
exch aload pop % m2 a b c d x y
/y exch def /x exch def % m2 a b c d
/d exch def /c exch def % m2 a b
/b exch def /a exch def % m2
/t a d mul b c mul sub def % t = ad - bc
d t div % m2 a2
b neg t div % m2 a2 b2
c neg t div % m2 a2 b2 c2
a t div % m2 a2 b2 c2 d2
c y mul d x mul sub t div % m2 a2 b2 c2 d2 x2
b x mul a y mul sub t div % m2 a2 b2 c2 d2 x2 y2
7 -1 roll % a2 b2 c2 d2 x2 y2 m2
astore % m2
end
} put
} if
Technical Details
Message-ID:
<24133@mimsy.umd.edu>Path:
arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!clyde.concordia.ca!uunet!tut.cis.ohio-state.edu!purdue!haven!mimsy!brillig.umd.edu!donReferences:
<@tfd.UUCP> <5903@amelia.nas.nasa.gov>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!clyde.concordia.ca!uunet!tut.cis.ohio-state.edu!purdue!haven!mimsy!brillig.umd.edu!don From: don@brillig.umd.edu (Don Hopkins) Newsgroups: comp.lang.postscript Subject: invertmatrix (was: Optical Illusion) Summary: PostScript source code: invertmatrix.ps Keywords: invertmatrix, NeWS Message-ID: <24133@mimsy.umd.edu> Date: 2 May 90 23:19:34 GMT References: <@tfd.UUCP> <5903@amelia.nas.nasa.gov> Sender: news@mimsy.umd.edu Reply-To: don@brillig.umd.edu (Don Hopkins) Organization: U of Maryland, Dept. of Computer Science, Coll. Pk., MD 20742 Lines: 55