%!PS-Adobe-3.0 EPSF-3.0 %%BoundingBox: 0 0 762 532 %%Creator: Gernot Hoffmann %%Title: CubePlane00 %%CreationDate: November 13/2006 % Disable setpagedevice /setpagedevice {pop} bind def % Intersection of a unit cube and an infinite plane /Typ 0 def /mm {2.834646 mul} def /sc 100 mm def /bx 760 def /by 530 def /lw 0.5 mm sc div def /x0 90 mm def % Center /y0 70 mm def /MatCam % Camera rotation matrix {/eps 1E-4 def /dx Px Vx sub def /dy Py Vy sub neg def /dz Pz Vz sub neg def /dr dx dup mul dy dup mul add sqrt def dx abs eps gt dy abs eps gt or {/Gam dx dy atan def } {/Gam 0 def } ifelse dz abs eps gt dr abs eps gt or {/Alf dz dr atan def } {/Alf 0 def } ifelse /ca Alf cos def /sa Alf sin def /cb Bet cos def /sb Bet sin def /cg Gam cos def /sg Gam sin def /c11 cb cg mul sa sb mul sg mul sub def /c12 cb sg mul sa sb mul cg mul add def /c13 ca sb mul neg def /c21 ca sg mul neg def /c22 ca cg mul def /c23 sa def /c31 sb cg mul sa cb mul sg mul add def /c32 sb sg mul sa cb mul cg mul sub def /c33 ca cb mul def /DD dx dup mul dy dup mul add dz dup mul add sqrt def } def /Transf {% Mod=Cam Camera projection % Map=Par Parallel % Map=Per Perspective % xf yf zf on the stack expected /zc exch Pz sub def /yc exch Py sub def /xc exch Px sub def /uc c11 xc mul c12 yc mul add c13 zc mul add def /wc c31 xc mul c32 yc mul add c33 zc mul add def Map (Par) eq {/fd uc def /hd wc def } if Map (Per) eq {/vc c21 xc mul c22 yc mul add c23 zc mul add def /fd uc vc div DD mul def /hd wc vc div DD mul def } if } def /Box { 0 0 0 1 setcmykcolor 1 setlinewidth newpath 1 1 moveto bx 0 rlineto 0 by rlineto bx neg 0 rlineto closepath stroke } def /Axes { 0 0 0 1 setcmykcolor lw setlinewidth newpath 0 0 0 Transf fd hd moveto 1.1 0 0 Transf fd hd lineto 0 0 0 Transf fd hd moveto 0 1.1 0 Transf fd hd lineto 0 0 0 Transf fd hd moveto 0 0 1.1 Transf fd hd lineto stroke 0 0 0 1 setcmykcolor /fh 18 sc div def /Helvetica findfont fh scalefont setfont 1.2 0 0 Transf fd hd moveto (x) show 0 1.2 0 Transf fd hd moveto (y) show 0 0 1.2 Transf fd hd moveto (z) show } def /MinDot {/hdd exch def /fdd exch def /rdd 0.8 mm sc div def newpath fdd hdd rdd 0 360 arc fill } def /MaxDot {/hdd exch def /fdd exch def /rdd 1.6 mm sc div def newpath fdd hdd rdd 0 360 arc fill } def /Dots { 0 1 1 0 setcmykcolor /kp 0 def 1 1 np { pop /xf pt kp get def /yf pt kp 1 add get def /zf pt kp 2 add get def xf yf zf Transf fd hd MaxDot /kp kp 3 add def } for 0.5 0 0 0.5 setcmykcolor sx sy sz Transf fd hd MinDot 0 1 1 0 setcmykcolor np 3 ge {mx my mz Transf fd hd MinDot} if sx abs 1.5 lt sy abs 1.5 lt and sz abs 1.5 lt and { % dashed lines [0.02 0.01] 0 setdash lw 0.7 mul setlinewidth 0 0 0 1 setcmykcolor newpath sx sy 0 Transf /fs fd def /hs hd def fs hs moveto sx 0 0 Transf fd hd lineto fs hs moveto 0 sy 0 Transf fd hd lineto fs hs moveto sx sy sz Transf fd hd lineto stroke [] 0 setdash } if } def /Dotp % c=A*B Matrix [ax ay az]*Matrix [bx by bz]-->c {/cbz exch def /cby exch def /cbx exch def /caz exch def /cay exch def /cax exch def /ccd cax cbx mul cay cby mul add caz cbz mul add def ccd } def /Shownum % Draw number by string % Version May 15 2004 / uses rounding % % tx0 ty0 num on stack % % tx0 Position not overwritten % ty0 % num Input number not overwritten nu =+-999999 % fh Font height not overwritten % tms Mantissa number of characters tms=0...6 Global % tms=3 Example % input -23.56789 -999.99 0.4567 9999.123456 % result -23.568 -999.990 0.467 9999.123 % Postscript number to string is not well defined % e.g. 1E-5 instead of 0.00001 % We use a straightforward BCD conversion. % This is always affected by round-off errors % because of 32-bit arithmetic % Results are different, depending on the interpreter { /num exch def /ty0 exch def /tx0 exch def /tfw fh 0.6 mul def % character distance /tna num abs 10 tms neg exp 0.500001 mul add def /tdec 1E5 def /tchr 1 string def tna 999999.1 lt % larger number replaced by # /tmm true def % sign {/tx0 tx0 tfw 6 mul sub def /tz 0 def 1 1 5 % first 5 digits, no leading 0 { pop /tk 0 def { tna tdec gt {/tna tna tdec sub def /tk tk 1 add def}{exit} ifelse } loop tk 0 ne {/tz tz 1 add def} if tz 0 ne { tx0 ty0 moveto tk tchr cvs show } if tz 1 eq num 0 lt and % minus { tx0 tfw 0.7 mul sub ty0 moveto (-) show /tmm false def } if /tdec tdec 0.1 mul def /tx0 tx0 tfw add def } for /tk 0 def % leading 0 { tna tdec gt {/tna tna tdec sub def /tk tk 1 add def}{exit} ifelse } loop tmm num 0 lt and % minus { tx0 tfw 0.7 mul sub ty0 moveto (-) show } if tx0 ty0 moveto tk tchr cvs show /tdec tdec 0.1 mul def /tx0 tx0 tfw add def tms 0 gt % for float { tx0 ty0 moveto (.) show /tx0 tx0 tfw 0.5 mul add def 1 1 tms { pop /tk 0 def { tna tdec gt {/tna tna tdec sub def /tk tk 1 add def}{exit} ifelse } loop tx0 ty0 moveto tk tchr cvs show /tdec tdec 0.1 mul def /tx0 tx0 tfw add def } for } if }{ tx0 tfw sub ty0 moveto (#) show} ifelse } def /LF {/ytxt ytxt fh sub def} def /List {/fh 16 def /Helvetica findfont fh scalefont setfont /tms 6 def /xtxt 230 mm def /ytxt 170 mm def /xtx1 200 mm def /xtx2 230 mm def xtx1 ytxt moveto (Camera pos.+ viewpoint) show LF LF xtx1 ytxt moveto (Px) show xtx2 ytxt Px Shownum LF xtx1 ytxt moveto (Py) show xtx2 ytxt Py Shownum LF xtx1 ytxt moveto (Pz) show xtx2 ytxt Pz Shownum LF LF xtx1 ytxt moveto (Vx) show xtx2 ytxt Vx Shownum LF xtx1 ytxt moveto (Vy) show xtx2 ytxt Vy Shownum LF xtx1 ytxt moveto (Vz) show xtx2 ytxt Vz Shownum LF LF xtx1 ytxt moveto (Plane point + normal) show LF LF xtx1 ytxt moveto (Sx) show xtx2 ytxt sx Shownum LF xtx1 ytxt moveto (Sy) show xtx2 ytxt sy Shownum LF xtx1 ytxt moveto (Sz) show xtx2 ytxt sz Shownum LF LF xtx1 ytxt moveto (nx) show xtx2 ytxt nxold Shownum LF xtx1 ytxt moveto (ny) show xtx2 ytxt nyold Shownum LF xtx1 ytxt moveto (nz) show xtx2 ytxt nzold Shownum LF LF xtx1 ytxt moveto (Mean of intersections) show LF LF xtx1 ytxt moveto (Mx) show xtx2 ytxt mx Shownum LF xtx1 ytxt moveto (My) show xtx2 ytxt my Shownum LF xtx1 ytxt moveto (Mz) show xtx2 ytxt mz Shownum LF LF xtx1 ytxt moveto (Intersections) show LF LF /tms 0 def xtx1 ytxt moveto (Np) show xtx2 ytxt np Shownum LF } def % Corners /cr [ 0 0 0 0 0 1 0 1 0 0 1 1 1 0 0 1 0 1 1 1 0 1 1 1 ] def % Edges /se [ 0 1 1 5 5 4 4 0 2 6 6 7 7 3 3 2 4 6 2 0 1 3 7 5 ] def % Points, up to 6 intersections /pt [ 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ] def /EdgeQRG {/no exch 2 mul def /se1 se no get def /se2 se no 1 add get def /cr1 se1 3 mul def /cr2 se2 3 mul def /qx cr cr1 get def /qy cr cr1 1 add get def /qz cr cr1 2 add get def /rx cr cr2 get def /ry cr cr2 1 add get def /rz cr cr2 2 add get def /gx rx qx sub def /gy ry qy sub def /gz rz qz sub def } def /EdgeDraw { 0 0 0 1 setcmykcolor lw 0.7 mul setlinewidth newpath 0 1 11 { EdgeQRG % uses no=0..11 qx qy qz Transf fd hd moveto rx ry rz Transf fd hd lineto } for stroke } def /FindPts { /nxold nx def /nyold ny def /nzold nz def /nn nx dup mul ny dup mul add nz dup mul add sqrt def /nx nx nn div def /ny ny nn div def /nz nz nn div def % CheckCorners /eps1 1e-8 def /eps2 eps1 20 mul def /kp 0 def /kc 0 def /mx 0 def /my 0 def /mz 0 def /np 0 def 1 1 8 { pop /xf cr kc get def /yf cr kc 1 add get def /zf cr kc 2 add get def /dis nx xf sx sub mul ny yf sy sub mul add nz zf sz sub mul add abs def dis eps1 lt {pt kp xf put pt kp 1 add yf put pt kp 2 add zf put /kp kp 3 add def /np np 1 add def /mx mx xf add def /my my yf add def /mz mz zf add def } if np 4 eq {exit} if /kc kc 3 add def } for % Check edges 0 1 11 { EdgeQRG /fx sx qx sub def /fy sy qy sub def /fz sz qz sub def /f nx ny nz fx fy fz Dotp def /g nx ny nz gx gy gz Dotp def /fnd false def g 0 gt { f 0 gt f g lt and {/fnd true def } if } if g 0 lt { f 0 lt f g gt and {/fnd true def } if } if fnd {/t f g div def /xf qx gx t mul add def /yf qy gy t mul add def /zf qz gz t mul add def % Skip double point /kj 0 def /skip false def 1 1 np {pop /xj pt kj get def /yj pt kj 1 add get def /zj pt kj 2 add get def /dis xf xj sub abs yf yj sub abs add zf zj sub abs add def dis eps2 lt {/skip true def exit} if /kj kj 3 add def } for skip not { pt kp xf put pt kp 1 add yf put pt kp 2 add zf put /kp kp 3 add def /np np 1 add def /mx mx xf add def /my my yf add def /mz mz zf add def } if } if np 6 eq {exit} if } for % Mean value /mx mx np div def /my my np div def /mz mz np div def % Sort by angle np 3 gt {/anx nx abs def /any ny abs def /anz nz abs def 1 { anx any ge anx anz ge and {PtSortYZ exit} if any anx ge any anz ge and {PtSortXZ exit} if anz anx ge anz any ge and {PtSortXY } if } repeat } if /kp 0 def lw setlinewidth newpath /xf pt kp get def /yf pt kp 1 add get def /zf pt kp 2 add get def xf yf zf Transf fd hd moveto /kp kp 3 add def 1 1 np 1 sub { pop /xf pt kp get def /yf pt kp 1 add get def /zf pt kp 2 add get def xf yf zf Transf fd hd lineto /kp kp 3 add def } for closepath np 3 ge { gsave 0.3 0 0 0.15 setcmykcolor fill grestore } if 1 0 0 0.5 setcmykcolor stroke } def % Sorting by angles: % Attention: PostScript versus C/C++ % /ang y x atan def delivers ang= 0..360 % ang = atan2(y,x) delivers ang=-pi..+pi /PtSortXY {/np1 np 1 sub def /i3 0 def /i1 1 def 1 1 np1 {pop /xfi pt i3 get def /yfi pt i3 1 add get def /ai yfi my sub xfi mx sub atan def /k3 i3 3 add def i1 1 np1 { pop /xfk pt k3 get def /yfk pt k3 1 add get def /ak yfk my sub xfk mx sub atan def ak ai lt {/xbi pt i3 get def /ybi pt i3 1 add get def /zbi pt i3 2 add get def pt i3 pt k3 get put pt i3 1 add pt k3 1 add get put pt i3 2 add pt k3 2 add get put /ai ak def pt k3 xbi put pt k3 1 add ybi put pt k3 2 add zbi put } if /k3 k3 3 add def } for /i1 i1 1 add def /i3 i3 3 add def } for } def /PtSortXZ {/np1 np 1 sub def /i3 0 def /i1 1 def 1 1 np1 {pop /xfi pt i3 get def /zfi pt i3 2 add get def /ai zfi mz sub xfi mx sub atan def /k3 i3 3 add def i1 1 np1 { pop /xfk pt k3 get def /zfk pt k3 2 add get def /ak zfk mz sub xfk mx sub atan def ak ai lt {/xbi pt i3 get def /ybi pt i3 1 add get def /zbi pt i3 2 add get def pt i3 pt k3 get put pt i3 1 add pt k3 1 add get put pt i3 2 add pt k3 2 add get put /ai ak def pt k3 xbi put pt k3 1 add ybi put pt k3 2 add zbi put } if /k3 k3 3 add def } for /i1 i1 1 add def /i3 i3 3 add def } for } def /PtSortYZ {/np1 np 1 sub def /i3 0 def /i1 1 def 1 1 np1 {pop /yfi pt i3 1 add get def /zfi pt i3 2 add get def /ai zfi mz sub yfi my sub atan def /k3 i3 3 add def i1 1 np1 { pop /yfk pt k3 1 add get def /zfk pt k3 2 add get def /ak zfk mz sub yfk my sub atan def ak ai lt {/xbi pt i3 get def /ybi pt i3 1 add get def /zbi pt i3 2 add get def pt i3 pt k3 get put pt i3 1 add pt k3 1 add get put pt i3 2 add pt k3 2 add get put /ai ak def pt k3 xbi put pt k3 1 add ybi put pt k3 2 add zbi put } if /k3 k3 3 add def } for /i1 i1 1 add def /i3 i3 3 add def } for } def true setstrokeadjust % for monitor gsave Box x0 y0 translate sc sc scale /Px 5 def % Camera position /Py 4 def /Pz 3 def /Vx 0 def % View point /Vy 0 def /Vz 0 def /Bet 0 def % Roll angle % /Typ 0 def defined in header Typ 0 eq % General illustration, pentagon {/sx 0.3 def % Point on plane /sy 0.5 def /sz 0.5 def /nx 0.6 def % Plane normal /ny 1.0 def /nz 0.4 def } if Typ 1 eq % Hexagon {/sx 0.5 def % Point on plane /sy 0.5 def /sz 0.5 def /nx 1.0 def % Plane normal /ny 1.0 def /nz 1.0 def } if Typ 2 eq % Triangle {/sx 0.8 def % Point on plane /sy 0.8 def /sz 0.8 def /nx 1.0 def % Plane normal /ny 1.0 def /nz 1.0 def } if Typ 3 eq % Square {/sx 0.6 def % Point on plane /sy 0.6 def /sz 0.5 def /nx 0.0 def % Plane normal /ny 0.0 def /nz 1.0 def } if Typ 4 eq % Random {/sx 0.1 def % Point on plane /sy 0.2 def /sz 0.3 def /nx 0.4 def % Plane normal /ny -0.5 def /nz 0.6 def } if Typ 5 eq % Single corner {/sx 0.0 def % Point on plane /sy 0.0 def /sz 0.0 def /nx 1.0 def % Plane normal /ny 1.0 def /nz 1.0 def } if Typ 6 eq % Two corners {/sx 0.5 def % Point on plane /sy 0.1 def /sz 0.95 def /nx 0.0 def % Plane normal /ny 1.0 def /nz 2.0 def } if Typ 7 eq % Four corners {/sx 0.5 def % Point on plane /sy 0.1 def /sz 0.9 def /nx 0.0 def % Plane normal /ny 1.0 def /nz 1.0 def } if Typ 8 eq % Face {/sx 0.6 def % Point on plane /sy 0.6 def /sz 1.0 def /nx 0.0 def % Plane normal /ny 0.0 def /nz 1.0 def } if /Map (Par) def % Parallel perspective MatCam FindPts Axes EdgeDraw Dots grestore List showpage