%! /intersection { 1 dict begin /L exch def /A L 0 get def /B L 1 get def /C L 2 get def /f00 A -1 mul B -1 mul add C add def /f10 A 1 mul B -1 mul add C add def /f11 A 1 mul B 1 mul add C add def /f01 A -1 mul B 1 mul add C add def % f01 f11 % f00 f10 [ f00 f10 mul 0 lt { /t f00 f00 f10 sub div def /s 1 t sub def % (1-t)(00) + t(10) [ -1 s mul 1 t mul add -1 ] } if f10 0 eq { [1 -1] } if f10 f11 mul 0 lt { /t f10 f10 f11 sub div def /s 1 t sub def [ 1 -1 s mul 1 t mul add ] } if f11 0 eq { [1 1] } if f11 f01 mul 0 lt { /t f11 f11 f01 sub div def /s 1 t sub def [ 1 s mul -1 t mul add 1 ] } if f01 0 eq { [-1 1] } if f01 f00 mul 0 lt { /t f01 f01 f00 sub div def /s 1 t sub def [ -1 1 s mul -1 t mul add ] } if f00 0 eq { [-1 -1] } if ] end } def % --- sample usage --------------------------------------- /S 72 def S dup scale 1 S div setlinewidth 4.25 5.5 translate newpath -1 -1 moveto 1 -1 lineto 1 1 lineto -1 1 lineto closepath stroke /I [3 -1 2] intersection def I length 2 eq { newpath I 0 get 0 get I 0 get 1 get moveto I 1 get 0 get I 1 get 1 get lineto stroke } if