% - the basic procedures --------------------------- % works in default page coordintes on a page of 8.5'' x 11'' % A B C on stack ==> line Ax + By + C = 0 /make-line-default { 8 dict begin /C exch def /B exch def /A exch def A abs B abs le { % left to right /x 0 def /y C neg A x mul sub B div def x y moveto /x 72 8.5 mul def /y C neg A x mul sub B div def x y lineto } { % bottom to top /y 0 def /x C neg B y mul sub A div def x y moveto /y 11 72 mul def /x C neg B y mul sub A div def x y lineto } ifelse end } def % ---------------------------------------------- % returns the matrix (an array of 6 elements) % describing user to page coordinate transformation /user-to-page-matrix { matrix currentmatrix matrix defaultmatrix matrix invertmatrix matrix concatmatrix } def % ---------------------------------------------- % M A B C on stack % returns A* B* C* for the new coordinate system % described by the transformation matrix M % [A* B* C*] = [A B C] M % if M is put in 3 x 3 form /transform-line { 8 dict begin /C exch def /B exch def /A exch def /M exch def /Minv M matrix invertmatrix def A Minv 0 get mul B Minv 1 get mul add A Minv 2 get mul B Minv 3 get mul add A Minv 4 get mul B Minv 5 get mul add C add end } def % builds the visible part of the line Ax + By + C = 0 on % a page, no matter what the user coordinate system is /make-line { 8 dict begin /C exch def /B exch def /A exch def % revert temporarily to the default CTM /ctm matrix currentmatrix def user-to-page-matrix matrix defaultmatrix setmatrix A B C transform-line make-line-default ctm setmatrix end } def % - sample usage ----------------------------------------- false { 72 72 scale 0.012 setlinewidth 4.25 5.5 translate newpath 0 1 0 make-line stroke newpath 0 1 -1 make-line stroke newpath 1 0 0 make-line stroke newpath 1 0 -1 make-line stroke newpath 1 1 -1 make-line stroke } if