%!PS-Adobe-3.0 EPSF-3.0 Y10E00NP.PS6.PS 20180501 %%BoundingBox: 14 08 828 584 %START PDFDE011.EPS /pdfmark where {pop} {userdict /pdfmark /cleartomark load put} ifelse /languagelevel where {pop languagelevel} {1} ifelse 2 lt { userdict (<<) cvn ([) cvn load put userdict (>>) cvn (]) cvn load put} if [ /Title (PostScript pictures: farbe.li.tu-berlin.de/DE42/DE42.HTM) /Author (compare K. Richter "Computergrafik ...": ISBN 3-8007-1775-1) /Subject (goto: http://farbe.li.tu-berlin.de http://130.149.60.45/~farbmetrik) /Keywords (image reproduction, colour devices) /Creator (klaus.richter@mac.com) /CreationDate (D:2018060112000) /ModDate (D:20180601112000) /DOCINFO pdfmark [ /View [ /Fit ] /DOCVIEW pdfmark %END PDFDE011 /sfgray {setgray} bind def %Early Frame File (f) definition %BEG DE42/OUTLIN10.PS Output Linearization (OL) olv*->olv'* 20110301 %Early Binding: needed for colour separation %/sgcmykcolor {setcmykcolor} bind def %/sggray {setgray} bind def %/sgrgbcolor {setrgbcolor} bind def %FILE PREPARED FOR MIXED MODE, e. g. input ORS18 and output TLS00 /IMES 0 def %0=LAB* used, no reflection factor necessary %/IMES 1 def /Yre 2.52 def %1=XYZ measurement and standard device reflection %/i*ptrsc 0 def %LAB* setcolor to cmy0* / 000n* setcmykcolor /i*ptrsc 1 def %LAB* setcolor to olv* setrgbcolor / w* setgray %/i*ptrsc 2 def %LAB* setcolor to cmy0* / nnn0* setcmykcolor %/i*ptrsc 3 def %LAB* setcolor to olv* / www* setrgbcolor %/i*ptrsc 4 def %LAB* setcolor to lab* setcolor %/i*ptrsc 5 def %LAB* setcolor to LAB* setcolor %/i*ptrsc 6 def %LAB* setcolor to 000n* setcmykcolor %/i*ptrsc 7 def %LAB* setcolor to w* setgray %/ISIN*ioG 0 def %default input for Offset Reflective System (ORS18/FRS09) %/ISOU*ioG 0 def %default output dto. /ISIN*ioG 1 def %input for Television Luminous System (TLS00) /ISOU*ioG 1 def %output dto. %/ISIN*ioG 2 def %input for Device Reflective measurement system (FRS09) %/ISOU*ioG 2 def %output dto. %/ISIN*ioG 3 def %input for Television Luminous Reflection System (TLS18) %/ISOU*ioG 3 def %output dto. %/ISIN*ioG 4 def %input for Natural Luminous System (NLS00) %/ISOU*ioG 4 def %output dto. %/ISIN*ioG 5 def %input for Natural Reflective System (NRS11) %/ISOU*ioG 5 def %output dto. %/ISIN*ioG 6 def %input for Standard Reflective System (CIE18) %/ISOU*ioG 6 def %output dto. %/ISIN*ioG 7 def %input for Standard Reflective System (TLS70) %/ISOU*ioG 7 def %output dto. /iLAB 0 def %/colormg 0 def %END DE42/OUTLIN10.PS Output Linearization (OL) olv*->olv'* 20110301 %BEG DE42/OUTLIN1X.PS 20110801 %EMPTY %END DE42/OUTLIN1X.PS 20110801 %BEG DE42/OUTLIN1Y2.PS Emty 20101101 %END DE42/OUTLIN1Y2.PS Emty 20101101 /sfrgbcolor {setrgbcolor} bind def /sfcmykcolor {setcmykcolor} bind def %line 20****************************************************** /BeginEPSF {% def % Prepare for EPS file /b4_Inc_state save def % Save state for cleanup /dict_count countdictstack def /op_count count 1 sub def % Count objects on op stack userdict begin % Make userdict current dict /showpage {} def 0 setgray 0 setlinecap 1 setlinewidth 0 setlinejoin 10 setmiterlimit [] 0 setdash newpath /languagelevel where % If level not equal to 1 then {pop languagelevel where % If level not equal to 1 then 1 ne {false setstrokeadjust false setoverprint } if } if } bind def /EndEPSF {% def % End for EPS file count op_count sub {pop} repeat countdictstack dict_count sub {end} repeat % Clean up dict stack b4_Inc_state restore } bind def /FS {findfont exch scalefont setfont} bind def /MM {72 25.4 div mul} def /str {8 string } bind def /languagelevel where {pop languagelevel} {1} ifelse /PSL12 exch def /dictende {counttomark 2 idiv dup dict begin {def} repeat pop currentdict end} bind def % !AUSTAUSCH Times-Roman -> Times-Roman-ISOLatin1=Times-I /Times-Roman findfont dup length dict begin {1 index /FID ne {def} {pop pop} ifelse }forall /Encoding ISOLatin1Encoding def currentdict end /Times-ISOL1 exch definefont pop /Times-Italic findfont dup length dict begin {1 index /FID ne {def} {pop pop} ifelse }forall /Encoding ISOLatin1Encoding def currentdict end /TimesI-ISOL1 exch definefont pop /Times-Bold findfont dup length dict begin {1 index /FID ne {def} {pop pop} ifelse }forall /Encoding ISOLatin1Encoding def currentdict end /TimesB-ISOL1 exch definefont pop /Times-BoldItalic findfont dup length dict begin {1 index /FID ne {def} {pop pop} ifelse }forall /Encoding ISOLatin1Encoding def currentdict end /TimesBI-ISOL1 exch definefont pop /TK {250 /Times-ISOL1 FS} bind def /TM {300 /Times-ISOL1 FS} bind def /TG {350 /Times-ISOL1 FS} bind def /TIK {250 /TimesI-ISOL1 FS} bind def /TIM {300 /TimesI-ISOL1 FS} bind def /TIG {350 /TimesI-ISOL1 FS} bind def /TBK {250 /TimesB-ISOL1 FS} bind def /TBM {300 /TimesB-ISOL1 FS} bind def /TBG {350 /TimesB-ISOL1 FS} bind def /TBIK {250 /TimesBI-ISOL1 FS} bind def /TBIM {300 /TimesBI-ISOL1 FS} bind def /TBIG {350 /TimesBI-ISOL1 FS} bind def %ANFA CMYKDEF %CMYKDEA0 (A0=Standard-Drucker-CMYKDEF) 15.3.97 /tzac [1.000 0.933 0.867 0.800 0.733 0.667 0.600 0.533 0.467 0.400 0.333 0.267 0.200 0.132 0.067 0.000 1.000 0.750 0.500 0.250 0.000] def /tzam [1.000 0.933 0.867 0.800 0.733 0.667 0.600 0.533 0.467 0.400 0.333 0.267 0.200 0.132 0.067 0.000 1.000 0.750 0.500 0.250 0.000] def /tzay [1.000 0.933 0.867 0.800 0.733 0.667 0.600 0.533 0.467 0.400 0.333 0.267 0.200 0.132 0.067 0.000 1.000 0.750 0.500 0.250 0.000] def /tzan [1.000 0.933 0.867 0.800 0.733 0.667 0.600 0.533 0.467 0.400 0.333 0.267 0.200 0.132 0.067 0.000 1.000 0.750 0.500 0.250 0.000] def /tza0 [0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000] def /tza1 [1.000 1.000 1.000 1.000 1.000 1.000 1.000 1.000 1.000 1.000 1.000 1.000 1.000 1.000 1.000 1.000 1.000 1.000 1.000 1.000 1.000] def %ENDE CMYKD /rec %x, y width heigth {/heigth exch def /width exch def moveto width 0 rlineto 0 heigth rlineto width neg 0 rlineto closepath } bind def /colrecfiLAB* %x y width heigth LAB* { setcolor rec fill} bind def /colrecstLAB* %x y width heigth LAB* { setcolor rec stroke} bind def /colrecficmyn* %x y width heigth cmy0* or 000n* { setcmykcolor rec fill} bind def /colrecstcmyn* %x y width heigth cmy0* or 000n* { setcmykcolor rec stroke} bind def /colrecfiw* %x y width heigth w* { setgray rec fill} bind def /colrecstw* %x y width heigth w* { setgray rec stroke} bind def /colrecfiolv* %x y width heigth olv* { setrgbcolor rec fill} bind def /colrecstolv* %x y width heigth olv* { setrgbcolor rec stroke} bind def /tzocmy0* {0.0 1.0 1.0 0.0} bind def %Reproduction colours /tzlcmy0* {1.0 0.0 1.0 0.0} bind def %cmyn* setcmykcolor /tzvcmy0* {1.0 1.0 0.0 0.0} bind def /tzccmy0* {1.0 0.0 0.0 0.0} bind def /tzmcmy0* {0.0 1.0 0.0 0.0} bind def /tzycmy0* {0.0 0.0 1.0 0.0} bind def /tzoolv* {1.0 0.0 0.0} bind def %Reproduction colours /tzlolv* {0.0 1.0 0.0} bind def %olv* setrgbcolor /tzvolv* {0.0 0.0 1.0} bind def /tzcolv* {0.0 1.0 1.0} bind def /tzmolv* {1.0 0.0 1.0} bind def /tzyolv* {1.0 1.0 0.0} bind def /tzoLAB* [53.34 72.46 50.66] def %Reproduction colours /tzlLAB* [84.93 -79.83 74.80] def %LAB* setcolor /tzvLAB* [32.20 24.88 -37.89] def /tzcLAB* [88.10 -44.88 -13.36] def /tzmLAB* [59.66 90.32 -19.65] def /tzyLAB* [93.76 -20.24 85.93] def /tzncmy0* {1.00 1.00 1.00 0.00} bind def %grey series /tzdcmy0* {0.75 0.75 0.75 0.00} bind def %cmy0* setcmykcolor /tzzcmy0* {0.50 0.50 0.50 0.00} bind def /tzhcmy0* {0.25 0.25 0.25 0.00} bind def /tzwcmy0* {0.00 0.00 0.00 0.00} bind def /tzn000n* {0.00 0.00 0.00 1.00} bind def %grey series 000n* /tzd000n* {0.00 0.00 0.00 0.75} bind def %000n* setcmykcolor /tzz000n* {0.00 0.00 0.00 0.50} bind def /tzh000n* {0.00 0.00 0.00 0.25} bind def /tzw000n* {0.00 0.00 0.00 0.00} bind def /tznw* {0.00} bind def %grey series /tzdw* {0.25} bind def %w* setgray /tzzw* {0.50} bind def /tzhw* {0.75} bind def /tzww* {1.00} bind def /tznolv* {0.00 0.00 0.00} bind def %grey series /tzdolv* {0.25 0.25 0.25} bind def %olv* setrgbcolor /tzzolv* {0.50 0.50 0.50} bind def /tzholv* {0.75 0.75 0.75} bind def /tzwolv* {1.00 1.00 1.00} bind def /tznLAB* [18.01 0.00 0.00] def %grey series /tzdLAB* [37.36 0.00 0.00] def %LAB* setcolor /tzzLAB* [56.71 0.00 0.00] def /tzhLAB* [76.06 0.00 0.00] def /tzwLAB* [95.41 0.00 0.00] def /tfn {0 setgray} bind def /tfw {1 setgray} bind def /A4quer {598 0 translate 90 rotate} def /cvishow {cvi 6 string cvs show} def /cvsshow1 {10 mul cvi 0.1 mul 7 string cvs show} def /cvsshow2 {100 mul cvi 0.01 mul 7 string cvs show} def /cvsshow3 {1000 mul cvi 0.001 mul 7 string cvs show} def %%EndProlog %*********************************************************** %%BeginPageSetup /#copies 1 def %A4querF 1.0 1.0 scale /pgsave save def %%EndPageSetup /SS$ [(G) (E) (S) (F) (I) (J) (M)] def /SC$ [(N) (F) (S) (D) (T) (E) (C)] def /SX$ [(0) (1) (2) (3) (4) (5) (6) (7) (8) (9) (A) (B) (C) (D) (E) (F)] def /SY$ [(0) (1) (2) (3) (4) (5) (6) (7) (8) (9) (A) (B) (C) (D) (E) (F)] def % 0 1 2 3 4 5 % 6 7 8 /EX$ [(A.TXT /.PS) (B.BMP /.PS) (G.GIF /.PS) (H.HTM /.PS) (I.HTM /.PS) (J.JPE /.PS) (P.PDF /.PS) (T.TIF /.PS)] def /EY$ [(A.DAT) (B.DAT) (G.DAT) (H.DAT) (I.DAT) (J.DAT) (P.DAT) (T.DAT)] def %******************************************************************* /lanind1f 01 def /lanind2f 01 def /laninddf 01 def /colorm1f 00 def /colorm2f 00 def /colormdf 01 def /deintp1f 00 def /deintp2f 00 def /deintpdf 01 def /xcolor1f 00 def /xcolor2f 00 def /xcolordf 01 def %2 and 10 degree /xchart1f 00 def /xchart2f 00 def /xchartdf 01 def /xchart3f 01 def /xchart4f 00 def /xchart5f 00 def /pchart1f 03 def /pchart2f 03 def /pchartdf 01 def %=3 for sRGB, Lr=0 /colsep1f 00 def /colsep2f 00 def /colsepdf 01 def /pmetam1f 00 def /pmetam2f 00 def /pmetamdf 01 def %/lanindf lanind1f def % /lanindf lanind1f def %lanind1f laninddf lanind2f {/lanindf exch def %/colormf colorm1f def % /colormf colorm1f def %colorm1f colormdf colorm2f {/colormf exch def %/deintpf deintp1f def % /deintpf deintp1f def %deintp1f deintpdf deintp2f {/deintpf exch def %/xcolorf xcolor1f def % xcolor1f xcolordf xcolor2f {/xcolorf exch def %/xchartf xchart1f def % /xchartf xchart1f def %xchart1f xchartdf xchart2f {/xchartf exch def %/pchartf pchart1f def % /pchartf pchart1f def %/pchartf pchart1f def %pchart1f pchartdf pchart2f {/pchartf exch def %/colsepf colsep1f def % /colsepf colsep1f def %colsep1f colsepdf colsep2f {/colsepf exch def /lanind lanindf def /colorm colormf def /deintp deintpf def /xcolor xcolorf def /xchart xchartf def /xchartm xchart2f xchart1f sub 1 add def /xchart3 xchart3f def /xchart4 xchart4f def /pchart pchartf def /colsep colsepf def %/pmetamf pmetam1f def % /pmetamf pmetam1f def %pmetam1f pmetamdf pmetam2f {/pmetamf exch def /pmetam pmetamf def %************************************************************* /setgray {sfgray} bind def /setrgbcolor {sfrgbcolor} bind def /setcmykcolor {sfcmykcolor} bind def %72 90 translate %0.01 MM dup scale %0 0 moveto 24600 0 rlineto 0 17220 rlineto % -24600 0 rlineto closepath stroke %000 -240 moveto %240 /Times-ISOL1 FS %lanindf cvishow (-) show %colormf cvishow %deintpf cvishow %xcolorf cvishow %xchartf cvishow %pchartf cvishow %colsepf cvishow (-F) show pmetamf cvishow %grestore gsave /GSS$ SS$ lanind get def /GSC$ SC$ colorm get def /GSX$ SX$ xcolor xcolor 16 idiv 16 mul sub get def /GSY$ SY$ xchart xchart 16 idiv 16 mul sub get def /GEX$ EX$ 6 get def /GEY$ EY$ 6 get def %01 %02 %03 %04 %05 %06 %07 %08 %09 %10 %11 %12 %13 %14 %15 %16 %gsave BeginEPSF 28 MM 197 MM translate 10 /Times-ISOL1 FS 53 MM 1 MM moveto 1 1 scale -77 -91 translate %%BeginDocument: Bild 10 %line 329 %%EndDocument EndEPSF grestore gsave BeginEPSF 28 MM 152 MM translate 10 /Times-ISOL1 FS 53 MM 1 MM moveto 1 1 scale -77 -91 translate %%BeginDocument: Bild 11 %line 339 %!PS-Adobe-3.0 EPSF-3.0 DE420-1, %%BoundingBox: 70 90 226 206 /FS {findfont exch scalefont setfont} bind def /MM {72 25.4 div mul} def %%EndProlog gsave 8 /Times-Roman FS 72 83 moveto %!2 (DE420-1,) show 72 90 translate %! 0.01 MM 0.01 MM scale %! 15 setlinewidth %! 0 0 moveto 5400 0 rlineto 0 4000 rlineto -5400 0 rlineto %! closepath stroke grestore showpage %%Trailer %%EndDocument EndEPSF grestore gsave BeginEPSF 86 MM 152 MM translate 10 /Times-ISOL1 FS 53 MM 1 MM moveto ( ) show 1 1 scale -77 -91 translate %%BeginDocument: Bild 12 %line 349 %!PS-Adobe-3.0 EPSF-3.0 DE420-2, %%BoundingBox: 70 90 226 206 /FS {findfont exch scalefont setfont} bind def /MM {72 25.4 div mul} def %%EndProlog gsave 8 /Times-Roman FS 72 83 moveto %!2 (DE420-2,) show 72 90 translate %! 0.01 MM 0.01 MM scale %! 15 setlinewidth %! 0 0 moveto 5400 0 rlineto 0 4000 rlineto -5400 0 rlineto %! closepath stroke grestore showpage %%Trailer %%EndDocument EndEPSF grestore gsave BeginEPSF 28 MM 108 MM translate 10 /Times-ISOL1 FS 53 MM 1 MM moveto ( ) show 1 1 scale -77 -91 translate %%BeginDocument: Bild 13 %line 359 %!PS-Adobe-3.0 EPSF-3.0 DE420-7N %%BoundingBox: 70 83 398 320 %START PDFDE011.EPS /pdfmark03 where {pop} {userdict /pdfmark03 /cleartomark load put} ifelse /languagelevel where {pop languagelevel} {1} ifelse 2 lt { userdict (<<) cvn ([) cvn load put userdict (>>) cvn (]) cvn load put} if [ /Title (PostScript pictures: farbe.li.tu-berlin.de/DE42/DE42.HTM) /Author (compare K. Richter "Computergrafik ...": ISBN 3-8007-1775-1) /Subject (goto: http://farbe.li.tu-berlin.de http://130.149.60.45/~farbmetrik) /Keywords (image reproduction, colour devices) /Creator (klaus.richter@mac.com) /CreationDate (D:2018060112000) /ModDate (D:20180601112000) /DOCINFO pdfmark03 [ /View [ /Fit ] /DOCVIEW pdfmark03 %END PDFDE011 /BeginEPSF {% def % Prepare for EPS file /b4_Inc_state save def % Save state for cleanup /dict_count countdictstack def /op_count count 1 sub def % Count objects on op stack userdict begin % Make userdict current dict /showpage {} def 0 setgray 0 setlinecap 1 setlinewidth 0 setlinejoin 10 setmiterlimit [] 0 setdash newpath /languagelevel where % If level not equal to 1 then {pop languagelevel where % If level not equal to 1 then 1 ne {false setstrokeadjust false setoverprint } if } if } bind def /EndEPSF {% def % End for EPS file count op_count sub {pop} repeat countdictstack dict_count sub {end} repeat % Clean up dict stack b4_Inc_state restore } bind def % !AUSTAUSCH Times-Roman -> Times-Roman-ISOLatin1=Times-I /Times-Roman findfont dup length dict begin {1 index /FID ne {def} {pop pop} ifelse }forall /Encoding ISOLatin1Encoding def currentdict end /Times-ISOL1 exch definefont pop /Times-Italic findfont dup length dict begin {1 index /FID ne {def} {pop pop} ifelse }forall /Encoding ISOLatin1Encoding def currentdict end /TimesI-ISOL1 exch definefont pop /Times-Bold findfont dup length dict begin {1 index /FID ne {def} {pop pop} ifelse }forall /Encoding ISOLatin1Encoding def currentdict end /TimesB-ISOL1 exch definefont pop /Times-BoldItalic findfont dup length dict begin {1 index /FID ne {def} {pop pop} ifelse }forall /Encoding ISOLatin1Encoding def currentdict end /TimesBI-ISOL1 exch definefont pop /FS {findfont exch scalefont setfont} bind def /MM {72 25.4 div mul} def /str {8 string } bind def /TK {250 16.67 div /Times-ISOL1 FS} bind def /TM {300 16.67 div /Times-ISOL1 FS} bind def /TG {350 16.67 div /Times-ISOL1 FS} bind def /TIK {250 16.67 div /TimesI-ISOL1 FS} bind def /TIM {300 16.67 div /TimesI-ISOL1 FS} bind def /TIG {350 16.67 div /TimesI-ISOL1 FS} bind def /TBK {250 16.67 div /TimesB-ISOL1 FS} bind def /TBM {300 16.67 div /TimesB-ISOL1 FS} bind def /TBG {350 16.67 div /TimesB-ISOL1 FS} bind def /TBIK {250 16.67 div /TimesBI-ISOL1 FS} bind def /TBIM {300 16.67 div /TimesBI-ISOL1 FS} bind def /TBIG {350 16.67 div /TimesBI-ISOL1 FS} bind def /RK {250 16.67 div /Times-Roman FS} bind def /RM {300 16.67 div /Times-Roman FS} bind def /RG {350 16.67 div /Times-Roman FS} bind def /RIK {250 16.67 div /Times-Italic FS} bind def /RIM {300 16.67 div /Times-Italic FS} bind def /RIG {350 16.67 div /Times-Italic FS} bind def /RBK {250 16.67 div /Times-Bold FS} bind def /RBM {300 16.67 div /Times-Bold FS} bind def /RBG {350 16.67 div /Times-Bold FS} bind def /RBIK {250 16.67 div /Times-BoldItalic FS} bind def /RBIM {300 16.67 div /Times-BoldItalic FS} bind def /RBIG {350 16.67 div /Times-BoldItalic FS} bind def /tolvfcol %Farbkreis-Reihenfolge [ (000) (F00) (FF0) (0F0) (0FF) (00F) (F0F) (FFF) (777) (700) (770) (070) (077) (007) (707) (F07) %15=R (333) (F77) (FF7) (7F7) (7FF) (77F) (F7F) (07F) %23=B (BBB) (F70) (7F0) (0F7) (07F) (70F) (F07) (0F7) %31=G ] def /tcmyfcol %Farbkreis-Reihenfolge [ (FFF) (0FF) (00F) (F0F) (F00) (FF0) (0F0) (000) (888) (8FF) (88F) (F8F) (F88) (FF8) (8F8) (0F8) %15=R (CCC) (088) (008) (808) (800) (880) (080) (F80) %23=B (444) (08F) (80F) (F08) (F80) (8F0) (0F8) (F08) %31=G ] def /tcmykfcol %Farbkreis-Reihenfolge [ (000F) (0FF0) (00F0) (F0F0) (F000) (FF00) (0F00) (0000) (0008) (0FF8) (00F8) (F0F8) (F008) (FF08) (0F08) (0F80) %15=R (000C) (0880) (0080) (8080) (8000) (8800) (0800) (F800) %23=B (0004) (0F80) (80F0) (F080) (F800) (8F00) (0F80) (F080) %31=G ] def /tolvfcols %Farbkreis-Reihenfolge [ (000*) (F00*) (FF0*) (0F0*) (0FF*) (00F*) (F0F*) (FFF*) (777*) (700*) (770*) (070*) (077*) (007*) (707*) (F07*) %15=R (333*) (F77*) (FF7*) (7F7*) (7FF*) (77F*) (F7F*) (07F*) %23=B (BBB*) (F70*) (7F0*) (0F7*) (07F*) (70F*) (F07*) (0F7*) %31=G ] def /tcmyfcols %Farbkreis-Reihenfolge [ (FFF*) (0FF*) (00F*) (F0F*) (F00*) (FF0*) (0F0*) (000*) (888*) (8FF*) (88F*) (F8F*) (F88*) (FF8*) (8F8*) (0F8*) %15=R (CCC*) (088*) (008*) (808*) (800*) (880*) (080*) (F80*) %23=B (444*) (08F*) (80F*) (F08*) (F80*) (8F0*) (0F8*) (F08*) %31=G ] def /tcmykfcols %Farbkreis-Reihenfolge [ (000F*) (0FF0*) (00F0*) (F0F0*) (F000*) (FF00*) (0F00*) (0000*) (0008*) (0FF8*) (00F8*) (F0F8*) (F008*) (FF08*) (0F08*) (0F80*) %15=R (000C*) (0880*) (0080*) (8080*) (8000*) (8800*) (0800*) (F800*) %23=B (0004*) (0F80*) (80F0*) (F080*) (F800*) (8F00*) (0F80*) (F080*) %31=G ] def /fcolors %CMYN 32 Testfarben Nr. 0 bis 31; Farbkreis-Reihenfolge [{0.0 0.0 0.0 1.0} {0.0 1.0 1.0 0.0} {0.0 0.0 1.0 0.0} {1.0 0.0 1.0 0.0} {1.0 0.0 0.0 0.0} {1.0 1.0 0.0 0.0} {0.0 1.0 0.0 0.0} {0.0 0.0 0.0 0.0} {0.0 0.0 0.0 0.5} {0.0 1.0 1.0 0.5} {0.0 0.0 1.0 0.5} {1.0 0.0 1.0 0.5} {1.0 0.0 0.0 0.5} {1.0 1.0 0.0 0.5} {0.0 1.0 0.0 0.5} {0.0 1.0 0.5 0.0} {0.0 0.0 0.0 0.75} {0.0 0.5 0.5 0.0} {0.0 0.0 0.5 0.0} {0.5 0.0 0.5 0.0} {0.5 0.0 0.0 0.0} {0.5 0.5 0.0 0.0} {0.0 0.5 0.0 0.0} {1.0 0.5 0.0 0.0} {0.0 0.0 0.0 0.25} {0.0 0.5 1.0 0.0} {0.5 0.0 1.0 0.0} {1.0 0.0 0.5 0.0} {1.0 0.5 0.0 0.0} {0.5 1.0 0.0 0.0} {0.0 1.0 0.5 0.0} {1.0 0.0 0.5 0.0} ] def /fak 0.5 def /Far %Farbkreis-Reihenfolge [ 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 %R 16 17 18 19 20 21 22 23 %B 24 25 26 27 28 29 30 31 %G ] def /cFar %Kompensativ-Farbkreis-Reihenfolge [ 8 4 5 6 1 2 3 0 0 20 21 22 17 18 19 31 %G 24 12 13 14 9 10 11 2 %J 16 28 29 30 25 26 27 15 %R ] def /Btx %Farbkreis- -> %Btx-Reihenfolge [ 0 1 3 2 5 6 4 7 8 9 11 10 13 14 12 15 %R 16 17 19 18 21 22 20 23 %B 24 25 26 27 28 29 30 31 %G ] def /cBtx %Farbkreis- -> %Kompensativ-Btx-Reihenfolge [ 7 4 6 5 2 3 1 0 8 20 22 21 18 19 17 31 %G 24 12 14 13 10 11 9 2 %J 16 25 26 27 28 29 30 15 %R ] def /rec %x, y width heigth {/heigth exch def /width exch def moveto width 0 rlineto 0 heigth rlineto width neg 0 rlineto closepath } bind def /colrecfi %x y width heigth c m y k {setrgbcolor rec fill} bind def /colrecst %x y width heigth c m y k {setrgbcolor rec stroke} bind def /tzo {0.0 1.0 1.0 0.0} bind def %Reproduktionsfarben /tzl {1.0 0.0 1.0 0.0} bind def /tzv {1.0 1.0 0.0 0.0} bind def /tzc {1.0 0.0 0.0 0.0} bind def /tzm {0.0 1.0 0.0 0.0} bind def /tzy {0.0 0.0 1.0 0.0} bind def /tzn {0.0 0.0 0.0 1.00} bind def %Graureihe /tzd {0.0 0.0 0.0 0.75} bind def /tzz {0.0 0.0 0.0 0.50} bind def /tzh {0.0 0.0 0.0 0.25} bind def /tzw {0.0 0.0 0.0 0.00} bind def /tzr {0.0 1.0 0.5 0.0} bind def %Elementarfarben /tzg {1.0 0.0 0.5 0.0} bind def /tzb {1.0 0.5 0.0 0.0} bind def /tzj {0.0 0.0 1.0 0.0} bind def /tzrz {0.0 1.0 0.5 0.5} bind def %Elementarfarben vergraut /tzgz {1.0 0.0 0.5 0.5} bind def /tzbz {1.0 0.5 0.0 0.5} bind def /tzjz {0.0 0.0 1.0 0.5} bind def /tfo {tzo setcmykcolor} bind def /tfl {tzl setcmykcolor} bind def /tfv {tzv setcmykcolor} bind def /tfc {tzc setcmykcolor} bind def /tfm {tzm setcmykcolor} bind def /tfy {tzy setcmykcolor} bind def /tfn {tzn setcmykcolor} bind def /tfd {tzd setcmykcolor} bind def /tfz {tzz setcmykcolor} bind def /tfh {tzh setcmykcolor} bind def /tfw {tzw setcmykcolor} bind def /tfr {tzr setcmykcolor} bind def /tfg {tzg setcmykcolor} bind def /tfb {tzb setcmykcolor} bind def /tfj {tzj setcmykcolor} bind def /tfrz {tzrz setcmykcolor} bind def /tfgz {tzgz setcmykcolor} bind def /tfbz {tzbz setcmykcolor} bind def /tfjz {tzjz setcmykcolor} bind def %
% - %This is ps3d.inc ----------------------------------

% - Copyright Bill Casselman
% - Original version 1.0 November, 1998
% - Version 1.1 December, 1999
% -      Took out aliases for moveto etc.
% -      Made display-matrix a 3 x 4 homogeneous matrix, added it to the 3d gstack 
% -      Allowed arbitrary eye location, 3d -> 2d projects onto z = 0 plane
% -      Although fancy stuff not yet implemented
% -      Made ght a variable
% -      Version 1.1 is *not* backwards compatible!
% - Version 1.2 August, 2002
% -      Thorough interpretation of matrices as arrays of columns and point vectors as rows
% -      And some speed up
% -      Similar rewriting of matrix.inc
% -      Again, backwards incompatible!
% - Version 1.3 August, 2003
% -      Rewriting shade for efficiency
% - Thanks to Jim Blinn's book `A trip down the graphics pipeline'
% - for several suggestions that (I hope) made this code cleaner 
% - by suggesting how useful homogeneous coordinates were.
% November 10, 2003: added fancier shading
% December 17, 2003: changed arguments for mkpath procedures

% ------------------------------------------------


% - Inserting matrix.inc ----------------------

% - Vector calculations (usually good in any number of dimensions) ----------

% - matrices in this package are usually laid out in a single array by columns ---
% - i.e. [ column1 column 2 ... ]
% - but sometimes as a double array [ [ column1] [column2] ... ] 

% <double array>  /to-single-array
% <single-array> /to-double-array
% <n> /identity
% <u> <v> /dot-product
% <u> <c> /vector-scale
% <u> <v> /vector-add
% <u> <v> /vectorssub
% <u> /vector-length
% <u> <v> cross-product
% <axis> <angle> /rotation-matrix3d
% v [a b c] /euclidean-reflect
% [a b c] /reflection-matrix-3d
% <m> <n> /matrix-mul
% <m> <v> /matrix-vector
% <v> <m> /vector-matrix 
% <m> /transpose
% <m> 3x3-det
% <m> /3x3-inverse
% <u> <v> /angle-between
% <x> /acos
% <x> <a> <a^v> /skew-reflect
% <a> <a^v> /skew-reflection-matrix

% - matrices in this package are laid out in a single array by columns ---------

% a double array: cannot be empty - just lays out all items
/to-single-array {
% [ [. . . ][ . . . ] ] => [ . . . . . . ]
[
	exch { % successive rows
		aload pop
	} forall
]
} def

% ----------------------------------------------

% [ ... ] a square matrix made into an array of columns
/to-double-array { 4 dict begin
/A exch def
/N A length sqrt round cvi def
/i 0 def
[
N {
	[
	N {
		A i get
		/i i 1 add def
	} repeat
	]
} repeat
]
end } def

% ----------------------------------------

% returns the nxn identity matrix as single array
/identity { 1 dict begin
/n exch def
[
  n 1 sub {
    1 
    n {
      0
	} repeat 
  } repeat
  1
]
end } def

% --- vector algebra --------------------------------

% u v -> u.v
/dot-product { 1 dict begin
/v exch def
0 0	     		% u s i
3 2 roll { 		% s i u[i]
  v 			% s i u[i] v
  2 index get mul 	% s i u[i]*v[i]
  3 2 roll		% i u[i]*v[i] s
  add exch 1 add	% s i
} forall
pop
end } def

% v c -> c.v
/vector-scale { 1 dict begin
/c exch def
[ exch
{ 		% s i u[i]
  c mul			% s i u[i] v 
} forall
]
end } def

% u v -> u+v
/vector-add { 1 dict begin
/v exch def
[ exch
0 	     	% u i
exch { 		% i u[i]
  v 		% i u[i] v
  2 index get add 	% i u[i]+v[i]
  exch 1 add	% i
} forall
pop
]
end } def

% u v -> u-v
/vector-sub { 1 dict begin
/v exch def
[ exch
0 	     	% u i
exch { 		% i u[i]
  v 		% i u[i] v
  2 index get sub 	% i u[i]+v[i]
  exch 1 add	% i
} forall
pop
]
end } def

% [x y z ... ] -> r
% watch out for overflow

/vector-length { 1 dict begin
dup
% find maximum entry
/max 0 def
{ % max 
  abs dup max gt {
    % if abs gt max
    /max exch def
  } {
    pop
  } ifelse
} forall

max 0 ne {
  0 exch 
  {  % 0 v[i]
    max div dup mul add
  } forall
  sqrt
  max mul
} {
  pop 0
} ifelse
end } def

% v -> v/|v|
/normalized { 1 dict begin
dup 			% v v
vector-length /r exch def
[ exch
  {
    r div
  } forall
]
end } def

% u v
% u0 u1 u2
% v0 v1 v2
% -> u x v
/cross-product {
2 dict begin
/v exch def
/u exch def
[
  u 1 get v 2 get mul
  v 1 get u 2 get mul sub

  v 0 get u 2 get mul
  u 0 get v 2 get mul sub

  u 0 get v 1 get mul
  v 0 get u 1 get mul sub
]
end
} def

% --------------------------------------------------------------

% axis A -> a matrix
/rotation-matrix3d {
8 dict begin
dup 
cos /c exch def
sin /s exch def
/a exch def
/r a vector-length def
/a0 a 0 get r div def
/a1	a 1 get r div def
/a2 a 2 get r div def

[

% e = [1 0 0] etc.
% e0 = (e.a)a, e# = e - e0, e* = a x e = a x e0 + a x e# = a x e#
/x a0 def
/e0 [a0 x mul
     a1 x mul 
     a2 x mul] def
/e# [1 e0 0 get sub 
     e0 1 get neg 
     e0 2 get neg] def
% [a0 a1 a2]
% [ 1  0  0]
/e* [0 
     a2 
     a1 neg
    ] def
e# 0 get c mul e* 0 get s mul add e0 0 get add 
e# 1 get c mul e* 1 get s mul add e0 1 get add 
e# 2 get c mul e* 2 get s mul add e0 2 get add 

/x a1 def
/e0 [a0 x mul a1 x mul a2 x mul] def
/e# [e0 0 get neg 
     1 e0 1 get sub 
     e0 2 get neg] def
% [a0 a1 a2]
% [ 0  1  0]
/e* [a2 neg 
     0
     a0
    ] def
e# 0 get c mul e* 0 get s mul add e0 0 get add 
e# 1 get c mul e* 1 get s mul add e0 1 get add 
e# 2 get c mul e* 2 get s mul add e0 2 get add 

/x a2 def
/e0 [a0 x mul a1 x mul a2 x mul] def
/e# [e0 0 get neg
     e0 1 get neg
     1 e0 2 get sub] def
% [a0 a1 a2]
% [ 0  0  1]
/e* [a1 
     a0 neg
     0
    ] def
e# 0 get c mul e* 0 get s mul add e0 0 get add 
e# 1 get c mul e* 1 get s mul add e0 1 get add 
e# 2 get c mul e* 2 get s mul add e0 2 get add 

]
% [ r0 r1 r2 r3 r4 r5 r6 r7 r8 ] -> [r0 r3 r6 r1 r4 r7 r2 r5 r8 ]
/r exch def
[
	r 0 get 
	r 3 get
	r 6 get
	r 1 get
	r 4 get
	r 7 get
	r 2 get
	r 5 get
	r 8 get
] 
end
} def

% v a -> v - 2(a.v)/(a.a) a
/euclidean-reflect { 16 dict begin
/a exch def
/v exch def
/N a length def
/d a v dot-product a dup dot-product div 2 mul def
[
  0
  v {
    % i v[i]
    exch dup 1 add					% v[i] i i+1
	3 1 roll							  % i+1 v[i] i
    a exch get d mul 				% i+1 v[i] a[i]*d
	sub										% i+1 v[i]-d*a[i]
	exch									% rv[i] i+1
  } forall
  pop
]
end } def

% f = [A B C] => linear 3d transformation: f not necessarily normalized
% Rv = v - 2 <f', v> f'

/reflection-matrix3d {
3 dict begin
aload pop
/C exch def
/B exch def
/A exch def
/r [ A B C ] vector-length def
/A A r div def
/B B r div def
/C C r div def
[
  1 A A mul dup add sub   B A mul dup add neg   C A mul dup add neg
    A B mul dup add neg 1 B B mul dup add sub   C B mul dup add neg
    A C mul dup add neg   B C mul dup add neg 1 C C mul dup add sub
]
end
} def

/matrix-mul {
8 dict begin
/B exch def
/A exch def
/n A length sqrt round cvi def
%  0    1  ...
%  n  n+1 ...
% 2n 2n+1 ...
[
  0
  n {
    % i = initial index of the column on the stack = 0, n, 2n ... 
    % after all previous entries
    dup n add exch 0	
    n {
	  % i+n i j on stack
      % j = initial index of the row
	  2 copy 1 add % i+n i j i j+1
	  4 2 roll	% i+n i j+1 i j
	  /ell exch def
      /k exch def
	  % i+n i j+1 
      0
      n {
		% i+n i j+1 s
        A ell get B k get mul add
        /k k 1 add def
        /ell ell n add def
      } repeat
	  4 1 roll
	  % s i+n i j+1
   	} repeat
    pop pop	% s i+n
  } repeat
  pop
]
end
} def

% A v: A = [ column 1, column 2, ... , column n ]
/matrix-vector {
8 dict begin
/v exch def
/r v length def
/A exch def
/c A length r idiv def
[
  0 1 c 1 sub {
	/i exch def
    % i = initial index of the row
    0 0
    r {
		% s j on stack
		dup 1 add	% s j j+1
		3 1 roll		% j+1 s j
      	v exch get A i get mul add	% j+1 s
		exch
   	  	/i i r add def
    } repeat
	% s r
	pop
  } for
]
end
} def

% v A: A = [ column1 column2 ... ]
/vector-matrix {
8 dict begin
/A exch def
/v exch def
/c v length def
/r A length c idiv def
[
  /i 0 def 
  r {
    % i = initial index of the row
    /j 0 def
    0
    c {
      A i get v j get mul add
      /j j 1 add def
   	  /i i 1 add def
    } repeat
  } repeat
]
end
} def

% a square matrix m x m
% [i, j] = n*i + j

/transpose {
4 dict begin
/M exch def
/n M length sqrt round cvi def
[
/k 0 def
n {
  /i k def
  n { 
    M i get
    /i i n add def
  } repeat
  /k k 1 add def
} repeat
]

end
} def

/3x3-det {
1 dict begin
/m exch def

m 0 get 
m 4 get mul
m 8 get mul

m 1 get 
m 5 get mul
m 6 get mul
add

m 2 get 
m 3 get mul
m 7 get mul
add

m 2 get 
m 4 get mul
m 6 get mul
sub

m 1 get 
m 3 get mul
m 8 get mul
sub

m 0 get 
m 5 get mul
m 7 get mul
sub

end
} def

/3x3-inverse {
2 dict begin
/m exch def
/d m 3x3-det def
[
   m 4 get m 8 get mul 
   m 5 get m 7 get mul sub
   d div
   
   m 2 get m 7 get mul 
   m 1 get m 8 get mul sub
   d div
   
   m 1 get m 5 get mul 
   m 4 get m 2 get mul sub
   d div

   m 5 get m 6 get mul 
   m 3 get m 8 get mul sub
   d div
   
   m 0 get m 8 get mul 
   m 2 get m 6 get mul sub
   d div
   
   m 2 get m 3 get mul 
   m 0 get m 5 get mul sub
   d div

   m 3 get m 7 get mul 
   m 6 get m 4 get mul sub
   d div
   
   m 1 get m 6 get mul 
   m 0 get m 7 get mul sub
   d div
   
   m 0 get m 4 get mul 
   m 1 get m 3 get mul sub
   d div
]
end
} def

/acos {
dup dup % x x x
mul 1 sub neg % x 1-x^2
sqrt exch atan
} def

% u v

/angle-between {
dup vector-length
% u v |v|
3 1 roll
% |v| u v
1 index 
% |v| u v u
dot-product
% |v| u u.v
exch vector-length
% |v| u.v |u|
div exch div
acos
} def

% x a av -> x - <a, x> av

/skew-reflect { 4 dict begin
/av exch def
/a exch def
/x exch def
/d x a dot-product def
[
	0 1 x length 1 sub {
		/i exch def
		x i get av i get d mul sub
	} for
]
end } def

% a av -> matrix
/skew-reflection-matrix { 8 dict begin
/av exch def
/a exch def
/n a length def
[
	0 1 n 1 sub {
		/i exch def
		[ n {0} repeat ] dup i 1 put
		% e[i] 
		a av skew-reflect
	} for
]
to-single-array
transpose
end } def

% - closing matrix.inc ------------------------

% - Defining PostScript commands' equivalents ----------

% - Coordinates in three dimensions -------------------

% There are three steps to drawing something in 3D:
% 1.  Converting from user 3d coords to default 3d coords
% 2.  Projecting onto (x, y)-plane
% 3.  Drawing the image on that plane
% These are more or less independent.  
% The last step is completely controlled by the usual PS stuff.
% The first and second are handled by 3d stuff here.

% - Initialize and manipulate the 3d gstack -----------

/gmax 64 def
/ght 0 def

% gstack = [[t0 d0 dm0] [t1 d2 dm1] [t2 d2 dm2] ... [t(gmax-1) d(gmax-1) dm(gmax-1)] ]

% the ctm is t[ght]
% the dual ctm is at d[ght]
% they are 4 x 4
% display-matrix = 3 x 4

/gstack3d gmax array def

% start with orthogonal projection to positive z-axis
gstack3d 0 [
  [ 1 0 0 0 
    0 1 0 0
    0 0 1 0
    0 0 0 1] 
  [ 1 0 0 0 
    0 1 0 0
    0 0 1 0
    0 0 0 1]
  [ 1 0 0 0
    0 1 0 0
    0 0 0 1]
] put

/gsave3d {
  /ctm gstack3d ght get def
  /ght ght 1 add def 
  ght gmax eq {
    (3d graphics stack overflow!) ==
    quit
  } if
  gstack3d 
    ght
    [ ctm 0 get ctm 1 get ctm 2 get ] 
  put
} def

/grestore3d {
  /ght ght 1 sub def
  ght 0 lt {
     (3d graphics stack underflow!) ==
     quit
  } if
} def

% n - restores to depth n

/gpop3d {
/ght exch def
} def

% [T T* dm]: sets cgfx3d = [T T* dm]

/gset3d {
gstack3d  		% [T T* d] g 
ght			    % [T T* d] g ght
3 2 roll 		    % g ght [T T* d]
put 
} def

% => [T T* dm]

/cgfx3d {
  gstack3d ght get
} def

/ctm3d {
  gstack3d ght get 0 get
} def

/cim3d {
  gstack3d ght get 1 get
} def

/cdm3d {
  gstack3d ght get 2 get
} def

% cpt3d isthe last 3d point drawn to

/currentpoint3d {
cpt3d
cgfx3d 1 get transform3d
aload pop     % x y z w 
pop			
} def

% - Sets up projection into 2D -------------------
		
% O = [x y z w] 
% sets display-matrix perspective onto z = 0 plane

/display-matrix {
  cgfx3d 2 get
} def

% [z0 0 -x0 0
%  0 z0 -y0 0
%  0 0 -w0 z0]
% (transposed)
% gives perspective onto point in z=0 plane
% from [x0 y0 z0 w0]

/set-eye {
4 dict begin
aload pop
/w0 exch def
/z0 exch def
/y0 exch def
/x0 exch def
gstack3d ght get
2 
[ z0 0 x0 neg 0 
  0 z0 y0 neg 0
  0 0 w0 neg z0]
put
end
} def

/get-eye { 1 dict begin
/d display-matrix def
[d 2 get neg d 6 get neg d 0 get d 10 get neg]
end } def

/get-virtual-eye {
get-eye cgfx3d 1 get transform3d
} def

% - backwards compatibility -----------------------------

/origin { get-eye } def
/eye { get-eye } def
/set-display { set-eye } def

% - Manipulate the current transformation matrix -----

% x y z

/translate3d {
8 dict begin
/z exch def
/y exch def
/x exch def
/ctm cgfx3d def
/T ctm 0 get def
[
[
  T 0 get 
  T 1 get 
  T 2 get 
  T 0 get x  mul
  T 1 get y  mul
  add
  T 2 get z  mul
  add
  T 3 get 
  add
  
  T 4 get 
  T 5 get 
  T 6 get
  T 4 get x  mul
  T 5 get y  mul
  add
  T 6 get z  mul
  add
  T 7 get 
  add
   
  T 8 get 
  T 9 get 
  T 10 get
  T 8 get x  mul
  T 9 get y  mul
  add
  T 10 get z  mul
  add
  T 11 get 
  add
   
  T 12 get 
  T 13 get 
  T 14 get
  T 12 get x  mul
  T 13 get y  mul
  add
  T 14 get z  mul
  add
  T 15 get 
  add
]
/T ctm 1 get def
[
  T 0 get T 12 get x mul sub 
  T 1 get T 13 get x mul sub 
  T 2 get T 14 get x mul sub 
  T 3 get T 15 get x mul sub 

  T 4 get T 12 get y mul sub 
  T 5 get T 13 get y mul sub 
  T 6 get T 14 get y mul sub 
  T 7 get T 15 get y mul sub 

  T 8 get T 12 get z mul sub 
  T 9 get T 13 get z mul sub 
  T 10 get T 14 get z mul sub 
  T 11 get T 15 get z mul sub 

  T 12 get
  T 13 get
  T 14 get
  T 15 get
]
  ctm 2 get
]
end
gset3d
} def

% ------------------------------------------------------

% axis A

/rotate3d { 4 dict begin
rotation-matrix3d
/R exch def
/C cgfx3d def
/T C 0 get def
[
[
  % first row
  T 0 get R 0 get mul
  T 1 get R 3 get mul
  add
  T 2 get R 6 get mul
  add
  
  T 0 get R 1 get mul
  T 1 get R 4 get mul
  add
  T 2 get R 7 get mul
  add
  
  T 0 get R 2 get mul
  T 1 get R 5 get mul
  add
  T 2 get R 8 get mul
  add
  
  T 3 get
  
  % second row
  T 4 get R 0 get mul
  T 5 get R 3 get mul
  add
  T 6 get R 6 get mul
  add
  
  T 4 get R 1 get mul
  T 5 get R 4 get mul
  add
  T 6 get R 7 get mul
  add
  
  T 4 get R 2 get mul
  T 5 get R 5 get mul
  add
  T 6 get R 8 get mul
  add
  
  T 7 get
  
  % third row
  T 8 get R 0 get mul
  T 9 get R 3 get mul
  add
  T 10 get R 6 get mul
  add
  
  T 8 get R 1 get mul
  T 9 get R 4 get mul
  add
  T 10 get R 7 get mul
  add
  
  T 8 get R 2 get mul
  T 9 get R 5 get mul
  add
  T 10 get R 8 get mul
  add
  
  T 11 get
  
  % fourth row
  T 12 get R 0 get mul
  T 13 get R 3 get mul
  add
  T 14 get R 6 get mul
  add
  
  T 12 get R 1 get mul
  T 13 get R 4 get mul
  add
  T 14 get R 7 get mul
  add
  
  T 12 get R 2 get mul
  T 13 get R 5 get mul
  add
  T 14 get R 8 get mul
  add
  
  T 15 get
]
/T C 1 get def
% T = T^-1
% => R^-1 T^-1 
[
  R 0 get T 0 get mul
  R 3 get T 4 get mul add
  R 6 get T 8 get mul add
  
  R 0 get T 1 get mul
  R 3 get T 5 get mul add
  R 6 get T 9 get mul add
  
  R 0 get T 2 get mul
  R 3 get T 6 get mul add
  R 6 get T 10 get mul add
  
  R 0 get T 3 get mul
  R 3 get T 7 get mul add
  R 6 get T 11 get mul add
  
  % ------------------------
  
  R 1 get T 0 get mul
  R 4 get T 4 get mul add
  R 7 get T 8 get mul add
  
  R 1 get T 1 get mul
  R 4 get T 5 get mul add
  R 7 get T 9 get mul add
  
  R 1 get T 2 get mul
  R 4 get T 6 get mul add
  R 7 get T 10 get mul add
  
  R 1 get T 3 get mul
  R 4 get T 7 get mul add
  R 7 get T 11 get mul add
  
  % ------------------------
  
  R 2 get T 0 get mul
  R 5 get T 4 get mul add
  R 8 get T 8 get mul add
  
  R 2 get T 1 get mul
  R 5 get T 5 get mul add
  R 8 get T 9 get mul add
  
  R 2 get T 2 get mul
  R 5 get T 6 get mul add
  R 8 get T 10 get mul add
  
  R 2 get T 3 get mul
  R 5 get T 7 get mul add
  R 8 get T 11 get mul add

  T 12 get
  T 13 get
  T 14 get
  T 15 get  
]
  C 2 get
]
end
gset3d
} def


% f = [A B C D] P
% f = 0 is the *affine* reflection plane
% v = v* + v0 with v* on f = 0 and v0 in P-direction => v* - v0
% The map is Q => f(P)*Q - 2*f(Q)P
% It is of order two.
%
% f(P) I -
%
% 2A*P[0] 2B*P[0] 2C*P[0] 2D*P[0]
% 2A*P[1] 2B*P[1] 2C*P[1] 2D*P[1]
% 2A*P[2] 2B*P[2] 2C*P[2] 2D*P[2]
% 2A*P[3] 2B*P[3] 2C*P[3] 2D*P[3]
%
% Matrix = f(P) I - P f
% set s0 = (T row 0)*P
% T x this =
% f(P)T[0,0]-A*s -B*s -C*s -D*s

/affine-reflect3d { 4 dict begin
aload pop
/P3 exch def
/P2 exch def
/P1 exch def
/P0 exch def
aload pop
/D exch def
/C exch def
/B exch def
/A exch def

/fP 
  A P0 mul 
  B P1 mul add
  C P2 mul add
  D P3 mul add
def
/A A dup add def
/B B dup add def
/C C dup add def
/D D dup add def
[
/T cgfx3d 0 get def
[
  /s % = (T row 1)*P
  T 0 get P0 mul
  T 1 get P1 mul add
  T 2 get P2 mul add
  T 3 get P3 mul add
  def
  
  fP T 0 get mul
    A s mul sub
  fP T 1 get mul
    B s mul sub
  fP T 2 get mul
    C s mul sub
  fP T 3 get mul
    D s mul sub

  /s % = (T row 1)*P
  T 4 get P0 mul
  T 5 get P1 mul add
  T 6 get P2 mul add
  T 7 get P3 mul add
  def
  
  fP T 4 get mul
    A s mul sub
  fP T 5 get mul
    B s mul sub
  fP T 6 get mul
    C s mul sub
  fP T 7 get mul
    D s mul sub

  /s % = (T row 2)*P
  T 8 get P0 mul
  T 9 get P1 mul add
  T 10 get P2 mul add
  T 11 get P3 mul add
  def
  
  fP T 8 get mul
    A s mul sub
  fP T 9 get mul
    B s mul sub
  fP T 10 get mul
    C s mul sub
  fP T 11 get mul
    D s mul sub

  /s % = (T row 3)*P
  T 12 get P0 mul
  T 13 get P1 mul add
  T 14 get P2 mul add
  T 15 get P3 mul add
  def
  
  fP T 12 get mul
    A s mul sub
  fP T 13 get mul
    B s mul sub
  fP T 14 get mul
    C s mul sub
  fP T 15 get mul
    D s mul sub
]
/T cgfx3d 1 get def
/f0 		
  % f paired with columns of T
  T 0 get A mul
  T 4 get B mul add
  T 8 get C mul add
  T 12 get D mul add
def

/f1 		
  % f paired with columns of T
  T 1 get A mul
  T 5 get B mul add
  T 9 get C mul add
  T 13 get D mul add
def

/f2 		
  % f paired with columns of T
  T 2 get A mul
  T 6 get B mul add
  T 10 get C mul add
  T 14 get D mul add
def

/f3 		
  % f paired with columns of T
  T 3 get A mul
  T 7 get B mul add
  T 11 get C mul add
  T 15 get D mul add
def

[
  fP T 0 get mul
    f0 P0 get mul sub
  fP T 1 get mul
    f1 P0 get mul sub
  fP T 2 get mul
    f2 P0 get mul sub
  fP T 3 get mul
    f3 P0 get mul sub
  fP T 4 get mul
    f0 P1 get mul sub
  fP T 5 get mul
    f1 P1 get mul sub
  fP T 6 get mul
    f2 P1 get mul sub
  fP T 7 get mul
    f3 P1 get mul sub
  fP T 8 get mul
    f0 P2 get mul sub
  fP T 9 get mul
    f1 P2 get mul sub
  fP T 10 get mul
    f2 P2 get mul sub
  fP T 11 get mul
    f3 P2 get mul sub
  fP T 12 get mul
    f0 P3 get mul sub
  fP T 13 get mul
    f1 P3 get mul sub
  fP T 14 get mul
    f2 P3 get mul sub
  fP T 15 get mul
    f3 P3 get mul sub
]
  cgfx3d 2 get
] 
end
gset3d
} def

% 3x3 M 

/concat3d {
4 dict begin
/M exch def
[
/T cgfx3d 0 get def
  [
    T 0 get M 0 get mul
    T 1 get M 3 get mul add
    T 2 get M 6 get mul add

    T 0 get M 1 get mul
    T 1 get M 4 get mul add
    T 2 get M 7 get mul add
     
    T 0 get M 2 get mul
    T 1 get M 5 get mul add
    T 2 get M 8 get mul add
    
    T 3 get
     
    T 4 get M 0 get mul
    T 5 get M 3 get mul add
    T 6 get M 6 get mul add

    T 4 get M 1 get mul
    T 5 get M 4 get mul add
    T 6 get M 7 get mul add
     
    T 4 get M 2 get mul
    T 5 get M 5 get mul add
    T 6 get M 8 get mul add
    
    T 7 get
     
    T 8 get M 0 get mul
    T 9 get M 3 get mul add
    T 10 get M 6 get mul add

    T 8 get M 1 get mul
    T 9 get M 4 get mul add
    T 10 get M 7 get mul add
     
    T 8 get M 2 get mul
    T 9 get M 5 get mul add
    T 10 get M 8 get mul add
    
    T 11 get
     
    T 12 get M 0 get mul
    T 13 get M 3 get mul add
    T 14 get M 6 get mul add

    T 12 get M 1 get mul
    T 13 get M 4 get mul add
    T 14 get M 7 get mul add
     
    T 12 get M 2 get mul
    T 13 get M 5 get mul add
    T 14 get M 8 get mul add
    
    T 15 get
     
  ]
/T cgfx3d 1 get def
/M M 3x3-inverse def
  [
    M 0 get T 0 get mul
    M 1 get T 4 get mul add
    M 2 get T 8 get mul add
    
    M 0 get T 1 get mul
    M 1 get T 5 get mul add
    M 2 get T 9 get mul add
    
    M 0 get T 2 get mul
    M 1 get T 6 get mul add
    M 2 get T 10 get mul add
    
    M 0 get T 3 get mul
    M 1 get T 7 get mul add
    M 2 get T 11 get mul add
    
    % -----------------------------
    
    M 3 get T 0 get mul
    M 4 get T 4 get mul add
    M 5 get T 8 get mul add
    
    M 3 get T 1 get mul
    M 4 get T 5 get mul add
    M 5 get T 9 get mul add
    
    M 3 get T 2 get mul
    M 4 get T 6 get mul add
    M 5 get T 10 get mul add
    
    M 3 get T 3 get mul
    M 4 get T 7 get mul add
    M 5 get T 11 get mul add
    
    % -----------------------------
    
    M 6 get T 0 get mul
    M 7 get T 4 get mul add
    M 8 get T 8 get mul add
    
    M 6 get T 1 get mul
    M 7 get T 5 get mul add
    M 8 get T 9 get mul add
    
    M 6 get T 2 get mul
    M 7 get T 6 get mul add
    M 8 get T 10 get mul add
    
    M 6 get T 3 get mul
    M 7 get T 7 get mul add
    M 8 get T 11 get mul add
    
    % -----------------------------
    
    T 12 get
    T 13 get
    T 14 get
    T 15 get
  ]
  cgfx3d 2 get
]
end
gset3d
} def

%
% v => v - 2 <v, a> a
%
% Matrix = I - 2 a a
% a

/reflect3d { 4 dict begin
reflection-matrix3d 
concat3d
end } def

% [x y z w] [a00 a01 a02 a03 ... ]
% but the vector is a linear function
% so it is multiplying by transpose
% if T is the current ctm3d, the point P -> P T transform3d
% but the plane f=0 -> f T^{-1} dual-transform3d

/dual-transform3d { 4 dict begin
/v exch def
/T exch def
[
  v 0 get T 0 get mul
  v 1 get T 4 get mul add
  v 2 get T 8 get mul add
  v 3 get T 12 get mul add
  
  v 0 get T 1 get mul
  v 1 get T 5 get mul add
  v 2 get T 9 get mul add
  v 3 get T 13 get mul add
  
  v 0 get T 2 get mul
  v 1 get T 6 get mul add
  v 2 get T 10 get mul add
  v 3 get T 14 get mul add
  
  v 0 get T 3 get mul
  v 1 get T 7 get mul add
  v 2 get T 11 get mul add
  v 3 get T 15 get mul add
]
end } def

% 4d to 3d homogeneous
/project3d { 4 dict begin
/T exch def
/v exch def
[
  T 0 get v 0 get mul
  T 1 get v 1 get mul
  add 
  T 2 get v 2 get mul 
  add
  T 3 get v 3 get mul 
  add

  T 4 get v 0 get mul
  T 5 get v 1 get mul
  add 
  T 6 get v 2 get mul 
  add
  T 7 get v 3 get mul 
  add

  T 8 get v 0 get mul
  T 9 get v 1 get mul
  add 
  T 10 get v 2 get mul 
  add
  T 11 get v 3 get mul 
  add
] 
end } def

% [x y z w] [a00 a01 a02 a03 ... ]

/transform3d {
4 dict begin
/T exch def
/v exch def
[
T 0 get v 0 get mul
T 1 get v 1 get mul
add 
T 2 get v 2 get mul 
add
T 3 get v 3 get mul 
add

T 4 get v 0 get mul
T 5 get v 1 get mul
add 
T 6 get v 2 get mul 
add
T 7 get v 3 get mul 
add

T 8 get v 0 get mul
T 9 get v 1 get mul
add 
T 10 get v 2 get mul 
add
T 11 get v 3 get mul 
add

T 12 get v 0 get mul
T 13 get v 1 get mul
add 
T 14 get v 2 get mul 
add
T 15 get v 3 get mul 
add

] 
end
} def

% sx sy sz

/scale3d {
8 dict begin
/sz exch def
/sy exch def
/sx exch def
/T cgfx3d 0 get def
[
[
  T 0 get sx mul
  T 1 get sy mul
  T 2 get sz mul
  T 3 get 
  
  T 4 get sx mul
  T 5 get sy mul
  T 6 get sz mul
  T 7 get 
  
  T 8 get sx mul
  T 9 get sy mul
  T 10 get sz mul
  T 11 get 
 
  T 12 get sx mul
  T 13 get sy mul
  T 14 get sz mul
  T 15 get 
]
/T cgfx3d 1 get def
[
  T 0 get sx div
  T 1 get sx div
  T 2 get sx div
  T 3 get sx div
  
  T 4 get sy div
  T 5 get sy div
  T 6 get sy div
  T 7 get sy div
  
  T 8 get sz div
  T 9 get sz div
  T 10 get sz div
  T 11 get sz div
 
  T 12 get 
  T 13 get 
  T 14 get 
  T 15 get 
]
  cgfx3d 2 get
]
end
gset3d
} def

% [ <9> ] i

/row {
4 dict begin
/i exch def
/a exch def
a length 9 eq {
  /i i 3 mul def
  /n i 2 add def
} {
  /i i 4 mul def
  /n i 3 add def
} ifelse
[
  i 1 n {
    a exch get
  } for
]
end
} def

% projects from P onto f=Ax+By+Cz+D=0
% two parameters: f = [A B C D] and P
% The map is Q => f(P)*Q - f(Q)P
% It is idempotent.
%
% f(P) I -
%
% A*P[0] A*P[1] A*P[2] A*P[3]
% B*P[0] B*P[1] B*P[2] B*P[3]
% C*P[0] C*P[1] C*P[2] C*P[3]
% D*P[0] D*P[1] D*P[2] D*P[3]
%
% Matrix = f(P) I - P f
% set s0 = (T row 0)*P
% T x this =
% f(P)T[0,0]-A*s -B*s -C*s -D*s

/plane-project {
12 dict begin
aload pop
/P3 exch def
/P2 exch def
/P1 exch def
/P0 exch def
aload pop
/D exch def
/C exch def
/B exch def
/A exch def

/fP 
  A P0 mul 
  B P1 mul add
  C P2 mul add
  D P3 mul add
def
[
/T cgfx3d 0 get def
[
  /s % = (T row 0)*P
  	T 0 get P0 mul
  	T 1 get P1 mul add
  	T 2 get P2 mul add
  	T 3 get P3 mul add
  def
  
  fP T 0 get mul
    A s mul sub
  fP T 1 get mul
    B s mul sub
  fP T 2 get mul
    C s mul sub
  fP T 3 get mul
    D s mul sub


  /s % = (T row 1)*P
  T 4 get P0 mul
  T 5 get P1 mul add
  T 6 get P2 mul add
  T 7 get P3 mul add
  def
  
  fP T 4 get mul
    A s mul sub
  fP T 5 get mul
    B s mul sub
  fP T 6 get mul
    C s mul sub
  fP T 7 get mul
    D s mul sub


  /s % = (T row 2)*P
  T 8 get P0 mul
  T 9 get P1 mul add
  T 10 get P2 mul add
  T 11 get P3 mul add
  def
  
  fP T 8 get mul
    A s mul sub
  fP T 9 get mul
    B s mul sub
  fP T 10 get mul
    C s mul sub
  fP T 11 get mul
    D s mul sub

  /s % = (T row 3)*P
  T 12 get P0 mul
  T 13 get P1 mul add
  T 14 get P2 mul add
  T 15 get P3 mul add
  def
  
  fP T 12 get mul
    A s mul sub
  fP T 13 get mul
    B s mul sub
  fP T 14 get mul
    C s mul sub
  fP T 15 get mul
    D s mul sub
]
/T cgfx3d 1 get def
[
  /s T 0 get T 1 get add T 2 get add T 3 get add def
  s A mul
  s B mul
  s C mul
  s D mul
  /s T 4 get T 5 get add T 6 get add T 7 get add def
  s A mul
  s B mul
  s C mul
  s D mul
  /s T 8 get T 9 get add T 10 get add T 11 get add def
  s A mul
  s B mul
  s C mul
  s D mul
  /s T 12 get T 13 get add T 14 get add T 15 get add def
  s A mul
  s B mul
  s C mul
  s D mul
]
  cgfx3d 2 get
] 
end
gset3d
} def

% - Drawing commands in 3D --------------------------

% P displayed = [x y w z] => [X Y W] -> [X/W Y/W]

/render {
8 dict begin
aload pop
/v3 exch def
/v2 exch def
/v1 exch def
/v0 exch def
/T display-matrix def
/x
  T 0 get v0 mul 
  T 1 get v1 mul add
  T 2 get v2 mul add
  T 3 get v3 mul add
def
/y 
  T 4 get v0 mul 
  T 5 get v1 mul add
  T 6 get v2 mul add
  T 7 get v3 mul add
def
/w 
  T 8 get v0 mul 
  T 9 get v1 mul add
  T 10 get v2 mul add
  T 11 get v3 mul add
def
w 0 eq {
  (Perspective: division by zero!) ==
  quit
} if
x w div
y w div
end
} def

%  x y z -> x y
/transformto2d {
[ 4 1 roll 1 ] ctm3d transform3d render 
} def

/cpt3d 4 array def
/lm3d 4 array def

% cpt3d is a point in the "real" 3d world

% Should we build the current 3d path for reuse?

% x y z
/moveto3d {
1 [ 5 1 roll ] 
cgfx3d 0 get 
transform3d 
aload pop cpt3d astore 
render moveto
cpt3d aload pop lm3d astore pop
} def

% x y z

/lineto3d {
1 [ 5 1 roll ] 
cgfx3d 0 get 
transform3d 
aload pop cpt3d astore 
render lineto
} def

% x y z

/rmoveto3d {
0 [ 5 1 roll ] cgfx3d 0 get
transform3d 			% [dx dy dz 0]
dup 0 get cpt3d 0 get add	% [dx dy dz 0] x+dx
exch 
dup 1 get cpt3d 1 get add	% x+dx [dx dy dz dw] y+dy
exch
dup 2 get cpt3d 2 get add	% x+dx x+dy [dx dy dz dw] z+dz
exch				% x+dx y+dy z+dz [dx dy dz dw]
3 get cpt3d 3 get add		% x+dx x+dy z+dz w+dw
cpt3d astore
render moveto
cpt3d aload pop lm3d astore pop
} def

% x y z

/rlineto3d {
0 [ 5 1 roll ] cgfx3d 0 get
transform3d 		% [dx dy dz 0]
dup 0 get cpt3d 0 get add	% [dx dy dz 0] x+dx
exch 
dup 1 get cpt3d 1 get add	% x+dx [dx dy dz dw] y+dy
exch
dup 2 get cpt3d 2 get add	% x+dx x+dy [dx dy dz dw] z+dz
exch				% x+dx y+dy z+dz [dx dy dz dw]
3 get cpt3d 3 get add		% x+dx x+dy z+dz w+dw
cpt3d astore  
render lineto
} def

% x1 y1 z1 x2 y2 z2 x3 y3 z3 

/curveto3d { 16 dict begin
/z3 exch def
/y3 exch def
/x3 exch def
/z2 exch def
/y2 exch def
/x2 exch def
/z1 exch def
/y1 exch def
/x1 exch def
% F(t) 
/P0 cpt3d display-matrix project3d def
/P1 [x1 y1 z1 1] cgfx3d 0 get transform3d display-matrix project3d def
/w P0 2 get def
/c P1 2 get w div 1 sub def
/x0 P0 0 get w div def
/x1 P1 0 get w div def
/y0 P0 1 get w div def
/y1 P1 1 get w div def
x1 x0 c mul sub 
y1 y0 c mul sub 
[x3 y3 z3 1] cgfx3d 0 get transform3d aload pop cpt3d astore 
display-matrix project3d /P3 exch def
/P2 [x2 y2 z2 1] cgfx3d 0 get transform3d display-matrix project3d def
% We are assuming the display-matrix has images on { z = 0 }
/w P3 2 get def
/c P2 2 get w div 1 sub def
/x3 P3 0 get w div def
/x2 P2 0 get w div def
/y3 P3 1 get w div def
/y2 P2 1 get w div def
x2 x3 c mul sub 
y2 y3 c mul sub 
x3 y3
curveto
end } def

% - are the next two used? --------------------------------

% dP dQ Q

/dcurveto3d { 16 dict begin
/z3 exch def
/y3 exch def
/x3 exch def
/dz3 exch def
/dy3 exch def
/dx3 exch def
/dz0 exch def
/dy0 exch def
/dx0 exch def
/P0 cpt3d display-matrix project3d def
/dP0 [dx0 dy0 dz0 0] cgfx3d 0 get transform3d display-matrix project3d def
/w P0 3 get def 
% c = 1 - w'/w
/c 1 dP0 3 get w div sub def
  P0 0 get w div c mul dP0 0 get w div add
  P0 1 get w div c mul dP0 1 get w div add
[x3 y3 z3 1] cgfx3d 0 get transform3d aload pop cpt3d astore 
display-matrix project3d /P3 exch def
/dP3 [dx3 dy3 dz3 0] cgfx3d 0 get transform3d display-matrix project3d def
/w P3 3 get def
/c 1 dP3 3 get w div add def
  P3 0 get w div c mul dP3 0 get w div sub
  P3 1 get w div c mul dP3 1 get w div sub
  P3 0 get w div
  P3 1 get w div
curveto
end
} def

% dP dQ Q

/dcurveto { 8 dict begin
/y3 exch def
/x3 exch def
/dy3 exch def
/dx3 exch def
/dy0 exch def
/dx0 exch def
currentpoint dy0 add exch dx0 add exch
x3 dx3 sub y3 dy3 sub
x3 y3 
curveto
end } def

% - are the above two used? ----------------------------

/closepath3d {
closepath
lm3d aload pop cpt3d astore pop
} def

% - Conversion from 2d to 3D ---------------------------

/2d-path-convert {
[
  { % x y
    [ 3 1 roll 0 {moveto3d}]
  }
  { % x y
    [ 3 1 roll 0 {lineto3d}]
  }
  { % x1 y1 x2 y2 x3 y3
    [ 7 1 roll
    0 5 1 roll
    0 3 1 roll
    0 {curveto3d} ]
  }
  {
    [ {closepath3d} ]
  }
  pathforall
]
newpath
{
  aload pop exec
} forall
} def

% -----------------------------------------------

% For a simple currentpoint:

/mkpath3dDict 8 dict def

mkpath3dDict begin

/pathcount {
0 
{pop pop 
  pop 1 exit}
{pop pop 
  pop 1 exit}
{pop pop pop pop pop pop 
  pop 1 exit}
{ pop 1 exit}
pathforall
} def

/thereisacurrentpoint {
pathcount
0 gt
{true}
{false}
ifelse
} def

end

% ---------------------------------------------

% stack: t0 t1 N [parameters] /f 

/mkpath3d { load 
/f exch def
/pars exch def
12 dict begin
/N exch def
/t1 exch def
/t exch def

/h t1 t sub N div def
/h3 h 0.333333 mul def

pars t f aload pop
/velocity exch def
/position exch def
/p [ position aload pop 1 ] 
cgfx3d 0 get transform3d display-matrix project3d def
/v [ velocity aload pop 0 ] 
cgfx3d 0 get transform3d display-matrix project3d def

% p v = homogeneous position and velocity
% p/p[3] v/p[3] - (v[3]/p[3])(p/p[3]) = inhomogeneous ones
% = p/w v/w - c*p/w

/w p 3 get def
/c v 3 get w div def
thereisacurrentpoint {
  p 0 get w div p 1 get w div lineto
} {
  p 0 get w div p 1 get w div moveto
} ifelse

N {				% x y = currentpoint
  p 0 get 
    v 0 get 
    p 0 get c mul 
    sub 
    h3 mul 
  add 
  w div
  
  p 1 get 
    v 1 get 
    p 1 get c mul 
    sub 
    h3 mul 
  add
  w div

/t t h add def

pars t f aload pop
/velocity exch def
/position exch def
/p [ position aload pop 1 ] 
cgfx3d 0 get transform3d display-matrix project3d def
/v [ velocity aload pop 0 ] 
cgfx3d 0 get transform3d display-matrix project3d def
/w p 3 get def
/c v 3 get w div def

  p 0 get 
    v 0 get 
    p 0 get c mul 
    sub 
    h3 mul 
  sub 
  w div
  
  p 1 get 
    v 1 get 
    p 1 get c mul 
    sub 
    h3 mul 
  sub
  w div

p 0 get w div
p 1 get w div
curveto

} repeat
end % local dict
} def

% makes polygon out of control points

/mkcontrolpath3d { load
mkpath3dDict begin
1 dict begin
/f exch def
/pars exch def
/N exch def
/t1 exch def
/t exch def

/h t1 t sub N div def
/h3 h 0.333333 mul def

pars t f aload pop
/velocity exch def
/position exch def

position aload pop
thereisacurrentpoint {
	lineto3d
} {
	moveto3d
} ifelse

N {				% x y = currentpoint
% currentpoint pixel pop

position 0 get
velocity 0 get		% x dx/dt
h3 mul add
position 1 get
velocity 1 get		% y dy/dt
h3 mul add
position 2 get
velocity 2 get		% z dz/dt
h3 mul add

lineto3d

/t t h add def

pars t f aload pop
/velocity exch def
/position exch def

position 0 get
velocity 0 get 
h3 mul sub
position 1 get
velocity 1 get 
h3 mul sub
position 2 get
velocity 2 get 
h3 mul sub

lineto3d

position 0 get
position 1 get
position 2 get

lineto3d

} repeat
end % local dict
end % mkpath3d dict
} def

% -----------------------------------------------

% makes polygon from endpoints

/mkpolypath3d { load
/f exch def
/pars exch def
mkpath3dDict begin
1 dict begin
/N exch def
/t1 exch def
/t exch def

/h t1 t sub N div def
/h3 h 0.333333 mul def

pars t f aload pop
/velocity exch def
/position exch def

position aload pop
thereisacurrentpoint {
	lineto3d
} {
	moveto3d
} ifelse

N {				% x y = currentpoint
% currentpoint pixel pop

/t t h add def

pars t f aload pop
/velocity exch def
/position exch def

position 0 get
position 1 get
position 2 get
lineto3d

} repeat
end % local dict
end % mkpath3d dict
} def

% ---------------------------------------------

% length width

/plainarrow3d {
5 dict begin
/shaftwidth exch def
/arrowlength exch def
/headwidth shaftwidth 3 mul def
/headlength headwidth def
/shaftlength arrowlength shaftwidth 2.5 mul sub def
0 0 0 moveto3d
0 shaftwidth 0.5 mul 0 lineto3d
% shaftlength 0 0 rlineto3d
shaftlength shaftwidth 0.5 mul 0 lineto3d
arrowlength headlength sub headwidth 0.5 mul 0 lineto3d
arrowlength 0 0 lineto3d
arrowlength headlength sub headwidth -0.5 mul 0 lineto3d
shaftlength shaftwidth -0.5 mul 0 lineto3d
0 shaftwidth -0.5 mul 0 lineto3d
0 0 0 lineto3d
end
} def

% length width

/plainarrowtail3d {
5 dict begin
/shaftwidth exch def
/arrowlength exch def
0 0 0 moveto3d
0 shaftwidth 0.5 mul 0 lineto3d
arrowlength 0 0 rlineto3d
0 shaftwidth neg 0 rlineto3d
arrowlength neg 0 0 rlineto3d
0 0 0 lineto3d
end
} def

% --- shading ------------------------------------------------------------------

% all the shade input routines have as one argument a number between -1 and 1
% the result of a calculation of the dot-product of two unit vectors

% linear interpolation: s [a b] -> a + (b-a)*t

/lshade { % s [a b]
exch 1 add 2 div 	% t in [0 1]
% [a b] t
exch aload 0 get		% t a b a
4 1 roll 				% a t a b
sub mul sub			% a - t(a-b)
} def

%  # in [-1 1] & coefficient array [A B C D]: 
% A etc = control points, A = min, D = max
% 1 = facing towards, -1 = facing away from light
% x -> (x+1)/2 = 0.5(x+1) takes [-1, 1] -> [0, 1]
% evaluate by Horner's method

/shade {                             % t [array]
exch                                 % [array] t
1 add 0.5 mul 	                     % a t now in [0 1]
1 1 index sub                        % a t s=1-t
dup dup mul                          % a t s s^2
dup 2 index mul                      % a t s s^2 s^3
5 -1 roll aload pop                  % t s s^2 s^3 a0 a1 a2 a3=P0
7 index mul                          % t s s^2 s^3 a0 a1 a2 a3.t
exch                                 % t s s^2 s^3 a0 a1 a3.t a2
7 -1 roll                            % t s^2 s^3 a0 a1 a3.t a2 s
mul 3 mul add                        % t s^2 s^3 a0 a1 a3.t+3.a2.s=P1
5 index mul                          % t s^2 s^3 a0 a1 P1.t
exch                                 % t s^2 s^3 a0 P1.t a1
5 -1 roll                            % t s^3 a0 P1.t a1 s^2
mul 3 mul add                        % t s^3 a0 P1.t+3.a1.s^2=P2
4 -1 roll mul                        % s^3 a0 P2.t
3 1 roll mul add                     % P2.t + a0.s^3=P3
} def

% t y=[ y0 y1 ... yn ]
/bernstein { % t y 
  % constants y n t s=1-t
  % variables k C P
  dup length % t y n+1
  1 sub      % t y n
  3 -1 roll 1 % y n t 1
  1 index sub % y n t s
  % constants in place
  1           % y n t s k
  3 index 3 index mul % y n t s k C=nt
  5 index 0 get       % y n t s k C P=y0
  5 index {           % y n t s k C P
    % P -> s.P + C.y[k]
    % C -> C.t.(n-k)/(k+1) 
    % k -> k+1
    3 index mul       % y n t s k C P.s
    1 index           % y n t s k C P.s C
    7 index           % y n t s k C P.s C y 
    4 index get mul add  % y n t s k C P.s+C.y[k]=new P
    3 1 roll          % y n t s P* k C
    5 index           % y n t s P* k C n
    2 index sub mul   % y n t s P* k C.(n-k)
    1 index 1 add div % y n t s P* k C.(n-k)/(k+1)
    4 index mul       % y n t s P* k C*
    3 1 roll 1 add    % y n t s C* P* k*
    3 1 roll          % y n t s k* C* P*
  } repeat
  7 1 roll 6 { pop } repeat
} def

% shading: s in [-1 1] and y a Bernstein array B -> t -> B(t)
/bshade { exch 
1 add 2 div 
exch bernstein
} def

% ---------------------------------------------------------------------------------

% input: [pars] /fcn s0 s1 t0 t1 ns nt
% the fcn: [pars] s t -> f_{pars}(s, t)
% output: a polygonal surface of faces [ normal-fcn triangle ]

/mksurface {
16 dict begin
/nt exch def
/ns exch def
/t1 exch def
/t0 exch def
/s1 exch def
/s0 exch def
/ds s1 s0 sub ns div def
/dt t1 t0 sub nt div def
/f exch cvx def
/pars exch def
/P [
  /s s0 def
  ns 1 add {
    [
      /t t0 def
      nt 1 add {
        pars s t f
        /t t dt add def
      } repeat
    ]
    /s s ds add def
  } repeat
] def
% P[i][j] = f(s0 + i.ds, t0 + j.dt)
[
  0 1 ns 1 sub {
    /i exch def
    0 1 nt 1 sub {
      /j exch def
      % an array of triangles (i, j, 0) + (i, j, 1) 
      % dividing the rectangles in two
      /P00 P i get j get def
      /P10 P i 1 add get j get def
      /P01 P i get j 1 add get def
      /P11 P i 1 add get j 1 add get def
      % normal
      /Q P10 P00 vector-sub P01 P00 vector-sub cross-product def
      /r Q vector-length def
      r 0 ne {
        [
          [ Q aload pop Q P10 dot-product neg ]
          % array of pointers to three vertices
          [ P00 P10 P01 ]
        ] 
      } if
      /Q P01 P11 vector-sub P10 P11 vector-sub cross-product def
      /r Q vector-length def
      r 0 ne {
        [
          [ Q aload pop Q P01 dot-product neg ]
          % array of pointers to three vertices
          [ P10 P11 P01 ]
        ]
      } if
    } for
  } for
]
end
} def

% an array of vertices 
% traversed according to right hand rule
% output normalized

/normal-function {
2 dict begin
/a exch def
/n 
  a 1 get a 0 get vector-sub 
  a 2 get a 1 get vector-sub 
  cross-product 
def
/r n 0 get dup mul n 1 get dup mul add n 2 get dup mul add sqrt def
r 0 gt {
  /n [ n 0 get r div n 1 get r div n 2 get r div ] def
  [
    n aload pop
    a 0 get n dot-product neg
  ]
}{ [] } ifelse
end
} def

% --- light ------------------------------------------------

% should be part of the graphics environment

/set-light { /light-source exch def } def

/get-virtual-light {
  light-source cgfx3d 1 get transform3d
} def


 
%%EndProlog
gsave
%lanindL2 START  20000505
/lanind 1 def
/lantex [(G) (E) (S) (F) (I) (J) (M)] def
/showde {0 lanind eq {show} {pop} ifelse} bind def
/showen {1 lanind eq {show} {pop} ifelse} bind def
/showes {3 lanind eq {show} {pop} ifelse} bind def
/showfr {2 lanind eq {show} {pop} ifelse} bind def
/showit {4 lanind eq {show} {pop} ifelse} bind def
/showjp {5 lanind eq {show} {pop} ifelse} bind def
/showm  {6 lanind eq {show} {pop} ifelse} bind def
 
/lanindg where {pop /lanind1 lanindg def /lanind2 lanindg def}
               {/lanind1 1 def /lanind2 1 def} ifelse

/lanind lanind1 def
%lanind1 1 lanind2 {/lanind exch def %output showpage

%ps3d.inc

gsave

72 90 translate

250 -7 moveto
6 /Times-Roman FS
(DE420-7N) show

0 0 translate	
0 0 moveto
(XYZ) show 

72 72 scale

0 setlinewidth

0 setgray

newpath
2 2 moveto
1 0 rlineto
0 1 rlineto
-1 0 rlineto
closepath
fill

1 0 0 setrgbcolor

newpath
1 1 moveto
1 0 rlineto
0 1 rlineto
-1 0 rlineto
closepath
stroke


1 0 0 setrgbcolor

[0 0 5 1] set-eye

[0 1 0] 30 rotate3d

newpath
1 0 moveto
(ABC) true charpath

2d-path-convert
gsave
0.7 0 0.1 setrgbcolor
fill
grestore
stroke

%15 setlinewidth
0 1 0 setrgbcolor
0 0 0 moveto3d 10 0 0 rlineto3d 0 6.66 0 rlineto3d -10 0 0 rlineto3d
closepath stroke

newpath
0 0 1 setrgbcolor

1 1 0 moveto3d
1 0 0 rlineto3d
0 1 0 rlineto3d
-1 0 0 rlineto3d
closepath
stroke

showpage

%%Trailer


%%EndDocument
EndEPSF grestore gsave

BeginEPSF
 86 MM 108 MM translate
  10 /Times-ISOL1 FS  53 MM 1 MM moveto ( ) show 1 1 scale  -77 -91 translate
%%BeginDocument: Bild 14

%line 369
%!PS-Adobe-3.0 EPSF-3.0 DE420-4,
%%BoundingBox: 70 90 226 206

/FS {findfont exch scalefont setfont} bind def
/MM {72 25.4 div mul} def
%%EndProlog
gsave

8 /Times-Roman FS
72 83 moveto
%!2     (DE420-4,) show

72 90 translate

%! 0.01 MM 0.01 MM scale
%! 15 setlinewidth
%! 0 0  moveto 5400 0 rlineto 0 4000 rlineto -5400 0 rlineto
%! closepath stroke

grestore

showpage
%%Trailer

%%EndDocument
EndEPSF grestore gsave

BeginEPSF
 28 MM 064 MM translate
  10 /Times-ISOL1 FS  53 MM 1 MM moveto ( ) show 1 1 scale  -77 -91 translate
%%BeginDocument: Bild 15

%line 379
%!PS-Adobe-3.0 EPSF-3.0 DE420-5,
%%BoundingBox: 70 90 226 206

/FS {findfont exch scalefont setfont} bind def
/MM {72 25.4 div mul} def
%%EndProlog
gsave

8 /Times-Roman FS
72 83 moveto
%!2     (DE420-5,) show

72 90 translate

%! 0.01 MM 0.01 MM scale
%! 15 setlinewidth
%! 0 0  moveto 5400 0 rlineto 0 4000 rlineto -5400 0 rlineto
%! closepath stroke

grestore

showpage
%%Trailer

%%EndDocument
EndEPSF grestore gsave

BeginEPSF
 86 MM 064 MM translate
  10 /Times-ISOL1 FS  53 MM 1 MM moveto ( ) show 1 1 scale  -77 -91 translate
%%BeginDocument: Bild 16

%line 389
%!PS-Adobe-3.0 EPSF-3.0 DE420-6,
%%BoundingBox: 70 90 226 206

/FS {findfont exch scalefont setfont} bind def
/MM {72 25.4 div mul} def
%%EndProlog
gsave

8 /Times-Roman FS
72 83 moveto
%!2     (DE420-6,) show

72 90 translate

%! 0.01 MM 0.01 MM scale
%! 15 setlinewidth
%! 0 0  moveto 5400 0 rlineto 0 4000 rlineto -5400 0 rlineto
%! closepath stroke

grestore

showpage
%%Trailer

%%EndDocument
EndEPSF grestore gsave
BeginEPSF
 /xc1 16 def /yc1 12 def /xt 1 def xchart 1 eq {/xt 1 def} if
 28 MM xt 0 eq {16 MM sub} if 20 MM xt 0 eq {12 MM sub} if translate
  10 /Times-ISOL1 FS  53 MM 1 MM moveto ( ) show 1 1 scale  -77 -91 translate
%%BeginDocument: Bild 17

%line 399
%!PS-Adobe-3.0 EPSF-3.0 DE420-7N
%%BoundingBox: 70 85 226 206

%START PDFDE011.EPS
/pdfmark07 where {pop} {userdict /pdfmark07 /cleartomark load put} ifelse
/languagelevel where {pop languagelevel} {1} ifelse
2 lt { userdict (<<) cvn ([) cvn load put
       userdict (>>) cvn (]) cvn load put} if
[ /Title (PostScript pictures: farbe.li.tu-berlin.de/DE42/DE42.HTM)
  /Author (compare K. Richter "Computergrafik ...": ISBN 3-8007-1775-1)
  /Subject (goto: http://farbe.li.tu-berlin.de http://130.149.60.45/~farbmetrik)
  /Keywords (image reproduction, colour devices)
  /Creator (klaus.richter@mac.com)
  /CreationDate (D:2018070112000)
  /ModDate (D:20180701112000)
/DOCINFO pdfmark07
[ /View [ /Fit ]
/DOCVIEW pdfmark07
%END  PDFDE011

/BeginEPSF {% def               % Prepare for EPS file
/b4_Inc_state save def          % Save state for cleanup
/dict_count countdictstack def
/op_count count 1 sub def       % Count objects on op stack
userdict begin                  % Make userdict current dict
/showpage {} def
0 setgray 0 setlinecap
1 setlinewidth 0 setlinejoin
10 setmiterlimit [] 0 setdash newpath
/languagelevel where            % If level not equal to 1 then
 {pop languagelevel where       % If level not equal to 1 then
 1 ne
 {false setstrokeadjust false setoverprint
 } if
} if
} bind def

/EndEPSF  {% def              % End for EPS file
 count op_count sub {pop} repeat
 countdictstack dict_count sub {end} repeat	% Clean up dict stack
 b4_Inc_state restore
} bind def


% !AUSTAUSCH Times-Roman -> Times-Roman-ISOLatin1=Times-I
 
/Times-Roman findfont dup length dict  begin
{1 index /FID ne {def} {pop pop} ifelse }forall
/Encoding ISOLatin1Encoding def
currentdict end
/Times-ISOL1 exch definefont pop
 
/Times-Italic findfont dup length dict  begin
{1 index /FID ne {def} {pop pop} ifelse }forall
/Encoding ISOLatin1Encoding def
currentdict end
/TimesI-ISOL1 exch definefont pop
 
/Times-Bold findfont dup length dict  begin
{1 index /FID ne {def} {pop pop} ifelse }forall
/Encoding ISOLatin1Encoding def
currentdict end
/TimesB-ISOL1 exch definefont pop
 
/Times-BoldItalic findfont dup length dict  begin
{1 index /FID ne {def} {pop pop} ifelse }forall
/Encoding ISOLatin1Encoding def
currentdict end
/TimesBI-ISOL1 exch definefont pop
 
/FS {findfont exch scalefont setfont} bind def
/MM {72 25.4 div mul} def /str {8 string } bind def
 
/TV {150 /Times-ISOL1 FS} bind def
/TS {200 /Times-ISOL1 FS} bind def 
/TK {250 /Times-ISOL1 FS} bind def
/TM {300 /Times-ISOL1 FS} bind def
/TG {350 /Times-ISOL1 FS} bind def

/TIV {150 /TimesI-ISOL1 FS} bind def
/TIS {200 /TimesI-ISOL1 FS} bind def 
/TIK {250 /TimesI-ISOL1 FS} bind def
/TIM {300 /TimesI-ISOL1 FS} bind def
/TIG {350 /TimesI-ISOL1 FS} bind def

/TBV {150 /TimesB-ISOL1 FS} bind def
/TBS {200 /TimesB-ISOL1 FS} bind def
/TBK {250 /TimesB-ISOL1 FS} bind def
/TBM {300 /TimesB-ISOL1 FS} bind def
/TBG {350 /TimesB-ISOL1 FS} bind def

/TBIV {150 /TimesBI-ISOL1 FS} bind def
/TBIS {200 /TimesBI-ISOL1 FS} bind def
/TBIK {250 /TimesBI-ISOL1 FS} bind def
/TBIM {300 /TimesBI-ISOL1 FS} bind def
/TBIG {350 /TimesBI-ISOL1 FS} bind def

/RV {150 /Times-Roman FS} bind def
/RS {200 /Times-Roman FS} bind def
/RK {250 /Times-Roman FS} bind def
/RM {300 /Times-Roman FS} bind def
/RG {350 /Times-Roman FS} bind def

/RIV {150 /Times-Italic FS} bind def
/RIS {200 /Times-Italic FS} bind def
/RIK {250 /Times-Italic FS} bind def
/RIM {300 /Times-Italic FS} bind def
/RIG {350 /Times-Italic FS} bind def

/RBV {150 /Times-Bold FS} bind def
/RBS {200 /Times-Bold FS} bind def
/RBK {250 /Times-Bold FS} bind def
/RBM {300 /Times-Bold FS} bind def
/RBG {350 /Times-Bold FS} bind def

/RBIV {150 /Times-BoldItalic FS} bind def
/RBIS {200 /Times-BoldItalic FS} bind def
/RBIK {250 /Times-BoldItalic FS} bind def
/RBIM {300 /Times-BoldItalic FS} bind def
/RBIG {350 /Times-BoldItalic FS} bind def

/SV {150 /Symbol FS} bind def
/SS {200 /Symbol FS} bind def
/SK {250 /Symbol FS} bind def
/SM {300 /Symbol FS} bind def
/SG {350 /Symbol FS} bind def

/rec %x, y width heigth
  {/heigth exch def /width exch def
   moveto width 0 rlineto 0 heigth rlineto width neg 0 rlineto
   closepath } bind def

/rec3d %x, y width heigth
  {/heigth exch def /width exch def
   0 moveto3d width 0 0 rlineto3d 0 heigth 0 rlineto3d width neg 0 0 rlineto3d
   closepath } bind def
 
/colrecfi %x y width heigth c m y k
  {setrgbcolor rec fill} bind def
 
/colrecst %x y width heigth c m y k
  {setrgbcolor rec stroke} bind def
 
/cvishow {0.5 add cvi 6 string cvs show} def
/cvsshow1  {10 mul cvi 0.1 mul 7 string cvs show} def
/cvsshow2  {100 mul cvi 0.01 mul 7 string cvs show} def
/cvsshow3  {1000 mul cvi 0.001 mul 7 string cvs show} def
/cvsshow4  {10000 mul cvi 0.0001 mul 8 string cvs show} def

%%EndProlog
%lanindL3 START  20160701
/lanind 1 def
/lantex [(G) (E) (S) (N) (I) (J) (M)] def
/showde {0 lanind eq {show} {pop} ifelse} bind def
/showen {1 lanind eq {show} {pop} ifelse} bind def
/showes {2 lanind eq {show} {pop} ifelse} bind def
/showfr {3 lanind eq {show} {pop} ifelse} bind def
/showit {4 lanind eq {show} {pop} ifelse} bind def
/showjp {5 lanind eq {show} {pop} ifelse} bind def
/showea {1 lanind le {show} {pop} ifelse} bind def

/lanind1 01 def /lanind2 01 def /lanindd 01 def /lanindm 01 def
/xcolor1 00 def /xcolor2 00 def /xcolord 01 def /xcolorm 01 def
/xchart1 00 def /xchart2 00 def /xchartd 01 def /xchartm 01 def
/pchart1 00 def /pchart2 00 def /pchartd 01 def /pchartm 01 def
/xchart3 01 def /xchart4 00 def /xchart5 00 def

%usual change of default values
/lanindf where {pop /lanind1 lanindf  def /lanind2 lanindf  def
                    /lanindd laninddf def} if
/xcolorf where {pop /xcolor1 xcolorf  def /xcolor2 xcolorf  def
                    /xcolord xcolordf def} if
/xchartf where {pop /xchart1 xchartf  def /xchart2 xchartf  def
                    /xchartd xchartdf def} if
/pchartf where {pop /pchart1 pchartf  def /pchart2 pchartf  def
                    /pchartd pchartdf def} if
/xchart3f where {pop /xchart3 xchart3f def} if
/xchart4f where {pop /xchart4 xchart4f def} if
/xchart5f where {pop /xchart5 xchart5f def} if

/lanind lanind1 def %
/xcolor xcolor1 def %
/xchart xchart1 def %
/pchart 0 def %

%lanindL3 START  20160701
gsave

/cname1 [(C) (B) (M)] def
/cname2 [(R) (Y) (G)] def
/dshow {4 /Times-Roman FS 0 -1 rmoveto (d) show 0 1 rmoveto
        5 /Times-Roman FS} def
/gshow {RBS 0 -50 rmoveto (d) show 0 50 rmoveto RBK} def

%0 1 4 {/pchart exch def %BEG pchart=0,4

/xchart 0 def
%0 4 8 {/xchart exch def %BEG xchart=0,4,8

gsave

/xs 300 def /ys xs def /d2 xs 2 div def /d8 xs 8 div def

72 90 translate

120 -4 moveto
4 /Times-Roman FS
(DE420-7N) show

0.01 MM dup scale

15 setlinewidth

pchart 0 eq {0.5 setgray} if
pchart 1 eq {0.0 setgray} if
pchart 2 eq {1.0 setgray} if
pchart 3 eq {0 1 1 setrgbcolor} if
pchart 4 eq {1 0 0 setrgbcolor} if

0 0  moveto 5400 0 rlineto 0 4000 rlineto -5400 0 rlineto
closepath fill

0.0 setgray
0 0  moveto 5400 0 rlineto 0 4000 rlineto -5400 0 rlineto
closepath stroke

grestore
gsave

72 90 translate

/fakt 2540 4 div def

0.01 MM dup scale

0 0 translate
0 setlinewidth

0 setgray

/xtr 1000 def /ytr 0 def
xtr ytr translate

/xf 1.3 def
/xs 300 xf mul def /ys xs def /d2 xs 2 div def /d8 xs 8 div def
/ymax 3300 def
/xmin 180 xf mul def
/xd 270 xf mul def
/yd 270 xf mul def
/xsd xs xd sub 0.5 mul def
/ysd xs xd sub 0.5 mul def

/fakt 1800 25.4 mul 72 div def

0 setgray
20 setlinewidth

%3x rgbcmy
/id 1 8 div def
/rijn 81 array def %for intermediate storage
/gijn 81 array def /bijn 81 array def

/n -1 def

/lmin xchart 4 idiv def
/lmax lmin def
lmin 1 lmax {/l exch def %l=0,lmax
             /xadd 0 def
             /yadd 0 def
          
%for intermediate storage of l=0,lmax
0 1 01 {/jchart exch def %jchart=0,1
        /xchartj l jchart 3 mul add def
0 1 08 {/j exch def %j=0,7
        /im 8 j sub def
jchart 1 im {/i exch def %i=0,8
        /ia 1 id j mul sub def
        /argb ia def /brgb ia i id mul sub def
        xchartj 0 eq {/r argb def /g brgb def /b brgb def} if
        xchartj 1 eq {/r argb def /g argb def /b brgb def} if
        xchartj 2 eq {/r brgb def /g argb def /b brgb def} if
        xchartj 3 eq {/r brgb def /g argb def /b argb def} if
        xchartj 4 eq {/r brgb def /g brgb def /b argb def} if
        xchartj 5 eq {/r argb def /g brgb def /b argb def} if
        jchart 0 eq {/in i j add def /jn j def}
                    {/in j def /jn i j add def} ifelse
                     rijn in 9 mul jn add r put
                     gijn in 9 mul jn add g put
                     bijn in 9 mul jn add b put
        } for %i=0,7
        } for %j=0,8
        } for %jchart=0,1
        
%for output of l=0,lmax

%        0   1   2   3   4   5   6   7   8
/xchar [(A) (B) (C) (D) (E) (F) (G) (H) (I)] def

TS
/xa xmin xadd add def
/ya ymax yadd sub def
0.5 0.5 0.5 setrgbcolor
xa xsd sub ya xs add xsd sub xs 9 mul xs 9 mul neg rec fill

0 1 08 {/j exch def %j=0,8
0 1 08 {/i exch def %i=0,8
        /r rijn i j 9 mul add get def
        /g gijn i j 9 mul add get def
        /b bijn i j 9 mul add get def
        
        /xa xmin xs j mul add xadd add def
        /ya ymax xs i mul sub yadd sub def
        
        r g b setrgbcolor
        xa ya xd dup rec fill
        RK
        pchart 1 ne {0 setgray} {1 setgray} ifelse
        i 0 eq {xa xd 0.3 mul add ya yd 1.2 mul add moveto xchar j get show} if
        j 0 eq {xa xd 0.8 mul sub ya yd 0.3 mul add moveto i cvishow} if

        RBIK
        i 0 eq
        j 0 eq and {%left top
                    /xald xa xd 2.0 mul sub def
                    /yald ya yd 0.3 mul add def
                    xald yald moveto (W) show gshow
                   } if

        i 8 eq
        j 0 eq and {%left down
                    /xald xa xd 2.0 mul sub def
                    /yald ya yd 0.3 mul add def
                    xald yald moveto cname1 xchart 4 idiv get show gshow
                   } if
        i 0 eq
        j 8 eq and {%right up
                    /xald xa xd 1.3 mul add def
                    /yald ya yd 0.2 mul add def
                    xald yald moveto cname2 xchart 4 idiv get show gshow
                   } if

        i 8 eq
        j 8 eq and {%right down
                    /xald xa xd 1.3 mul add def
                    /yald ya yd 0.3 mul add def
                    xald yald moveto (N) show gshow
                   } if

        } for %i=0,8
        } for %j=0,8

        } for %l=0,lmax
        
xtr neg ytr neg translate
        
showpage

/ioutd 0 def
ioutd 1 eq {%ioutd=1

0 1 000010 {/j exch def
0 1 100000 {/i exch def %dummy for 1s? display time
            } for %dummy for 1s? display time
            } for %dummy

} if %ioutd=1

grestore

%} for %xchart=0,4,8

%} for %pchart=0,4

%%Trailer


%%EndDocument
EndEPSF grestore gsave

BeginEPSF  86 MM 020 MM translate 12 /Times-ISOL1 FS -9 MM -7 MM  moveto
( ) show
  10 /Times-ISOL1 FS  53 MM 1 MM moveto ( ) show 1 1 scale  -77 -91 translate
%%BeginDocument: Bild 18

%line 409
%!PS-Adobe-3.0 EPSF-3.0 DE420-8N
%%BoundingBox: 70 84 226 206

%START PDFDE011.EPS
/pdfmark08 where {pop} {userdict /pdfmark08 /cleartomark load put} ifelse
/languagelevel where {pop languagelevel} {1} ifelse
2 lt { userdict (<<) cvn ([) cvn load put
       userdict (>>) cvn (]) cvn load put} if
[ /Title (PostScript pictures: farbe.li.tu-berlin.de/DE42/DE42.HTM)
  /Author (compare K. Richter "Computergrafik ...": ISBN 3-8007-1775-1)
  /Subject (goto: http://farbe.li.tu-berlin.de http://130.149.60.45/~farbmetrik)
  /Keywords (image reproduction, colour devices)
  /Creator (klaus.richter@mac.com)
  /CreationDate (D:2018060112000)
  /ModDate (D:20180601112000)
/DOCINFO pdfmark08
[ /View [ /Fit ]
/DOCVIEW pdfmark08
%END  PDFDE011

/BeginEPSF {% def               % Prepare for EPS file
/b4_Inc_state save def          % Save state for cleanup
/dict_count countdictstack def
/op_count count 1 sub def       % Count objects on op stack
userdict begin                  % Make userdict current dict
/showpage {} def
0 setgray 0 setlinecap
1 setlinewidth 0 setlinejoin
10 setmiterlimit [] 0 setdash newpath
/languagelevel where            % If level not equal to 1 then
 {pop languagelevel where       % If level not equal to 1 then
 1 ne
 {false setstrokeadjust false setoverprint
 } if
} if
} bind def

/EndEPSF  {% def              % End for EPS file
 count op_count sub {pop} repeat
 countdictstack dict_count sub {end} repeat	% Clean up dict stack
 b4_Inc_state restore
} bind def


% !AUSTAUSCH Times-Roman -> Times-Roman-ISOLatin1=Times-I
 
/Times-Roman findfont dup length dict  begin
{1 index /FID ne {def} {pop pop} ifelse }forall
/Encoding ISOLatin1Encoding def
currentdict end
/Times-ISOL1 exch definefont pop
 
/Times-Italic findfont dup length dict  begin
{1 index /FID ne {def} {pop pop} ifelse }forall
/Encoding ISOLatin1Encoding def
currentdict end
/TimesI-ISOL1 exch definefont pop
 
/Times-Bold findfont dup length dict  begin
{1 index /FID ne {def} {pop pop} ifelse }forall
/Encoding ISOLatin1Encoding def
currentdict end
/TimesB-ISOL1 exch definefont pop
 
/Times-BoldItalic findfont dup length dict  begin
{1 index /FID ne {def} {pop pop} ifelse }forall
/Encoding ISOLatin1Encoding def
currentdict end
/TimesBI-ISOL1 exch definefont pop
 
/FS {findfont exch scalefont setfont} bind def
/MM {72 25.4 div mul} def /str {8 string } bind def
 
/TK {250 16.67 div /Times-ISOL1 FS} bind def
/TM {300 16.67 div /Times-ISOL1 FS} bind def
/TG {350 16.67 div /Times-ISOL1 FS} bind def
 
/TIK {250 16.67 div /TimesI-ISOL1 FS} bind def
/TIM {300 16.67 div /TimesI-ISOL1 FS} bind def
/TIG {350 16.67 div /TimesI-ISOL1 FS} bind def
 
/TBK {250 16.67 div /TimesB-ISOL1 FS} bind def
/TBM {300 16.67 div /TimesB-ISOL1 FS} bind def
/TBG {350 16.67 div /TimesB-ISOL1 FS} bind def
 
/TBIK {250 16.67 div /TimesBI-ISOL1 FS} bind def
/TBIM {300 16.67 div /TimesBI-ISOL1 FS} bind def
/TBIG {350 16.67 div /TimesBI-ISOL1 FS} bind def

/RK {250 16.67 div /Times-Roman FS} bind def
/RM {300 16.67 div /Times-Roman FS} bind def
/RG {350 16.67 div /Times-Roman FS} bind def

/RIK {250 16.67 div /Times-Italic FS} bind def
/RIM {300 16.67 div /Times-Italic FS} bind def
/RIG {350 16.67 div /Times-Italic FS} bind def

/RBK {250 16.67 div /Times-Bold FS} bind def
/RBM {300 16.67 div /Times-Bold FS} bind def
/RBG {350 16.67 div /Times-Bold FS} bind def

/RBIK {250 16.67 div /Times-BoldItalic FS} bind def
/RBIM {300 16.67 div /Times-BoldItalic FS} bind def
/RBIG {350 16.67 div /Times-BoldItalic FS} bind def

/rec %x, y width heigth
  {/heigth exch def /width exch def
   moveto width 0 rlineto 0 heigth rlineto width neg 0 rlineto
   closepath } bind def
 
/colrecfi %x y width heigth c m y k
  {setrgbcolor rec fill} bind def
 
/colrecst %x y width heigth c m y k
  {setrgbcolor rec stroke} bind def
 
/cvishow {0.5 add cvi 6 string cvs show} def
/cvsshow1  {10 mul cvi 0.1 mul 7 string cvs show} def
/cvsshow2  {100 mul cvi 0.01 mul 7 string cvs show} def
/cvsshow3  {1000 mul cvi 0.001 mul 7 string cvs show} def
/cvsshow4  {10000 mul cvi 0.0001 mul 8 string cvs show} def

%
% - %This is ps3d.inc ----------------------------------

% - Copyright Bill Casselman
% - Original version 1.0 November, 1998
% - Version 1.1 December, 1999
% -      Took out aliases for moveto etc.
% -      Made display-matrix a 3 x 4 homogeneous matrix, added it to the 3d gstack 
% -      Allowed arbitrary eye location, 3d -> 2d projects onto z = 0 plane
% -      Although fancy stuff not yet implemented
% -      Made ght a variable
% -      Version 1.1 is *not* backwards compatible!
% - Version 1.2 August, 2002
% -      Thorough interpretation of matrices as arrays of columns and point vectors as rows
% -      And some speed up
% -      Similar rewriting of matrix.inc
% -      Again, backwards incompatible!
% - Version 1.3 August, 2003
% -      Rewriting shade for efficiency
% - Thanks to Jim Blinn's book `A trip down the graphics pipeline'
% - for several suggestions that (I hope) made this code cleaner 
% - by suggesting how useful homogeneous coordinates were.
% November 10, 2003: added fancier shading
% December 17, 2003: changed arguments for mkpath procedures

% ------------------------------------------------


% - Inserting matrix.inc ----------------------

% - Vector calculations (usually good in any number of dimensions) ----------

% - matrices in this package are usually laid out in a single array by columns ---
% - i.e. [ column1 column 2 ... ]
% - but sometimes as a double array [ [ column1] [column2] ... ] 

% <double array>  /to-single-array
% <single-array> /to-double-array
% <n> /identity
% <u> <v> /dot-product
% <u> <c> /vector-scale
% <u> <v> /vector-add
% <u> <v> /vectorssub
% <u> /vector-length
% <u> <v> cross-product
% <axis> <angle> /rotation-matrix3d
% v [a b c] /euclidean-reflect
% [a b c] /reflection-matrix-3d
% <m> <n> /matrix-mul
% <m> <v> /matrix-vector
% <v> <m> /vector-matrix 
% <m> /transpose
% <m> 3x3-det
% <m> /3x3-inverse
% <u> <v> /angle-between
% <x> /acos
% <x> <a> <a^v> /skew-reflect
% <a> <a^v> /skew-reflection-matrix

% - matrices in this package are laid out in a single array by columns ---------

% a double array: cannot be empty - just lays out all items
/to-single-array {
% [ [. . . ][ . . . ] ] => [ . . . . . . ]
[
	exch { % successive rows
		aload pop
	} forall
]
} def

% ----------------------------------------------

% [ ... ] a square matrix made into an array of columns
/to-double-array { 4 dict begin
/A exch def
/N A length sqrt round cvi def
/i 0 def
[
N {
	[
	N {
		A i get
		/i i 1 add def
	} repeat
	]
} repeat
]
end } def

% ----------------------------------------

% returns the nxn identity matrix as single array
/identity { 1 dict begin
/n exch def
[
  n 1 sub {
    1 
    n {
      0
	} repeat 
  } repeat
  1
]
end } def

% --- vector algebra --------------------------------

% u v -> u.v
/dot-product { 1 dict begin
/v exch def
0 0	     		% u s i
3 2 roll { 		% s i u[i]
  v 			% s i u[i] v
  2 index get mul 	% s i u[i]*v[i]
  3 2 roll		% i u[i]*v[i] s
  add exch 1 add	% s i
} forall
pop
end } def

% v c -> c.v
/vector-scale { 1 dict begin
/c exch def
[ exch
{ 		% s i u[i]
  c mul			% s i u[i] v 
} forall
]
end } def

% u v -> u+v
/vector-add { 1 dict begin
/v exch def
[ exch
0 	     	% u i
exch { 		% i u[i]
  v 		% i u[i] v
  2 index get add 	% i u[i]+v[i]
  exch 1 add	% i
} forall
pop
]
end } def

% u v -> u-v
/vector-sub { 1 dict begin
/v exch def
[ exch
0 	     	% u i
exch { 		% i u[i]
  v 		% i u[i] v
  2 index get sub 	% i u[i]+v[i]
  exch 1 add	% i
} forall
pop
]
end } def

% [x y z ... ] -> r
% watch out for overflow

/vector-length { 1 dict begin
dup
% find maximum entry
/max 0 def
{ % max 
  abs dup max gt {
    % if abs gt max
    /max exch def
  } {
    pop
  } ifelse
} forall

max 0 ne {
  0 exch 
  {  % 0 v[i]
    max div dup mul add
  } forall
  sqrt
  max mul
} {
  pop 0
} ifelse
end } def

% v -> v/|v|
/normalized { 1 dict begin
dup 			% v v
vector-length /r exch def
[ exch
  {
    r div
  } forall
]
end } def

% u v
% u0 u1 u2
% v0 v1 v2
% -> u x v
/cross-product {
2 dict begin
/v exch def
/u exch def
[
  u 1 get v 2 get mul
  v 1 get u 2 get mul sub

  v 0 get u 2 get mul
  u 0 get v 2 get mul sub

  u 0 get v 1 get mul
  v 0 get u 1 get mul sub
]
end
} def

% --------------------------------------------------------------

% axis A -> a matrix
/rotation-matrix3d {
8 dict begin
dup 
cos /c exch def
sin /s exch def
/a exch def
/r a vector-length def
/a0 a 0 get r div def
/a1	a 1 get r div def
/a2 a 2 get r div def

[

% e = [1 0 0] etc.
% e0 = (e.a)a, e# = e - e0, e* = a x e = a x e0 + a x e# = a x e#
/x a0 def
/e0 [a0 x mul
     a1 x mul 
     a2 x mul] def
/e# [1 e0 0 get sub 
     e0 1 get neg 
     e0 2 get neg] def
% [a0 a1 a2]
% [ 1  0  0]
/e* [0 
     a2 
     a1 neg
    ] def
e# 0 get c mul e* 0 get s mul add e0 0 get add 
e# 1 get c mul e* 1 get s mul add e0 1 get add 
e# 2 get c mul e* 2 get s mul add e0 2 get add 

/x a1 def
/e0 [a0 x mul a1 x mul a2 x mul] def
/e# [e0 0 get neg 
     1 e0 1 get sub 
     e0 2 get neg] def
% [a0 a1 a2]
% [ 0  1  0]
/e* [a2 neg 
     0
     a0
    ] def
e# 0 get c mul e* 0 get s mul add e0 0 get add 
e# 1 get c mul e* 1 get s mul add e0 1 get add 
e# 2 get c mul e* 2 get s mul add e0 2 get add 

/x a2 def
/e0 [a0 x mul a1 x mul a2 x mul] def
/e# [e0 0 get neg
     e0 1 get neg
     1 e0 2 get sub] def
% [a0 a1 a2]
% [ 0  0  1]
/e* [a1 
     a0 neg
     0
    ] def
e# 0 get c mul e* 0 get s mul add e0 0 get add 
e# 1 get c mul e* 1 get s mul add e0 1 get add 
e# 2 get c mul e* 2 get s mul add e0 2 get add 

]
% [ r0 r1 r2 r3 r4 r5 r6 r7 r8 ] -> [r0 r3 r6 r1 r4 r7 r2 r5 r8 ]
/r exch def
[
	r 0 get 
	r 3 get
	r 6 get
	r 1 get
	r 4 get
	r 7 get
	r 2 get
	r 5 get
	r 8 get
] 
end
} def

% v a -> v - 2(a.v)/(a.a) a
/euclidean-reflect { 16 dict begin
/a exch def
/v exch def
/N a length def
/d a v dot-product a dup dot-product div 2 mul def
[
  0
  v {
    % i v[i]
    exch dup 1 add					% v[i] i i+1
	3 1 roll							  % i+1 v[i] i
    a exch get d mul 				% i+1 v[i] a[i]*d
	sub										% i+1 v[i]-d*a[i]
	exch									% rv[i] i+1
  } forall
  pop
]
end } def

% f = [A B C] => linear 3d transformation: f not necessarily normalized
% Rv = v - 2 <f', v> f'

/reflection-matrix3d {
3 dict begin
aload pop
/C exch def
/B exch def
/A exch def
/r [ A B C ] vector-length def
/A A r div def
/B B r div def
/C C r div def
[
  1 A A mul dup add sub   B A mul dup add neg   C A mul dup add neg
    A B mul dup add neg 1 B B mul dup add sub   C B mul dup add neg
    A C mul dup add neg   B C mul dup add neg 1 C C mul dup add sub
]
end
} def

/matrix-mul {
8 dict begin
/B exch def
/A exch def
/n A length sqrt round cvi def
%  0    1  ...
%  n  n+1 ...
% 2n 2n+1 ...
[
  0
  n {
    % i = initial index of the column on the stack = 0, n, 2n ... 
    % after all previous entries
    dup n add exch 0	
    n {
	  % i+n i j on stack
      % j = initial index of the row
	  2 copy 1 add % i+n i j i j+1
	  4 2 roll	% i+n i j+1 i j
	  /ell exch def
      /k exch def
	  % i+n i j+1 
      0
      n {
		% i+n i j+1 s
        A ell get B k get mul add
        /k k 1 add def
        /ell ell n add def
      } repeat
	  4 1 roll
	  % s i+n i j+1
   	} repeat
    pop pop	% s i+n
  } repeat
  pop
]
end
} def

% A v: A = [ column 1, column 2, ... , column n ]
/matrix-vector {
8 dict begin
/v exch def
/r v length def
/A exch def
/c A length r idiv def
[
  0 1 c 1 sub {
	/i exch def
    % i = initial index of the row
    0 0
    r {
		% s j on stack
		dup 1 add	% s j j+1
		3 1 roll		% j+1 s j
      	v exch get A i get mul add	% j+1 s
		exch
   	  	/i i r add def
    } repeat
	% s r
	pop
  } for
]
end
} def

% v A: A = [ column1 column2 ... ]
/vector-matrix {
8 dict begin
/A exch def
/v exch def
/c v length def
/r A length c idiv def
[
  /i 0 def 
  r {
    % i = initial index of the row
    /j 0 def
    0
    c {
      A i get v j get mul add
      /j j 1 add def
   	  /i i 1 add def
    } repeat
  } repeat
]
end
} def

% a square matrix m x m
% [i, j] = n*i + j

/transpose {
4 dict begin
/M exch def
/n M length sqrt round cvi def
[
/k 0 def
n {
  /i k def
  n { 
    M i get
    /i i n add def
  } repeat
  /k k 1 add def
} repeat
]

end
} def

/3x3-det {
1 dict begin
/m exch def

m 0 get 
m 4 get mul
m 8 get mul

m 1 get 
m 5 get mul
m 6 get mul
add

m 2 get 
m 3 get mul
m 7 get mul
add

m 2 get 
m 4 get mul
m 6 get mul
sub

m 1 get 
m 3 get mul
m 8 get mul
sub

m 0 get 
m 5 get mul
m 7 get mul
sub

end
} def

/3x3-inverse {
2 dict begin
/m exch def
/d m 3x3-det def
[
   m 4 get m 8 get mul 
   m 5 get m 7 get mul sub
   d div
   
   m 2 get m 7 get mul 
   m 1 get m 8 get mul sub
   d div
   
   m 1 get m 5 get mul 
   m 4 get m 2 get mul sub
   d div

   m 5 get m 6 get mul 
   m 3 get m 8 get mul sub
   d div
   
   m 0 get m 8 get mul 
   m 2 get m 6 get mul sub
   d div
   
   m 2 get m 3 get mul 
   m 0 get m 5 get mul sub
   d div

   m 3 get m 7 get mul 
   m 6 get m 4 get mul sub
   d div
   
   m 1 get m 6 get mul 
   m 0 get m 7 get mul sub
   d div
   
   m 0 get m 4 get mul 
   m 1 get m 3 get mul sub
   d div
]
end
} def

/acos {
dup dup % x x x
mul 1 sub neg % x 1-x^2
sqrt exch atan
} def

% u v

/angle-between {
dup vector-length
% u v |v|
3 1 roll
% |v| u v
1 index 
% |v| u v u
dot-product
% |v| u u.v
exch vector-length
% |v| u.v |u|
div exch div
acos
} def

% x a av -> x - <a, x> av

/skew-reflect { 4 dict begin
/av exch def
/a exch def
/x exch def
/d x a dot-product def
[
	0 1 x length 1 sub {
		/i exch def
		x i get av i get d mul sub
	} for
]
end } def

% a av -> matrix
/skew-reflection-matrix { 8 dict begin
/av exch def
/a exch def
/n a length def
[
	0 1 n 1 sub {
		/i exch def
		[ n {0} repeat ] dup i 1 put
		% e[i] 
		a av skew-reflect
	} for
]
to-single-array
transpose
end } def

% - closing matrix.inc ------------------------

% - Defining PostScript commands' equivalents ----------

% - Coordinates in three dimensions -------------------

% There are three steps to drawing something in 3D:
% 1.  Converting from user 3d coords to default 3d coords
% 2.  Projecting onto (x, y)-plane
% 3.  Drawing the image on that plane
% These are more or less independent.  
% The last step is completely controlled by the usual PS stuff.
% The first and second are handled by 3d stuff here.

% - Initialize and manipulate the 3d gstack -----------

/gmax 64 def
/ght 0 def

% gstack = [[t0 d0 dm0] [t1 d2 dm1] [t2 d2 dm2] ... [t(gmax-1) d(gmax-1) dm(gmax-1)] ]

% the ctm is t[ght]
% the dual ctm is at d[ght]
% they are 4 x 4
% display-matrix = 3 x 4

/gstack3d gmax array def

% start with orthogonal projection to positive z-axis
gstack3d 0 [
  [ 1 0 0 0 
    0 1 0 0
    0 0 1 0
    0 0 0 1] 
  [ 1 0 0 0 
    0 1 0 0
    0 0 1 0
    0 0 0 1]
  [ 1 0 0 0
    0 1 0 0
    0 0 0 1]
] put

/gsave3d {
  /ctm gstack3d ght get def
  /ght ght 1 add def 
  ght gmax eq {
    (3d graphics stack overflow!) ==
    quit
  } if
  gstack3d 
    ght
    [ ctm 0 get ctm 1 get ctm 2 get ] 
  put
} def

/grestore3d {
  /ght ght 1 sub def
  ght 0 lt {
     (3d graphics stack underflow!) ==
     quit
  } if
} def

% n - restores to depth n

/gpop3d {
/ght exch def
} def

% [T T* dm]: sets cgfx3d = [T T* dm]

/gset3d {
gstack3d  		% [T T* d] g 
ght			    % [T T* d] g ght
3 2 roll 		    % g ght [T T* d]
put 
} def

% => [T T* dm]

/cgfx3d {
  gstack3d ght get
} def

/ctm3d {
  gstack3d ght get 0 get
} def

/cim3d {
  gstack3d ght get 1 get
} def

/cdm3d {
  gstack3d ght get 2 get
} def

% cpt3d isthe last 3d point drawn to

/currentpoint3d {
cpt3d
cgfx3d 1 get transform3d
aload pop     % x y z w 
pop			
} def

% - Sets up projection into 2D -------------------
		
% O = [x y z w] 
% sets display-matrix perspective onto z = 0 plane

/display-matrix {
  cgfx3d 2 get
} def

% [z0 0 -x0 0
%  0 z0 -y0 0
%  0 0 -w0 z0]
% (transposed)
% gives perspective onto point in z=0 plane
% from [x0 y0 z0 w0]

/set-eye {
4 dict begin
aload pop
/w0 exch def
/z0 exch def
/y0 exch def
/x0 exch def
gstack3d ght get
2 
[ z0 0 x0 neg 0 
  0 z0 y0 neg 0
  0 0 w0 neg z0]
put
end
} def

/get-eye { 1 dict begin
/d display-matrix def
[d 2 get neg d 6 get neg d 0 get d 10 get neg]
end } def

/get-virtual-eye {
get-eye cgfx3d 1 get transform3d
} def

% - backwards compatibility -----------------------------

/origin { get-eye } def
/eye { get-eye } def
/set-display { set-eye } def

% - Manipulate the current transformation matrix -----

% x y z

/translate3d {
8 dict begin
/z exch def
/y exch def
/x exch def
/ctm cgfx3d def
/T ctm 0 get def
[
[
  T 0 get 
  T 1 get 
  T 2 get 
  T 0 get x  mul
  T 1 get y  mul
  add
  T 2 get z  mul
  add
  T 3 get 
  add
  
  T 4 get 
  T 5 get 
  T 6 get
  T 4 get x  mul
  T 5 get y  mul
  add
  T 6 get z  mul
  add
  T 7 get 
  add
   
  T 8 get 
  T 9 get 
  T 10 get
  T 8 get x  mul
  T 9 get y  mul
  add
  T 10 get z  mul
  add
  T 11 get 
  add
   
  T 12 get 
  T 13 get 
  T 14 get
  T 12 get x  mul
  T 13 get y  mul
  add
  T 14 get z  mul
  add
  T 15 get 
  add
]
/T ctm 1 get def
[
  T 0 get T 12 get x mul sub 
  T 1 get T 13 get x mul sub 
  T 2 get T 14 get x mul sub 
  T 3 get T 15 get x mul sub 

  T 4 get T 12 get y mul sub 
  T 5 get T 13 get y mul sub 
  T 6 get T 14 get y mul sub 
  T 7 get T 15 get y mul sub 

  T 8 get T 12 get z mul sub 
  T 9 get T 13 get z mul sub 
  T 10 get T 14 get z mul sub 
  T 11 get T 15 get z mul sub 

  T 12 get
  T 13 get
  T 14 get
  T 15 get
]
  ctm 2 get
]
end
gset3d
} def

% ------------------------------------------------------

% axis A

/rotate3d { 4 dict begin
rotation-matrix3d
/R exch def
/C cgfx3d def
/T C 0 get def
[
[
  % first row
  T 0 get R 0 get mul
  T 1 get R 3 get mul
  add
  T 2 get R 6 get mul
  add
  
  T 0 get R 1 get mul
  T 1 get R 4 get mul
  add
  T 2 get R 7 get mul
  add
  
  T 0 get R 2 get mul
  T 1 get R 5 get mul
  add
  T 2 get R 8 get mul
  add
  
  T 3 get
  
  % second row
  T 4 get R 0 get mul
  T 5 get R 3 get mul
  add
  T 6 get R 6 get mul
  add
  
  T 4 get R 1 get mul
  T 5 get R 4 get mul
  add
  T 6 get R 7 get mul
  add
  
  T 4 get R 2 get mul
  T 5 get R 5 get mul
  add
  T 6 get R 8 get mul
  add
  
  T 7 get
  
  % third row
  T 8 get R 0 get mul
  T 9 get R 3 get mul
  add
  T 10 get R 6 get mul
  add
  
  T 8 get R 1 get mul
  T 9 get R 4 get mul
  add
  T 10 get R 7 get mul
  add
  
  T 8 get R 2 get mul
  T 9 get R 5 get mul
  add
  T 10 get R 8 get mul
  add
  
  T 11 get
  
  % fourth row
  T 12 get R 0 get mul
  T 13 get R 3 get mul
  add
  T 14 get R 6 get mul
  add
  
  T 12 get R 1 get mul
  T 13 get R 4 get mul
  add
  T 14 get R 7 get mul
  add
  
  T 12 get R 2 get mul
  T 13 get R 5 get mul
  add
  T 14 get R 8 get mul
  add
  
  T 15 get
]
/T C 1 get def
% T = T^-1
% => R^-1 T^-1 
[
  R 0 get T 0 get mul
  R 3 get T 4 get mul add
  R 6 get T 8 get mul add
  
  R 0 get T 1 get mul
  R 3 get T 5 get mul add
  R 6 get T 9 get mul add
  
  R 0 get T 2 get mul
  R 3 get T 6 get mul add
  R 6 get T 10 get mul add
  
  R 0 get T 3 get mul
  R 3 get T 7 get mul add
  R 6 get T 11 get mul add
  
  % ------------------------
  
  R 1 get T 0 get mul
  R 4 get T 4 get mul add
  R 7 get T 8 get mul add
  
  R 1 get T 1 get mul
  R 4 get T 5 get mul add
  R 7 get T 9 get mul add
  
  R 1 get T 2 get mul
  R 4 get T 6 get mul add
  R 7 get T 10 get mul add
  
  R 1 get T 3 get mul
  R 4 get T 7 get mul add
  R 7 get T 11 get mul add
  
  % ------------------------
  
  R 2 get T 0 get mul
  R 5 get T 4 get mul add
  R 8 get T 8 get mul add
  
  R 2 get T 1 get mul
  R 5 get T 5 get mul add
  R 8 get T 9 get mul add
  
  R 2 get T 2 get mul
  R 5 get T 6 get mul add
  R 8 get T 10 get mul add
  
  R 2 get T 3 get mul
  R 5 get T 7 get mul add
  R 8 get T 11 get mul add

  T 12 get
  T 13 get
  T 14 get
  T 15 get  
]
  C 2 get
]
end
gset3d
} def


% f = [A B C D] P
% f = 0 is the *affine* reflection plane
% v = v* + v0 with v* on f = 0 and v0 in P-direction => v* - v0
% The map is Q => f(P)*Q - 2*f(Q)P
% It is of order two.
%
% f(P) I -
%
% 2A*P[0] 2B*P[0] 2C*P[0] 2D*P[0]
% 2A*P[1] 2B*P[1] 2C*P[1] 2D*P[1]
% 2A*P[2] 2B*P[2] 2C*P[2] 2D*P[2]
% 2A*P[3] 2B*P[3] 2C*P[3] 2D*P[3]
%
% Matrix = f(P) I - P f
% set s0 = (T row 0)*P
% T x this =
% f(P)T[0,0]-A*s -B*s -C*s -D*s

/affine-reflect3d { 4 dict begin
aload pop
/P3 exch def
/P2 exch def
/P1 exch def
/P0 exch def
aload pop
/D exch def
/C exch def
/B exch def
/A exch def

/fP 
  A P0 mul 
  B P1 mul add
  C P2 mul add
  D P3 mul add
def
/A A dup add def
/B B dup add def
/C C dup add def
/D D dup add def
[
/T cgfx3d 0 get def
[
  /s % = (T row 1)*P
  T 0 get P0 mul
  T 1 get P1 mul add
  T 2 get P2 mul add
  T 3 get P3 mul add
  def
  
  fP T 0 get mul
    A s mul sub
  fP T 1 get mul
    B s mul sub
  fP T 2 get mul
    C s mul sub
  fP T 3 get mul
    D s mul sub

  /s % = (T row 1)*P
  T 4 get P0 mul
  T 5 get P1 mul add
  T 6 get P2 mul add
  T 7 get P3 mul add
  def
  
  fP T 4 get mul
    A s mul sub
  fP T 5 get mul
    B s mul sub
  fP T 6 get mul
    C s mul sub
  fP T 7 get mul
    D s mul sub

  /s % = (T row 2)*P
  T 8 get P0 mul
  T 9 get P1 mul add
  T 10 get P2 mul add
  T 11 get P3 mul add
  def
  
  fP T 8 get mul
    A s mul sub
  fP T 9 get mul
    B s mul sub
  fP T 10 get mul
    C s mul sub
  fP T 11 get mul
    D s mul sub

  /s % = (T row 3)*P
  T 12 get P0 mul
  T 13 get P1 mul add
  T 14 get P2 mul add
  T 15 get P3 mul add
  def
  
  fP T 12 get mul
    A s mul sub
  fP T 13 get mul
    B s mul sub
  fP T 14 get mul
    C s mul sub
  fP T 15 get mul
    D s mul sub
]
/T cgfx3d 1 get def
/f0 		
  % f paired with columns of T
  T 0 get A mul
  T 4 get B mul add
  T 8 get C mul add
  T 12 get D mul add
def

/f1 		
  % f paired with columns of T
  T 1 get A mul
  T 5 get B mul add
  T 9 get C mul add
  T 13 get D mul add
def

/f2 		
  % f paired with columns of T
  T 2 get A mul
  T 6 get B mul add
  T 10 get C mul add
  T 14 get D mul add
def

/f3 		
  % f paired with columns of T
  T 3 get A mul
  T 7 get B mul add
  T 11 get C mul add
  T 15 get D mul add
def

[
  fP T 0 get mul
    f0 P0 get mul sub
  fP T 1 get mul
    f1 P0 get mul sub
  fP T 2 get mul
    f2 P0 get mul sub
  fP T 3 get mul
    f3 P0 get mul sub
  fP T 4 get mul
    f0 P1 get mul sub
  fP T 5 get mul
    f1 P1 get mul sub
  fP T 6 get mul
    f2 P1 get mul sub
  fP T 7 get mul
    f3 P1 get mul sub
  fP T 8 get mul
    f0 P2 get mul sub
  fP T 9 get mul
    f1 P2 get mul sub
  fP T 10 get mul
    f2 P2 get mul sub
  fP T 11 get mul
    f3 P2 get mul sub
  fP T 12 get mul
    f0 P3 get mul sub
  fP T 13 get mul
    f1 P3 get mul sub
  fP T 14 get mul
    f2 P3 get mul sub
  fP T 15 get mul
    f3 P3 get mul sub
]
  cgfx3d 2 get
] 
end
gset3d
} def

% 3x3 M 

/concat3d {
4 dict begin
/M exch def
[
/T cgfx3d 0 get def
  [
    T 0 get M 0 get mul
    T 1 get M 3 get mul add
    T 2 get M 6 get mul add

    T 0 get M 1 get mul
    T 1 get M 4 get mul add
    T 2 get M 7 get mul add
     
    T 0 get M 2 get mul
    T 1 get M 5 get mul add
    T 2 get M 8 get mul add
    
    T 3 get
     
    T 4 get M 0 get mul
    T 5 get M 3 get mul add
    T 6 get M 6 get mul add

    T 4 get M 1 get mul
    T 5 get M 4 get mul add
    T 6 get M 7 get mul add
     
    T 4 get M 2 get mul
    T 5 get M 5 get mul add
    T 6 get M 8 get mul add
    
    T 7 get
     
    T 8 get M 0 get mul
    T 9 get M 3 get mul add
    T 10 get M 6 get mul add

    T 8 get M 1 get mul
    T 9 get M 4 get mul add
    T 10 get M 7 get mul add
     
    T 8 get M 2 get mul
    T 9 get M 5 get mul add
    T 10 get M 8 get mul add
    
    T 11 get
     
    T 12 get M 0 get mul
    T 13 get M 3 get mul add
    T 14 get M 6 get mul add

    T 12 get M 1 get mul
    T 13 get M 4 get mul add
    T 14 get M 7 get mul add
     
    T 12 get M 2 get mul
    T 13 get M 5 get mul add
    T 14 get M 8 get mul add
    
    T 15 get
     
  ]
/T cgfx3d 1 get def
/M M 3x3-inverse def
  [
    M 0 get T 0 get mul
    M 1 get T 4 get mul add
    M 2 get T 8 get mul add
    
    M 0 get T 1 get mul
    M 1 get T 5 get mul add
    M 2 get T 9 get mul add
    
    M 0 get T 2 get mul
    M 1 get T 6 get mul add
    M 2 get T 10 get mul add
    
    M 0 get T 3 get mul
    M 1 get T 7 get mul add
    M 2 get T 11 get mul add
    
    % -----------------------------
    
    M 3 get T 0 get mul
    M 4 get T 4 get mul add
    M 5 get T 8 get mul add
    
    M 3 get T 1 get mul
    M 4 get T 5 get mul add
    M 5 get T 9 get mul add
    
    M 3 get T 2 get mul
    M 4 get T 6 get mul add
    M 5 get T 10 get mul add
    
    M 3 get T 3 get mul
    M 4 get T 7 get mul add
    M 5 get T 11 get mul add
    
    % -----------------------------
    
    M 6 get T 0 get mul
    M 7 get T 4 get mul add
    M 8 get T 8 get mul add
    
    M 6 get T 1 get mul
    M 7 get T 5 get mul add
    M 8 get T 9 get mul add
    
    M 6 get T 2 get mul
    M 7 get T 6 get mul add
    M 8 get T 10 get mul add
    
    M 6 get T 3 get mul
    M 7 get T 7 get mul add
    M 8 get T 11 get mul add
    
    % -----------------------------
    
    T 12 get
    T 13 get
    T 14 get
    T 15 get
  ]
  cgfx3d 2 get
]
end
gset3d
} def

%
% v => v - 2 <v, a> a
%
% Matrix = I - 2 a a
% a

/reflect3d { 4 dict begin
reflection-matrix3d 
concat3d
end } def

% [x y z w] [a00 a01 a02 a03 ... ]
% but the vector is a linear function
% so it is multiplying by transpose
% if T is the current ctm3d, the point P -> P T transform3d
% but the plane f=0 -> f T^{-1} dual-transform3d

/dual-transform3d { 4 dict begin
/v exch def
/T exch def
[
  v 0 get T 0 get mul
  v 1 get T 4 get mul add
  v 2 get T 8 get mul add
  v 3 get T 12 get mul add
  
  v 0 get T 1 get mul
  v 1 get T 5 get mul add
  v 2 get T 9 get mul add
  v 3 get T 13 get mul add
  
  v 0 get T 2 get mul
  v 1 get T 6 get mul add
  v 2 get T 10 get mul add
  v 3 get T 14 get mul add
  
  v 0 get T 3 get mul
  v 1 get T 7 get mul add
  v 2 get T 11 get mul add
  v 3 get T 15 get mul add
]
end } def

% 4d to 3d homogeneous
/project3d { 4 dict begin
/T exch def
/v exch def
[
  T 0 get v 0 get mul
  T 1 get v 1 get mul
  add 
  T 2 get v 2 get mul 
  add
  T 3 get v 3 get mul 
  add

  T 4 get v 0 get mul
  T 5 get v 1 get mul
  add 
  T 6 get v 2 get mul 
  add
  T 7 get v 3 get mul 
  add

  T 8 get v 0 get mul
  T 9 get v 1 get mul
  add 
  T 10 get v 2 get mul 
  add
  T 11 get v 3 get mul 
  add
] 
end } def

% [x y z w] [a00 a01 a02 a03 ... ]

/transform3d {
4 dict begin
/T exch def
/v exch def
[
T 0 get v 0 get mul
T 1 get v 1 get mul
add 
T 2 get v 2 get mul 
add
T 3 get v 3 get mul 
add

T 4 get v 0 get mul
T 5 get v 1 get mul
add 
T 6 get v 2 get mul 
add
T 7 get v 3 get mul 
add

T 8 get v 0 get mul
T 9 get v 1 get mul
add 
T 10 get v 2 get mul 
add
T 11 get v 3 get mul 
add

T 12 get v 0 get mul
T 13 get v 1 get mul
add 
T 14 get v 2 get mul 
add
T 15 get v 3 get mul 
add

] 
end
} def

% sx sy sz

/scale3d {
8 dict begin
/sz exch def
/sy exch def
/sx exch def
/T cgfx3d 0 get def
[
[
  T 0 get sx mul
  T 1 get sy mul
  T 2 get sz mul
  T 3 get 
  
  T 4 get sx mul
  T 5 get sy mul
  T 6 get sz mul
  T 7 get 
  
  T 8 get sx mul
  T 9 get sy mul
  T 10 get sz mul
  T 11 get 
 
  T 12 get sx mul
  T 13 get sy mul
  T 14 get sz mul
  T 15 get 
]
/T cgfx3d 1 get def
[
  T 0 get sx div
  T 1 get sx div
  T 2 get sx div
  T 3 get sx div
  
  T 4 get sy div
  T 5 get sy div
  T 6 get sy div
  T 7 get sy div
  
  T 8 get sz div
  T 9 get sz div
  T 10 get sz div
  T 11 get sz div
 
  T 12 get 
  T 13 get 
  T 14 get 
  T 15 get 
]
  cgfx3d 2 get
]
end
gset3d
} def

% [ <9> ] i

/row {
4 dict begin
/i exch def
/a exch def
a length 9 eq {
  /i i 3 mul def
  /n i 2 add def
} {
  /i i 4 mul def
  /n i 3 add def
} ifelse
[
  i 1 n {
    a exch get
  } for
]
end
} def

% projects from P onto f=Ax+By+Cz+D=0
% two parameters: f = [A B C D] and P
% The map is Q => f(P)*Q - f(Q)P
% It is idempotent.
%
% f(P) I -
%
% A*P[0] A*P[1] A*P[2] A*P[3]
% B*P[0] B*P[1] B*P[2] B*P[3]
% C*P[0] C*P[1] C*P[2] C*P[3]
% D*P[0] D*P[1] D*P[2] D*P[3]
%
% Matrix = f(P) I - P f
% set s0 = (T row 0)*P
% T x this =
% f(P)T[0,0]-A*s -B*s -C*s -D*s

/plane-project {
12 dict begin
aload pop
/P3 exch def
/P2 exch def
/P1 exch def
/P0 exch def
aload pop
/D exch def
/C exch def
/B exch def
/A exch def

/fP 
  A P0 mul 
  B P1 mul add
  C P2 mul add
  D P3 mul add
def
[
/T cgfx3d 0 get def
[
  /s % = (T row 0)*P
  	T 0 get P0 mul
  	T 1 get P1 mul add
  	T 2 get P2 mul add
  	T 3 get P3 mul add
  def
  
  fP T 0 get mul
    A s mul sub
  fP T 1 get mul
    B s mul sub
  fP T 2 get mul
    C s mul sub
  fP T 3 get mul
    D s mul sub


  /s % = (T row 1)*P
  T 4 get P0 mul
  T 5 get P1 mul add
  T 6 get P2 mul add
  T 7 get P3 mul add
  def
  
  fP T 4 get mul
    A s mul sub
  fP T 5 get mul
    B s mul sub
  fP T 6 get mul
    C s mul sub
  fP T 7 get mul
    D s mul sub


  /s % = (T row 2)*P
  T 8 get P0 mul
  T 9 get P1 mul add
  T 10 get P2 mul add
  T 11 get P3 mul add
  def
  
  fP T 8 get mul
    A s mul sub
  fP T 9 get mul
    B s mul sub
  fP T 10 get mul
    C s mul sub
  fP T 11 get mul
    D s mul sub

  /s % = (T row 3)*P
  T 12 get P0 mul
  T 13 get P1 mul add
  T 14 get P2 mul add
  T 15 get P3 mul add
  def
  
  fP T 12 get mul
    A s mul sub
  fP T 13 get mul
    B s mul sub
  fP T 14 get mul
    C s mul sub
  fP T 15 get mul
    D s mul sub
]
/T cgfx3d 1 get def
[
  /s T 0 get T 1 get add T 2 get add T 3 get add def
  s A mul
  s B mul
  s C mul
  s D mul
  /s T 4 get T 5 get add T 6 get add T 7 get add def
  s A mul
  s B mul
  s C mul
  s D mul
  /s T 8 get T 9 get add T 10 get add T 11 get add def
  s A mul
  s B mul
  s C mul
  s D mul
  /s T 12 get T 13 get add T 14 get add T 15 get add def
  s A mul
  s B mul
  s C mul
  s D mul
]
  cgfx3d 2 get
] 
end
gset3d
} def

% - Drawing commands in 3D --------------------------

% P displayed = [x y w z] => [X Y W] -> [X/W Y/W]

/render {
8 dict begin
aload pop
/v3 exch def
/v2 exch def
/v1 exch def
/v0 exch def
/T display-matrix def
/x
  T 0 get v0 mul 
  T 1 get v1 mul add
  T 2 get v2 mul add
  T 3 get v3 mul add
def
/y 
  T 4 get v0 mul 
  T 5 get v1 mul add
  T 6 get v2 mul add
  T 7 get v3 mul add
def
/w 
  T 8 get v0 mul 
  T 9 get v1 mul add
  T 10 get v2 mul add
  T 11 get v3 mul add
def
w 0 eq {
  (Perspective: division by zero!) ==
  quit
} if
x w div
y w div
end
} def

%  x y z -> x y
/transformto2d {
[ 4 1 roll 1 ] ctm3d transform3d render 
} def

/cpt3d 4 array def
/lm3d 4 array def

% cpt3d is a point in the "real" 3d world

% Should we build the current 3d path for reuse?

% x y z
/moveto3d {
1 [ 5 1 roll ] 
cgfx3d 0 get 
transform3d 
aload pop cpt3d astore 
render moveto
cpt3d aload pop lm3d astore pop
} def

% x y z

/lineto3d {
1 [ 5 1 roll ] 
cgfx3d 0 get 
transform3d 
aload pop cpt3d astore 
render lineto
} def

% x y z

/rmoveto3d {
0 [ 5 1 roll ] cgfx3d 0 get
transform3d 			% [dx dy dz 0]
dup 0 get cpt3d 0 get add	% [dx dy dz 0] x+dx
exch 
dup 1 get cpt3d 1 get add	% x+dx [dx dy dz dw] y+dy
exch
dup 2 get cpt3d 2 get add	% x+dx x+dy [dx dy dz dw] z+dz
exch				% x+dx y+dy z+dz [dx dy dz dw]
3 get cpt3d 3 get add		% x+dx x+dy z+dz w+dw
cpt3d astore
render moveto
cpt3d aload pop lm3d astore pop
} def

% x y z

/rlineto3d {
0 [ 5 1 roll ] cgfx3d 0 get
transform3d 		% [dx dy dz 0]
dup 0 get cpt3d 0 get add	% [dx dy dz 0] x+dx
exch 
dup 1 get cpt3d 1 get add	% x+dx [dx dy dz dw] y+dy
exch
dup 2 get cpt3d 2 get add	% x+dx x+dy [dx dy dz dw] z+dz
exch				% x+dx y+dy z+dz [dx dy dz dw]
3 get cpt3d 3 get add		% x+dx x+dy z+dz w+dw
cpt3d astore  
render lineto
} def

% x1 y1 z1 x2 y2 z2 x3 y3 z3 

/curveto3d { 16 dict begin
/z3 exch def
/y3 exch def
/x3 exch def
/z2 exch def
/y2 exch def
/x2 exch def
/z1 exch def
/y1 exch def
/x1 exch def
% F(t) 
/P0 cpt3d display-matrix project3d def
/P1 [x1 y1 z1 1] cgfx3d 0 get transform3d display-matrix project3d def
/w P0 2 get def
/c P1 2 get w div 1 sub def
/x0 P0 0 get w div def
/x1 P1 0 get w div def
/y0 P0 1 get w div def
/y1 P1 1 get w div def
x1 x0 c mul sub 
y1 y0 c mul sub 
[x3 y3 z3 1] cgfx3d 0 get transform3d aload pop cpt3d astore 
display-matrix project3d /P3 exch def
/P2 [x2 y2 z2 1] cgfx3d 0 get transform3d display-matrix project3d def
% We are assuming the display-matrix has images on { z = 0 }
/w P3 2 get def
/c P2 2 get w div 1 sub def
/x3 P3 0 get w div def
/x2 P2 0 get w div def
/y3 P3 1 get w div def
/y2 P2 1 get w div def
x2 x3 c mul sub 
y2 y3 c mul sub 
x3 y3
curveto
end } def

% - are the next two used? --------------------------------

% dP dQ Q

/dcurveto3d { 16 dict begin
/z3 exch def
/y3 exch def
/x3 exch def
/dz3 exch def
/dy3 exch def
/dx3 exch def
/dz0 exch def
/dy0 exch def
/dx0 exch def
/P0 cpt3d display-matrix project3d def
/dP0 [dx0 dy0 dz0 0] cgfx3d 0 get transform3d display-matrix project3d def
/w P0 3 get def 
% c = 1 - w'/w
/c 1 dP0 3 get w div sub def
  P0 0 get w div c mul dP0 0 get w div add
  P0 1 get w div c mul dP0 1 get w div add
[x3 y3 z3 1] cgfx3d 0 get transform3d aload pop cpt3d astore 
display-matrix project3d /P3 exch def
/dP3 [dx3 dy3 dz3 0] cgfx3d 0 get transform3d display-matrix project3d def
/w P3 3 get def
/c 1 dP3 3 get w div add def
  P3 0 get w div c mul dP3 0 get w div sub
  P3 1 get w div c mul dP3 1 get w div sub
  P3 0 get w div
  P3 1 get w div
curveto
end
} def

% dP dQ Q

/dcurveto { 8 dict begin
/y3 exch def
/x3 exch def
/dy3 exch def
/dx3 exch def
/dy0 exch def
/dx0 exch def
currentpoint dy0 add exch dx0 add exch
x3 dx3 sub y3 dy3 sub
x3 y3 
curveto
end } def

% - are the above two used? ----------------------------

/closepath3d {
closepath
lm3d aload pop cpt3d astore pop
} def

% - Conversion from 2d to 3D ---------------------------

/2d-path-convert {
[
  { % x y
    [ 3 1 roll 0 {moveto3d}]
  }
  { % x y
    [ 3 1 roll 0 {lineto3d}]
  }
  { % x1 y1 x2 y2 x3 y3
    [ 7 1 roll
    0 5 1 roll
    0 3 1 roll
    0 {curveto3d} ]
  }
  {
    [ {closepath3d} ]
  }
  pathforall
]
newpath
{
  aload pop exec
} forall
} def

% -----------------------------------------------

% For a simple currentpoint:

/mkpath3dDict 8 dict def

mkpath3dDict begin

/pathcount {
0 
{pop pop 
  pop 1 exit}
{pop pop 
  pop 1 exit}
{pop pop pop pop pop pop 
  pop 1 exit}
{ pop 1 exit}
pathforall
} def

/thereisacurrentpoint {
pathcount
0 gt
{true}
{false}
ifelse
} def

end

% ---------------------------------------------

% stack: t0 t1 N [parameters] /f 

/mkpath3d { load 
/f exch def
/pars exch def
12 dict begin
/N exch def
/t1 exch def
/t exch def

/h t1 t sub N div def
/h3 h 0.333333 mul def

pars t f aload pop
/velocity exch def
/position exch def
/p [ position aload pop 1 ] 
cgfx3d 0 get transform3d display-matrix project3d def
/v [ velocity aload pop 0 ] 
cgfx3d 0 get transform3d display-matrix project3d def

% p v = homogeneous position and velocity
% p/p[3] v/p[3] - (v[3]/p[3])(p/p[3]) = inhomogeneous ones
% = p/w v/w - c*p/w

/w p 3 get def
/c v 3 get w div def
thereisacurrentpoint {
  p 0 get w div p 1 get w div lineto
} {
  p 0 get w div p 1 get w div moveto
} ifelse

N {				% x y = currentpoint
  p 0 get 
    v 0 get 
    p 0 get c mul 
    sub 
    h3 mul 
  add 
  w div
  
  p 1 get 
    v 1 get 
    p 1 get c mul 
    sub 
    h3 mul 
  add
  w div

/t t h add def

pars t f aload pop
/velocity exch def
/position exch def
/p [ position aload pop 1 ] 
cgfx3d 0 get transform3d display-matrix project3d def
/v [ velocity aload pop 0 ] 
cgfx3d 0 get transform3d display-matrix project3d def
/w p 3 get def
/c v 3 get w div def

  p 0 get 
    v 0 get 
    p 0 get c mul 
    sub 
    h3 mul 
  sub 
  w div
  
  p 1 get 
    v 1 get 
    p 1 get c mul 
    sub 
    h3 mul 
  sub
  w div

p 0 get w div
p 1 get w div
curveto

} repeat
end % local dict
} def

% makes polygon out of control points

/mkcontrolpath3d { load
mkpath3dDict begin
1 dict begin
/f exch def
/pars exch def
/N exch def
/t1 exch def
/t exch def

/h t1 t sub N div def
/h3 h 0.333333 mul def

pars t f aload pop
/velocity exch def
/position exch def

position aload pop
thereisacurrentpoint {
	lineto3d
} {
	moveto3d
} ifelse

N {				% x y = currentpoint
% currentpoint pixel pop

position 0 get
velocity 0 get		% x dx/dt
h3 mul add
position 1 get
velocity 1 get		% y dy/dt
h3 mul add
position 2 get
velocity 2 get		% z dz/dt
h3 mul add

lineto3d

/t t h add def

pars t f aload pop
/velocity exch def
/position exch def

position 0 get
velocity 0 get 
h3 mul sub
position 1 get
velocity 1 get 
h3 mul sub
position 2 get
velocity 2 get 
h3 mul sub

lineto3d

position 0 get
position 1 get
position 2 get

lineto3d

} repeat
end % local dict
end % mkpath3d dict
} def

% -----------------------------------------------

% makes polygon from endpoints

/mkpolypath3d { load
/f exch def
/pars exch def
mkpath3dDict begin
1 dict begin
/N exch def
/t1 exch def
/t exch def

/h t1 t sub N div def
/h3 h 0.333333 mul def

pars t f aload pop
/velocity exch def
/position exch def

position aload pop
thereisacurrentpoint {
	lineto3d
} {
	moveto3d
} ifelse

N {				% x y = currentpoint
% currentpoint pixel pop

/t t h add def

pars t f aload pop
/velocity exch def
/position exch def

position 0 get
position 1 get
position 2 get
lineto3d

} repeat
end % local dict
end % mkpath3d dict
} def

% ---------------------------------------------

% length width

/plainarrow3d {
5 dict begin
/shaftwidth exch def
/arrowlength exch def
/headwidth shaftwidth 3 mul def
/headlength headwidth def
/shaftlength arrowlength shaftwidth 2.5 mul sub def
0 0 0 moveto3d
0 shaftwidth 0.5 mul 0 lineto3d
% shaftlength 0 0 rlineto3d
shaftlength shaftwidth 0.5 mul 0 lineto3d
arrowlength headlength sub headwidth 0.5 mul 0 lineto3d
arrowlength 0 0 lineto3d
arrowlength headlength sub headwidth -0.5 mul 0 lineto3d
shaftlength shaftwidth -0.5 mul 0 lineto3d
0 shaftwidth -0.5 mul 0 lineto3d
0 0 0 lineto3d
end
} def

% length width

/plainarrowtail3d {
5 dict begin
/shaftwidth exch def
/arrowlength exch def
0 0 0 moveto3d
0 shaftwidth 0.5 mul 0 lineto3d
arrowlength 0 0 rlineto3d
0 shaftwidth neg 0 rlineto3d
arrowlength neg 0 0 rlineto3d
0 0 0 lineto3d
end
} def

% --- shading ------------------------------------------------------------------

% all the shade input routines have as one argument a number between -1 and 1
% the result of a calculation of the dot-product of two unit vectors

% linear interpolation: s [a b] -> a + (b-a)*t

/lshade { % s [a b]
exch 1 add 2 div 	% t in [0 1]
% [a b] t
exch aload 0 get		% t a b a
4 1 roll 				% a t a b
sub mul sub			% a - t(a-b)
} def

%  # in [-1 1] & coefficient array [A B C D]: 
% A etc = control points, A = min, D = max
% 1 = facing towards, -1 = facing away from light
% x -> (x+1)/2 = 0.5(x+1) takes [-1, 1] -> [0, 1]
% evaluate by Horner's method

/shade {                             % t [array]
exch                                 % [array] t
1 add 0.5 mul 	                     % a t now in [0 1]
1 1 index sub                        % a t s=1-t
dup dup mul                          % a t s s^2
dup 2 index mul                      % a t s s^2 s^3
5 -1 roll aload pop                  % t s s^2 s^3 a0 a1 a2 a3=P0
7 index mul                          % t s s^2 s^3 a0 a1 a2 a3.t
exch                                 % t s s^2 s^3 a0 a1 a3.t a2
7 -1 roll                            % t s^2 s^3 a0 a1 a3.t a2 s
mul 3 mul add                        % t s^2 s^3 a0 a1 a3.t+3.a2.s=P1
5 index mul                          % t s^2 s^3 a0 a1 P1.t
exch                                 % t s^2 s^3 a0 P1.t a1
5 -1 roll                            % t s^3 a0 P1.t a1 s^2
mul 3 mul add                        % t s^3 a0 P1.t+3.a1.s^2=P2
4 -1 roll mul                        % s^3 a0 P2.t
3 1 roll mul add                     % P2.t + a0.s^3=P3
} def

% t y=[ y0 y1 ... yn ]
/bernstein { % t y 
  % constants y n t s=1-t
  % variables k C P
  dup length % t y n+1
  1 sub      % t y n
  3 -1 roll 1 % y n t 1
  1 index sub % y n t s
  % constants in place
  1           % y n t s k
  3 index 3 index mul % y n t s k C=nt
  5 index 0 get       % y n t s k C P=y0
  5 index {           % y n t s k C P
    % P -> s.P + C.y[k]
    % C -> C.t.(n-k)/(k+1) 
    % k -> k+1
    3 index mul       % y n t s k C P.s
    1 index           % y n t s k C P.s C
    7 index           % y n t s k C P.s C y 
    4 index get mul add  % y n t s k C P.s+C.y[k]=new P
    3 1 roll          % y n t s P* k C
    5 index           % y n t s P* k C n
    2 index sub mul   % y n t s P* k C.(n-k)
    1 index 1 add div % y n t s P* k C.(n-k)/(k+1)
    4 index mul       % y n t s P* k C*
    3 1 roll 1 add    % y n t s C* P* k*
    3 1 roll          % y n t s k* C* P*
  } repeat
  7 1 roll 6 { pop } repeat
} def

% shading: s in [-1 1] and y a Bernstein array B -> t -> B(t)
/bshade { exch 
1 add 2 div 
exch bernstein
} def

% ---------------------------------------------------------------------------------

% input: [pars] /fcn s0 s1 t0 t1 ns nt
% the fcn: [pars] s t -> f_{pars}(s, t)
% output: a polygonal surface of faces [ normal-fcn triangle ]

/mksurface {
16 dict begin
/nt exch def
/ns exch def
/t1 exch def
/t0 exch def
/s1 exch def
/s0 exch def
/ds s1 s0 sub ns div def
/dt t1 t0 sub nt div def
/f exch cvx def
/pars exch def
/P [
  /s s0 def
  ns 1 add {
    [
      /t t0 def
      nt 1 add {
        pars s t f
        /t t dt add def
      } repeat
    ]
    /s s ds add def
  } repeat
] def
% P[i][j] = f(s0 + i.ds, t0 + j.dt)
[
  0 1 ns 1 sub {
    /i exch def
    0 1 nt 1 sub {
      /j exch def
      % an array of triangles (i, j, 0) + (i, j, 1) 
      % dividing the rectangles in two
      /P00 P i get j get def
      /P10 P i 1 add get j get def
      /P01 P i get j 1 add get def
      /P11 P i 1 add get j 1 add get def
      % normal
      /Q P10 P00 vector-sub P01 P00 vector-sub cross-product def
      /r Q vector-length def
      r 0 ne {
        [
          [ Q aload pop Q P10 dot-product neg ]
          % array of pointers to three vertices
          [ P00 P10 P01 ]
        ] 
      } if
      /Q P01 P11 vector-sub P10 P11 vector-sub cross-product def
      /r Q vector-length def
      r 0 ne {
        [
          [ Q aload pop Q P01 dot-product neg ]
          % array of pointers to three vertices
          [ P10 P11 P01 ]
        ]
      } if
    } for
  } for
]
end
} def

% an array of vertices 
% traversed according to right hand rule
% output normalized

/normal-function {
2 dict begin
/a exch def
/n 
  a 1 get a 0 get vector-sub 
  a 2 get a 1 get vector-sub 
  cross-product 
def
/r n 0 get dup mul n 1 get dup mul add n 2 get dup mul add sqrt def
r 0 gt {
  /n [ n 0 get r div n 1 get r div n 2 get r div ] def
  [
    n aload pop
    a 0 get n dot-product neg
  ]
}{ [] } ifelse
end
} def

% --- light ------------------------------------------------

% should be part of the graphics environment

/set-light { /light-source exch def } def

/get-virtual-light {
  light-source cgfx3d 1 get transform3d
} def


 
%%EndProlog
gsave
%lanindL2 START  20000505
/lanind 1 def
/lantex [(G) (E) (S) (F) (I) (J) (M)] def
/showde {0 lanind eq {show} {pop} ifelse} bind def
/showen {1 lanind eq {show} {pop} ifelse} bind def
/showes {3 lanind eq {show} {pop} ifelse} bind def
/showfr {2 lanind eq {show} {pop} ifelse} bind def
/showit {4 lanind eq {show} {pop} ifelse} bind def
/showjp {5 lanind eq {show} {pop} ifelse} bind def
/showm  {6 lanind eq {show} {pop} ifelse} bind def
 
/lanindg where {pop /lanind1 lanindg def /lanind2 lanindg def}
               {/lanind1 1 def /lanind2 1 def} ifelse

/lanind lanind1 def
%lanind1 1 lanind2 {/lanind exch def %output showpage

%ps3d.inc

gsave

72 90 translate

100 -5 moveto
5 /Times-Roman FS
(DE420-8N) show

0.01 MM 0.01 MM scale

15 setlinewidth

0.5 setgray
0 0  moveto 5400 0 rlineto 0 4000 rlineto -5400 0 rlineto
closepath fill

0 setgray
0 0  moveto 5400 0 rlineto 0 4000 rlineto -5400 0 rlineto
closepath stroke

grestore
gsave

72 90 translate

18 18 scale

0 0 translate
0 setlinewidth

0 setgray

%newpath
%2 2 moveto
%1 0 rlineto
%0 1 rlineto
%-1 0 rlineto
%closepath
%fill

%1 0 0 setrgbcolor

%newpath
%1 1 moveto
%1 0 rlineto
%0 1 rlineto
%-1 0 rlineto
%closepath
%stroke


/xd 0.65 def
/yd 0.65 def
/xf 0.55 def
/yf 0.55 def
/x0 xd 2 div 1.0 add def
/y0 yd 2 div 0.2 sub def

/xchar [(A) (B) (C) (D) (E) (F) (G) (H) (I)] def
0.3 /Times-Roman FS

0 1 8 {/j exch def %j=0,8
0 1 8 {/i exch def %i=0,8
       /ic i 0.1 mul def
       /jc j 0.1 mul def
       ic jc 0 setrgbcolor
       /x x0 i xd mul add def
       /y y0 j yd mul add def
       x y moveto xf 0 rlineto 0 yf rlineto
                  xf neg 0 rlineto closepath fill
       0 setgray
       i 0 eq {x 0.5 xf mul sub y 0.3 yf mul add moveto j cvishow} if
       j 8 eq {x 0.3 xf mul add y 1.2 yf mul add moveto xchar i get show} if
      } for %i=0,8
      } for %j=0,8


/iout 0 def
iout 1 eq {%iout=1

1 0 0 setrgbcolor

[0 0 5 1] set-eye

[0 1 0] 30 rotate3d

4 /Times-Roman FS

newpath
1 0 moveto
(ABC) true charpath

2d-path-convert
gsave
0.7 0 0.1 setrgbcolor
fill
grestore
stroke

%15 setlinewidth
0 1 0 setrgbcolor
0 0 0 moveto3d 10 0 0 rlineto3d 0 6 0 rlineto3d -10 0 0 rlineto3d
closepath stroke

newpath
0 0 1 setrgbcolor

1 1 0 moveto3d
1 0 0 rlineto3d
0 1 0 rlineto3d
-1 0 0 rlineto3d
closepath
stroke

} if %iout=1

showpage

%%Trailer


%%EndDocument
EndEPSF grestore gsave

BeginEPSF
161 MM 197 MM translate
  10 /Times-ISOL1 FS  1 1 scale  -77 -91 translate
%%BeginDocument: Bild 12

%line 419

%%EndDocument
EndEPSF grestore gsave

BeginEPSF
161 MM 08 MM sub 152 MM translate
  10 /Times-ISOL1 FS  53 MM 1 MM moveto ( ) show 1 1 scale  -77 -91 translate
%%BeginDocument: Bild 21

%line 429
%!PS-Adobe-3.0 EPSF-3.0 DE421-1N
%%BoundingBox: 70 85 226 206

%START PDFDE011.EPS
/pdfmark11 where {pop} {userdict /pdfmark11 /cleartomark load put} ifelse
/languagelevel where {pop languagelevel} {1} ifelse
2 lt { userdict (<<) cvn ([) cvn load put
       userdict (>>) cvn (]) cvn load put} if
[ /Title (PostScript pictures: farbe.li.tu-berlin.de/DE42/DE42.HTM)
  /Author (compare K. Richter "Computergrafik ...": ISBN 3-8007-1775-1)
  /Subject (goto: http://farbe.li.tu-berlin.de http://130.149.60.45/~farbmetrik)
  /Keywords (image reproduction, colour devices)
  /Creator (klaus.richter@mac.com)
  /CreationDate (D:2018060112000)
  /ModDate (D:20180601112000)
/DOCINFO pdfmark11
[ /View [ /Fit ]
/DOCVIEW pdfmark11
%END  PDFDE011

/BeginEPSF {% def               % Prepare for EPS file
/b4_Inc_state save def          % Save state for cleanup
/dict_count countdictstack def
/op_count count 1 sub def       % Count objects on op stack
userdict begin                  % Make userdict current dict
/showpage {} def
0 setgray 0 setlinecap
1 setlinewidth 0 setlinejoin
10 setmiterlimit [] 0 setdash newpath
/languagelevel where            % If level not equal to 1 then
 {pop languagelevel where       % If level not equal to 1 then
 1 ne
 {false setstrokeadjust false setoverprint
 } if
} if
} bind def

/EndEPSF  {% def              % End for EPS file
 count op_count sub {pop} repeat
 countdictstack dict_count sub {end} repeat	% Clean up dict stack
 b4_Inc_state restore
} bind def


% !AUSTAUSCH Times-Roman -> Times-Roman-ISOLatin1=Times-I
 
/Times-Roman findfont dup length dict  begin
{1 index /FID ne {def} {pop pop} ifelse }forall
/Encoding ISOLatin1Encoding def
currentdict end
/Times-ISOL1 exch definefont pop
 
/Times-Italic findfont dup length dict  begin
{1 index /FID ne {def} {pop pop} ifelse }forall
/Encoding ISOLatin1Encoding def
currentdict end
/TimesI-ISOL1 exch definefont pop
 
/Times-Bold findfont dup length dict  begin
{1 index /FID ne {def} {pop pop} ifelse }forall
/Encoding ISOLatin1Encoding def
currentdict end
/TimesB-ISOL1 exch definefont pop
 
/Times-BoldItalic findfont dup length dict  begin
{1 index /FID ne {def} {pop pop} ifelse }forall
/Encoding ISOLatin1Encoding def
currentdict end
/TimesBI-ISOL1 exch definefont pop
 
/FS {findfont exch scalefont setfont} bind def
/MM {72 25.4 div mul} def /str {8 string } bind def
 
/TV {150 /Times-ISOL1 FS} bind def
/TS {200 /Times-ISOL1 FS} bind def 
/TK {250 /Times-ISOL1 FS} bind def
/TM {300 /Times-ISOL1 FS} bind def
/TG {350 /Times-ISOL1 FS} bind def

/TIV {150 /TimesI-ISOL1 FS} bind def
/TIS {200 /TimesI-ISOL1 FS} bind def 
/TIK {250 /TimesI-ISOL1 FS} bind def
/TIM {300 /TimesI-ISOL1 FS} bind def
/TIG {350 /TimesI-ISOL1 FS} bind def

/TBV {150 /TimesB-ISOL1 FS} bind def
/TBS {200 /TimesB-ISOL1 FS} bind def
/TBK {250 /TimesB-ISOL1 FS} bind def
/TBM {300 /TimesB-ISOL1 FS} bind def
/TBG {350 /TimesB-ISOL1 FS} bind def

/TBIV {150 /TimesBI-ISOL1 FS} bind def
/TBIS {200 /TimesBI-ISOL1 FS} bind def
/TBIK {250 /TimesBI-ISOL1 FS} bind def
/TBIM {300 /TimesBI-ISOL1 FS} bind def
/TBIG {350 /TimesBI-ISOL1 FS} bind def

/RV {150 /Times-Roman FS} bind def
/RS {200 /Times-Roman FS} bind def
/RK {250 /Times-Roman FS} bind def
/RM {300 /Times-Roman FS} bind def
/RG {350 /Times-Roman FS} bind def

/RIV {150 /Times-Italic FS} bind def
/RIS {200 /Times-Italic FS} bind def
/RIK {250 /Times-Italic FS} bind def
/RIM {300 /Times-Italic FS} bind def
/RIG {350 /Times-Italic FS} bind def

/RBV {150 /Times-Bold FS} bind def
/RBS {200 /Times-Bold FS} bind def
/RBK {250 /Times-Bold FS} bind def
/RBM {300 /Times-Bold FS} bind def
/RBG {350 /Times-Bold FS} bind def

/RBIV {150 /Times-BoldItalic FS} bind def
/RBIS {200 /Times-BoldItalic FS} bind def
/RBIK {250 /Times-BoldItalic FS} bind def
/RBIM {300 /Times-BoldItalic FS} bind def
/RBIG {350 /Times-BoldItalic FS} bind def

/SV {150 /Symbol FS} bind def
/SS {200 /Symbol FS} bind def
/SK {250 /Symbol FS} bind def
/SM {300 /Symbol FS} bind def
/SG {350 /Symbol FS} bind def

/rec %x, y width heigth
  {/heigth exch def /width exch def
   moveto width 0 rlineto 0 heigth rlineto width neg 0 rlineto
   closepath } bind def

/rec3d %x, y width heigth
  {/heigth exch def /width exch def
   0 moveto3d width 0 0 rlineto3d 0 heigth 0 rlineto3d width neg 0 0 rlineto3d
   closepath } bind def
 
/colrecfi %x y width heigth c m y k
  {setrgbcolor rec fill} bind def
 
/colrecst %x y width heigth c m y k
  {setrgbcolor rec stroke} bind def
 
/cvishow {0.5 add cvi 6 string cvs show} def
/cvsshow1  {10 mul cvi 0.1 mul 7 string cvs show} def
/cvsshow2  {100 mul cvi 0.01 mul 7 string cvs show} def
/cvsshow3  {1000 mul cvi 0.001 mul 7 string cvs show} def
/cvsshow4  {10000 mul cvi 0.0001 mul 8 string cvs show} def

%%EndProlog
%lanindL3 START  20160701
/lanind 1 def
/lantex [(G) (E) (S) (N) (I) (J) (M)] def
/showde {0 lanind eq {show} {pop} ifelse} bind def
/showen {1 lanind eq {show} {pop} ifelse} bind def
/showes {2 lanind eq {show} {pop} ifelse} bind def
/showfr {3 lanind eq {show} {pop} ifelse} bind def
/showit {4 lanind eq {show} {pop} ifelse} bind def
/showjp {5 lanind eq {show} {pop} ifelse} bind def
/showea {1 lanind le {show} {pop} ifelse} bind def

/lanind1 01 def /lanind2 01 def /lanindd 01 def /lanindm 01 def
/xcolor1 00 def /xcolor2 00 def /xcolord 01 def /xcolorm 01 def
/xchart1 00 def /xchart2 00 def /xchartd 01 def /xchartm 01 def
/pchart1 00 def /pchart2 00 def /pchartd 01 def /pchartm 01 def
/xchart3 01 def /xchart4 00 def /xchart5 00 def

%usual change of default values
/lanindf where {pop /lanind1 lanindf  def /lanind2 lanindf  def
                    /lanindd laninddf def} if
/xcolorf where {pop /xcolor1 xcolorf  def /xcolor2 xcolorf  def
                    /xcolord xcolordf def} if
/xchartf where {pop /xchart1 xchartf  def /xchart2 xchartf  def
                    /xchartd xchartdf def} if
/pchartf where {pop /pchart1 pchartf  def /pchart2 pchartf  def
                    /pchartd pchartdf def} if
/xchart3f where {pop /xchart3 xchart3f def} if
/xchart4f where {pop /xchart4 xchart4f def} if
/xchart5f where {pop /xchart5 xchart5f def} if

/lanind lanind1 def %
/xcolor xcolor1 def %
/xchart xchart1 def %
/pchart 0 def %

%lanindL3 START  20160701
gsave

/cname1 [(C) (B) (M)] def
/cname2 [(R) (Y) (G)] def
/dshow {4 /Times-Roman FS 0 -1 rmoveto (d) show 0 1 rmoveto
        5 /Times-Roman FS} def
/gshow {RBS 0 -50 rmoveto (d) show 0 50 rmoveto RBK} def

%0 1 4 {/pchart exch def %BEG pchart=0,4

/xchart 0 def
%0 4 8 {/xchart exch def %BEG xchart=0,4,8

gsave

/xs 300 def /ys xs def /d2 xs 2 div def /d8 xs 8 div def

72 90 translate

120 -4 moveto
4 /Times-Roman FS
(DE421-1N) show

0.01 MM dup scale

15 setlinewidth

pchart 0 eq {0.5 setgray} if
pchart 1 eq {0.0 setgray} if
pchart 2 eq {1.0 setgray} if
pchart 3 eq {0 1 1 setrgbcolor} if
pchart 4 eq {1 0 0 setrgbcolor} if

0 0  moveto 5400 0 rlineto 0 4000 rlineto -5400 0 rlineto
closepath fill

0.0 setgray
0 0  moveto 5400 0 rlineto 0 4000 rlineto -5400 0 rlineto
closepath stroke

grestore
gsave

72 90 translate

/fakt 2540 4 div def

0.01 MM dup scale

0 0 translate
0 setlinewidth

0 setgray

/xtr 1000 def /ytr 0 def
xtr ytr translate

/xf 1.3 def
/xs 300 xf mul def /ys xs def /d2 xs 2 div def /d8 xs 8 div def
/ymax 3300 def
/xmin 180 xf mul def
/xd 270 xf mul def
/yd 270 xf mul def
/xsd xs xd sub 0.5 mul def
/ysd xs xd sub 0.5 mul def

/fakt 1800 25.4 mul 72 div def

0 setgray
20 setlinewidth

%3x rgbcmy
/id 1 8 div def
/rijn 81 array def %for intermediate storage
/gijn 81 array def /bijn 81 array def

/n -1 def

/lmin xchart 4 idiv def
/lmax lmin def
lmin 1 lmax {/l exch def %l=0,lmax
             /xadd 0 def
             /yadd 0 def
          
%for intermediate storage of l=0,lmax
0 1 01 {/jchart exch def %jchart=0,1
        /xchartj l jchart 3 mul add def
0 1 08 {/j exch def %j=0,7
        /im 8 j sub def
jchart 1 im {/i exch def %i=0,8
        /ia 1 id j mul sub def
        /argb ia def /brgb ia i id mul sub def
        xchartj 0 eq {/r argb def /g brgb def /b brgb def} if
        xchartj 1 eq {/r argb def /g argb def /b brgb def} if
        xchartj 2 eq {/r brgb def /g argb def /b brgb def} if
        xchartj 3 eq {/r brgb def /g argb def /b argb def} if
        xchartj 4 eq {/r brgb def /g brgb def /b argb def} if
        xchartj 5 eq {/r argb def /g brgb def /b argb def} if
        jchart 0 eq {/in i j add def /jn j def}
                    {/in j def /jn i j add def} ifelse
                     rijn in 9 mul jn add r put
                     gijn in 9 mul jn add g put
                     bijn in 9 mul jn add b put
        } for %i=0,7
        } for %j=0,8
        } for %jchart=0,1
        
%for output of l=0,lmax

%        0   1   2   3   4   5   6   7   8
/xchar [(A) (B) (C) (D) (E) (F) (G) (H) (I)] def

TS
/xa xmin xadd add def
/ya ymax yadd sub def
0.5 0.5 0.5 setrgbcolor
xa xsd sub ya xs add xsd sub xs 9 mul xs 9 mul neg rec fill

0 1 08 {/j exch def %j=0,8
0 1 08 {/i exch def %i=0,8
        /r rijn i j 9 mul add get def
        /g gijn i j 9 mul add get def
        /b bijn i j 9 mul add get def
        
        /xa xmin xs j mul add xadd add def
        /ya ymax xs i mul sub yadd sub def
        
        r g b setrgbcolor
        xa ya xd dup rec fill
        RK
        pchart 1 ne {0 setgray} {1 setgray} ifelse
        i 0 eq {xa xd 0.3 mul add ya yd 1.2 mul add moveto xchar j get show} if
        j 0 eq {xa xd 0.8 mul sub ya yd 0.3 mul add moveto i cvishow} if

        RBIK
        i 0 eq
        j 0 eq and {%left top
                    /xald xa xd 2.0 mul sub def
                    /yald ya yd 0.3 mul add def
                    xald yald moveto (W) show gshow
                   } if

        i 8 eq
        j 0 eq and {%left down
                    /xald xa xd 2.0 mul sub def
                    /yald ya yd 0.3 mul add def
                    xald yald moveto cname1 xchart 4 idiv get show gshow
                   } if
        i 0 eq
        j 8 eq and {%right up
                    /xald xa xd 1.3 mul add def
                    /yald ya yd 0.2 mul add def
                    xald yald moveto cname2 xchart 4 idiv get show gshow
                   } if

        i 8 eq
        j 8 eq and {%right down
                    /xald xa xd 1.3 mul add def
                    /yald ya yd 0.3 mul add def
                    xald yald moveto (N) show gshow
                   } if

        } for %i=0,8
        } for %j=0,8

        } for %l=0,lmax
        
xtr neg ytr neg translate
        
showpage
grestore

%} for %xchart=0,4,8

%} for %pchart=0,4

%%Trailer


%%EndDocument
EndEPSF grestore gsave

BeginEPSF
219 MM 152 MM translate
  10 /Times-ISOL1 FS  53 MM 1 MM moveto ( ) show 1 1 scale  -77 -91 translate
%%BeginDocument: Bild 22

%line 439
%!PS-Adobe-3.0 EPSF-3.0 DE421-2N
%%BoundingBox: 70 85 226 206

%START PDFDE011.EPS
/pdfmark12 where {pop} {userdict /pdfmark12 /cleartomark load put} ifelse
/languagelevel where {pop languagelevel} {1} ifelse
2 lt { userdict (<<) cvn ([) cvn load put
       userdict (>>) cvn (]) cvn load put} if
[ /Title (PostScript pictures: farbe.li.tu-berlin.de/DE42/DE42.HTM)
  /Author (compare K. Richter "Computergrafik ...": ISBN 3-8007-1775-1)
  /Subject (goto: http://farbe.li.tu-berlin.de http://130.149.60.45/~farbmetrik)
  /Keywords (image reproduction, colour devices)
  /Creator (klaus.richter@mac.com)
  /CreationDate (D:2018060112000)
  /ModDate (D:20180601112000)
/DOCINFO pdfmark12
[ /View [ /Fit ]
/DOCVIEW pdfmark12
%END  PDFDE011

/BeginEPSF {% def               % Prepare for EPS file
/b4_Inc_state save def          % Save state for cleanup
/dict_count countdictstack def
/op_count count 1 sub def       % Count objects on op stack
userdict begin                  % Make userdict current dict
/showpage {} def
0 setgray 0 setlinecap
1 setlinewidth 0 setlinejoin
10 setmiterlimit [] 0 setdash newpath
/languagelevel where            % If level not equal to 1 then
 {pop languagelevel where       % If level not equal to 1 then
 1 ne
 {false setstrokeadjust false setoverprint
 } if
} if
} bind def

/EndEPSF  {% def              % End for EPS file
 count op_count sub {pop} repeat
 countdictstack dict_count sub {end} repeat	% Clean up dict stack
 b4_Inc_state restore
} bind def


% !AUSTAUSCH Times-Roman -> Times-Roman-ISOLatin1=Times-I
 
/Times-Roman findfont dup length dict  begin
{1 index /FID ne {def} {pop pop} ifelse }forall
/Encoding ISOLatin1Encoding def
currentdict end
/Times-ISOL1 exch definefont pop
 
/Times-Italic findfont dup length dict  begin
{1 index /FID ne {def} {pop pop} ifelse }forall
/Encoding ISOLatin1Encoding def
currentdict end
/TimesI-ISOL1 exch definefont pop
 
/Times-Bold findfont dup length dict  begin
{1 index /FID ne {def} {pop pop} ifelse }forall
/Encoding ISOLatin1Encoding def
currentdict end
/TimesB-ISOL1 exch definefont pop
 
/Times-BoldItalic findfont dup length dict  begin
{1 index /FID ne {def} {pop pop} ifelse }forall
/Encoding ISOLatin1Encoding def
currentdict end
/TimesBI-ISOL1 exch definefont pop
 
/FS {findfont exch scalefont setfont} bind def
/MM {72 25.4 div mul} def /str {8 string } bind def
 
/TV {150 /Times-ISOL1 FS} bind def
/TS {200 /Times-ISOL1 FS} bind def 
/TK {250 /Times-ISOL1 FS} bind def
/TM {300 /Times-ISOL1 FS} bind def
/TG {350 /Times-ISOL1 FS} bind def

/TIV {150 /TimesI-ISOL1 FS} bind def
/TIS {200 /TimesI-ISOL1 FS} bind def 
/TIK {250 /TimesI-ISOL1 FS} bind def
/TIM {300 /TimesI-ISOL1 FS} bind def
/TIG {350 /TimesI-ISOL1 FS} bind def

/TBV {150 /TimesB-ISOL1 FS} bind def
/TBS {200 /TimesB-ISOL1 FS} bind def
/TBK {250 /TimesB-ISOL1 FS} bind def
/TBM {300 /TimesB-ISOL1 FS} bind def
/TBG {350 /TimesB-ISOL1 FS} bind def

/TBIV {150 /TimesBI-ISOL1 FS} bind def
/TBIS {200 /TimesBI-ISOL1 FS} bind def
/TBIK {250 /TimesBI-ISOL1 FS} bind def
/TBIM {300 /TimesBI-ISOL1 FS} bind def
/TBIG {350 /TimesBI-ISOL1 FS} bind def

/RV {150 /Times-Roman FS} bind def
/RS {200 /Times-Roman FS} bind def
/RK {250 /Times-Roman FS} bind def
/RM {300 /Times-Roman FS} bind def
/RG {350 /Times-Roman FS} bind def

/RIV {150 /Times-Italic FS} bind def
/RIS {200 /Times-Italic FS} bind def
/RIK {250 /Times-Italic FS} bind def
/RIM {300 /Times-Italic FS} bind def
/RIG {350 /Times-Italic FS} bind def

/RBV {150 /Times-Bold FS} bind def
/RBS {200 /Times-Bold FS} bind def
/RBK {250 /Times-Bold FS} bind def
/RBM {300 /Times-Bold FS} bind def
/RBG {350 /Times-Bold FS} bind def

/RBIV {150 /Times-BoldItalic FS} bind def
/RBIS {200 /Times-BoldItalic FS} bind def
/RBIK {250 /Times-BoldItalic FS} bind def
/RBIM {300 /Times-BoldItalic FS} bind def
/RBIG {350 /Times-BoldItalic FS} bind def

/SV {150 /Symbol FS} bind def
/SS {200 /Symbol FS} bind def
/SK {250 /Symbol FS} bind def
/SM {300 /Symbol FS} bind def
/SG {350 /Symbol FS} bind def

/rec %x, y width heigth
  {/heigth exch def /width exch def
   moveto width 0 rlineto 0 heigth rlineto width neg 0 rlineto
   closepath } bind def

/rec3d %x, y width heigth
  {/heigth exch def /width exch def
   0 moveto3d width 0 0 rlineto3d 0 heigth 0 rlineto3d width neg 0 0 rlineto3d
   closepath } bind def
 
/colrecfi %x y width heigth c m y k
  {setrgbcolor rec fill} bind def
 
/colrecst %x y width heigth c m y k
  {setrgbcolor rec stroke} bind def
 
/cvishow {0.5 add cvi 6 string cvs show} def
/cvsshow1  {10 mul cvi 0.1 mul 7 string cvs show} def
/cvsshow2  {100 mul cvi 0.01 mul 7 string cvs show} def
/cvsshow3  {1000 mul cvi 0.001 mul 7 string cvs show} def
/cvsshow4  {10000 mul cvi 0.0001 mul 8 string cvs show} def

%%EndProlog
%lanindL3 START  20160701
/lanind 1 def
/lantex [(G) (E) (S) (N) (I) (J) (M)] def
/showde {0 lanind eq {show} {pop} ifelse} bind def
/showen {1 lanind eq {show} {pop} ifelse} bind def
/showes {2 lanind eq {show} {pop} ifelse} bind def
/showfr {3 lanind eq {show} {pop} ifelse} bind def
/showit {4 lanind eq {show} {pop} ifelse} bind def
/showjp {5 lanind eq {show} {pop} ifelse} bind def
/showea {1 lanind le {show} {pop} ifelse} bind def

/lanind1 01 def /lanind2 01 def /lanindd 01 def /lanindm 01 def
/xcolor1 00 def /xcolor2 00 def /xcolord 01 def /xcolorm 01 def
/xchart1 00 def /xchart2 00 def /xchartd 01 def /xchartm 01 def
/pchart1 00 def /pchart2 00 def /pchartd 01 def /pchartm 01 def
/xchart3 01 def /xchart4 00 def /xchart5 00 def

%usual change of default values
/lanindf where {pop /lanind1 lanindf  def /lanind2 lanindf  def
                    /lanindd laninddf def} if
/xcolorf where {pop /xcolor1 xcolorf  def /xcolor2 xcolorf  def
                    /xcolord xcolordf def} if
/xchartf where {pop /xchart1 xchartf  def /xchart2 xchartf  def
                    /xchartd xchartdf def} if
/pchartf where {pop /pchart1 pchartf  def /pchart2 pchartf  def
                    /pchartd pchartdf def} if
/xchart3f where {pop /xchart3 xchart3f def} if
/xchart4f where {pop /xchart4 xchart4f def} if
/xchart5f where {pop /xchart5 xchart5f def} if

/lanind lanind1 def %
/xcolor xcolor1 def %
/xchart xchart1 def %
/pchart 0 def %

%lanindL3 START  20160701
gsave

/cname1 [(C) (B) (M)] def
/cname2 [(R) (Y) (G)] def
/dshow {4 /Times-Roman FS 0 -1 rmoveto (d) show 0 1 rmoveto
        5 /Times-Roman FS} def
/gshow {RBS 0 -50 rmoveto (d) show 0 50 rmoveto RBK} def

%0 1 4 {/pchart exch def %BEG pchart=0,4

/xchart 4 def
%0 4 8 {/xchart exch def %BEG xchart=0,4,8

gsave

/xs 300 def /ys xs def /d2 xs 2 div def /d8 xs 8 div def

72 90 translate

120 -4 moveto
4 /Times-Roman FS
(DE421-2N) show

0.01 MM dup scale

15 setlinewidth

pchart 0 eq {0.5 setgray} if
pchart 1 eq {0.0 setgray} if
pchart 2 eq {1.0 setgray} if
pchart 3 eq {0 1 1 setrgbcolor} if
pchart 4 eq {1 0 0 setrgbcolor} if

0 0  moveto 5400 0 rlineto 0 4000 rlineto -5400 0 rlineto
closepath fill

0.0 setgray
0 0  moveto 5400 0 rlineto 0 4000 rlineto -5400 0 rlineto
closepath stroke

grestore
gsave

72 90 translate

/fakt 2540 4 div def

0.01 MM dup scale

0 0 translate
0 setlinewidth

0 setgray

/xtr 1000 def /ytr 0 def
xtr ytr translate

/xf 1.3 def
/xs 300 xf mul def /ys xs def /d2 xs 2 div def /d8 xs 8 div def
/ymax 3300 def
/xmin 180 xf mul def
/xd 270 xf mul def
/yd 270 xf mul def
/xsd xs xd sub 0.5 mul def
/ysd xs xd sub 0.5 mul def

/fakt 1800 25.4 mul 72 div def

0 setgray
20 setlinewidth

%3x rgbcmy
/id 1 8 div def
/rijn 81 array def %for intermediate storage
/gijn 81 array def /bijn 81 array def

/n -1 def

/lmin xchart 4 idiv def
/lmax lmin def
lmin 1 lmax {/l exch def %l=0,lmax
             /xadd 0 def
             /yadd 0 def
          
%for intermediate storage of l=0,lmax
0 1 01 {/jchart exch def %jchart=0,1
        /xchartj l jchart 3 mul add def
0 1 08 {/j exch def %j=0,7
        /im 8 j sub def
jchart 1 im {/i exch def %i=0,8
        /ia 1 id j mul sub def
        /argb ia def /brgb ia i id mul sub def
        xchartj 0 eq {/r argb def /g brgb def /b brgb def} if
        xchartj 1 eq {/r argb def /g argb def /b brgb def} if
        xchartj 2 eq {/r brgb def /g argb def /b brgb def} if
        xchartj 3 eq {/r brgb def /g argb def /b argb def} if
        xchartj 4 eq {/r brgb def /g brgb def /b argb def} if
        xchartj 5 eq {/r argb def /g brgb def /b argb def} if
        jchart 0 eq {/in i j add def /jn j def}
                    {/in j def /jn i j add def} ifelse
                     rijn in 9 mul jn add r put
                     gijn in 9 mul jn add g put
                     bijn in 9 mul jn add b put
        } for %i=0,7
        } for %j=0,8
        } for %jchart=0,1
        
%for output of l=0,lmax

%        0   1   2   3   4   5   6   7   8
/xchar [(A) (B) (C) (D) (E) (F) (G) (H) (I)] def

TS
/xa xmin xadd add def
/ya ymax yadd sub def
0.5 0.5 0.5 setrgbcolor
xa xsd sub ya xs add xsd sub xs 9 mul xs 9 mul neg rec fill

0 1 08 {/j exch def %j=0,8
0 1 08 {/i exch def %i=0,8
        /r rijn i j 9 mul add get def
        /g gijn i j 9 mul add get def
        /b bijn i j 9 mul add get def
        
        /xa xmin xs j mul add xadd add def
        /ya ymax xs i mul sub yadd sub def
        
        r g b setrgbcolor
        xa ya xd dup rec fill
        RK
        pchart 1 ne {0 setgray} {1 setgray} ifelse
        i 0 eq {xa xd 0.3 mul add ya yd 1.2 mul add moveto xchar j get show} if
        j 0 eq {xa xd 0.8 mul sub ya yd 0.3 mul add moveto i cvishow} if

        RBIK
        i 0 eq
        j 0 eq and {%left top
                    /xald xa xd 2.0 mul sub def
                    /yald ya yd 0.3 mul add def
                    xald yald moveto (W) show gshow
                   } if

        i 8 eq
        j 0 eq and {%left down
                    /xald xa xd 2.0 mul sub def
                    /yald ya yd 0.3 mul add def
                    xald yald moveto cname1 xchart 4 idiv get show gshow
                   } if
        i 0 eq
        j 8 eq and {%right up
                    /xald xa xd 1.3 mul add def
                    /yald ya yd 0.2 mul add def
                    xald yald moveto cname2 xchart 4 idiv get show gshow
                   } if

        i 8 eq
        j 8 eq and {%right down
                    /xald xa xd 1.3 mul add def
                    /yald ya yd 0.3 mul add def
                    xald yald moveto (N) show gshow
                   } if

        } for %i=0,8
        } for %j=0,8

        } for %l=0,lmax
        
xtr neg ytr neg translate
        
showpage
grestore

%} for %xchart=0,4,8

%} for %pchart=0,4

%%Trailer


%%EndDocument
EndEPSF grestore gsave

BeginEPSF
161 MM 08 MM sub 108 MM translate
  10 /Times-ISOL1 FS  53 MM 1 MM moveto ( ) show 1 1 scale  -77 -91 translate
%%BeginDocument: Bild 23

%line 449
%!PS-Adobe-3.0 EPSF-3.0 DE421-3N
%%BoundingBox: 70 85 226 206

%START PDFDE011.EPS
/pdfmark13 where {pop} {userdict /pdfmark13 /cleartomark load put} ifelse
/languagelevel where {pop languagelevel} {1} ifelse
2 lt { userdict (<<) cvn ([) cvn load put
       userdict (>>) cvn (]) cvn load put} if
[ /Title (PostScript pictures: farbe.li.tu-berlin.de/DE42/DE42.HTM)
  /Author (compare K. Richter "Computergrafik ...": ISBN 3-8007-1775-1)
  /Subject (goto: http://farbe.li.tu-berlin.de http://130.149.60.45/~farbmetrik)
  /Keywords (image reproduction, colour devices)
  /Creator (klaus.richter@mac.com)
  /CreationDate (D:2018060112000)
  /ModDate (D:20180601112000)
/DOCINFO pdfmark13
[ /View [ /Fit ]
/DOCVIEW pdfmark13
%END  PDFDE011

/BeginEPSF {% def               % Prepare for EPS file
/b4_Inc_state save def          % Save state for cleanup
/dict_count countdictstack def
/op_count count 1 sub def       % Count objects on op stack
userdict begin                  % Make userdict current dict
/showpage {} def
0 setgray 0 setlinecap
1 setlinewidth 0 setlinejoin
10 setmiterlimit [] 0 setdash newpath
/languagelevel where            % If level not equal to 1 then
 {pop languagelevel where       % If level not equal to 1 then
 1 ne
 {false setstrokeadjust false setoverprint
 } if
} if
} bind def

/EndEPSF  {% def              % End for EPS file
 count op_count sub {pop} repeat
 countdictstack dict_count sub {end} repeat	% Clean up dict stack
 b4_Inc_state restore
} bind def


% !AUSTAUSCH Times-Roman -> Times-Roman-ISOLatin1=Times-I
 
/Times-Roman findfont dup length dict  begin
{1 index /FID ne {def} {pop pop} ifelse }forall
/Encoding ISOLatin1Encoding def
currentdict end
/Times-ISOL1 exch definefont pop
 
/Times-Italic findfont dup length dict  begin
{1 index /FID ne {def} {pop pop} ifelse }forall
/Encoding ISOLatin1Encoding def
currentdict end
/TimesI-ISOL1 exch definefont pop
 
/Times-Bold findfont dup length dict  begin
{1 index /FID ne {def} {pop pop} ifelse }forall
/Encoding ISOLatin1Encoding def
currentdict end
/TimesB-ISOL1 exch definefont pop
 
/Times-BoldItalic findfont dup length dict  begin
{1 index /FID ne {def} {pop pop} ifelse }forall
/Encoding ISOLatin1Encoding def
currentdict end
/TimesBI-ISOL1 exch definefont pop
 
/FS {findfont exch scalefont setfont} bind def
/MM {72 25.4 div mul} def /str {8 string } bind def
 
/TV {150 /Times-ISOL1 FS} bind def
/TS {200 /Times-ISOL1 FS} bind def 
/TK {250 /Times-ISOL1 FS} bind def
/TM {300 /Times-ISOL1 FS} bind def
/TG {350 /Times-ISOL1 FS} bind def

/TIV {150 /TimesI-ISOL1 FS} bind def
/TIS {200 /TimesI-ISOL1 FS} bind def 
/TIK {250 /TimesI-ISOL1 FS} bind def
/TIM {300 /TimesI-ISOL1 FS} bind def
/TIG {350 /TimesI-ISOL1 FS} bind def

/TBV {150 /TimesB-ISOL1 FS} bind def
/TBS {200 /TimesB-ISOL1 FS} bind def
/TBK {250 /TimesB-ISOL1 FS} bind def
/TBM {300 /TimesB-ISOL1 FS} bind def
/TBG {350 /TimesB-ISOL1 FS} bind def

/TBIV {150 /TimesBI-ISOL1 FS} bind def
/TBIS {200 /TimesBI-ISOL1 FS} bind def
/TBIK {250 /TimesBI-ISOL1 FS} bind def
/TBIM {300 /TimesBI-ISOL1 FS} bind def
/TBIG {350 /TimesBI-ISOL1 FS} bind def

/RV {150 /Times-Roman FS} bind def
/RS {200 /Times-Roman FS} bind def
/RK {250 /Times-Roman FS} bind def
/RM {300 /Times-Roman FS} bind def
/RG {350 /Times-Roman FS} bind def

/RIV {150 /Times-Italic FS} bind def
/RIS {200 /Times-Italic FS} bind def
/RIK {250 /Times-Italic FS} bind def
/RIM {300 /Times-Italic FS} bind def
/RIG {350 /Times-Italic FS} bind def

/RBV {150 /Times-Bold FS} bind def
/RBS {200 /Times-Bold FS} bind def
/RBK {250 /Times-Bold FS} bind def
/RBM {300 /Times-Bold FS} bind def
/RBG {350 /Times-Bold FS} bind def

/RBIV {150 /Times-BoldItalic FS} bind def
/RBIS {200 /Times-BoldItalic FS} bind def
/RBIK {250 /Times-BoldItalic FS} bind def
/RBIM {300 /Times-BoldItalic FS} bind def
/RBIG {350 /Times-BoldItalic FS} bind def

/SV {150 /Symbol FS} bind def
/SS {200 /Symbol FS} bind def
/SK {250 /Symbol FS} bind def
/SM {300 /Symbol FS} bind def
/SG {350 /Symbol FS} bind def

/rec %x, y width heigth
  {/heigth exch def /width exch def
   moveto width 0 rlineto 0 heigth rlineto width neg 0 rlineto
   closepath } bind def

/rec3d %x, y width heigth
  {/heigth exch def /width exch def
   0 moveto3d width 0 0 rlineto3d 0 heigth 0 rlineto3d width neg 0 0 rlineto3d
   closepath } bind def
 
/colrecfi %x y width heigth c m y k
  {setrgbcolor rec fill} bind def
 
/colrecst %x y width heigth c m y k
  {setrgbcolor rec stroke} bind def
 
/cvishow {0.5 add cvi 6 string cvs show} def
/cvsshow1  {10 mul cvi 0.1 mul 7 string cvs show} def
/cvsshow2  {100 mul cvi 0.01 mul 7 string cvs show} def
/cvsshow3  {1000 mul cvi 0.001 mul 7 string cvs show} def
/cvsshow4  {10000 mul cvi 0.0001 mul 8 string cvs show} def

%%EndProlog
%lanindL3 START  20160701
/lanind 1 def
/lantex [(G) (E) (S) (N) (I) (J) (M)] def
/showde {0 lanind eq {show} {pop} ifelse} bind def
/showen {1 lanind eq {show} {pop} ifelse} bind def
/showes {2 lanind eq {show} {pop} ifelse} bind def
/showfr {3 lanind eq {show} {pop} ifelse} bind def
/showit {4 lanind eq {show} {pop} ifelse} bind def
/showjp {5 lanind eq {show} {pop} ifelse} bind def
/showea {1 lanind le {show} {pop} ifelse} bind def

/lanind1 01 def /lanind2 01 def /lanindd 01 def /lanindm 01 def
/xcolor1 00 def /xcolor2 00 def /xcolord 01 def /xcolorm 01 def
/xchart1 00 def /xchart2 00 def /xchartd 01 def /xchartm 01 def
/pchart1 00 def /pchart2 00 def /pchartd 01 def /pchartm 01 def
/xchart3 01 def /xchart4 00 def /xchart5 00 def

%usual change of default values
/lanindf where {pop /lanind1 lanindf  def /lanind2 lanindf  def
                    /lanindd laninddf def} if
/xcolorf where {pop /xcolor1 xcolorf  def /xcolor2 xcolorf  def
                    /xcolord xcolordf def} if
/xchartf where {pop /xchart1 xchartf  def /xchart2 xchartf  def
                    /xchartd xchartdf def} if
/pchartf where {pop /pchart1 pchartf  def /pchart2 pchartf  def
                    /pchartd pchartdf def} if
/xchart3f where {pop /xchart3 xchart3f def} if
/xchart4f where {pop /xchart4 xchart4f def} if
/xchart5f where {pop /xchart5 xchart5f def} if

/lanind lanind1 def %
/xcolor xcolor1 def %
/xchart xchart1 def %
/pchart 0 def %

%lanindL3 START  20160701
gsave

/cname1 [(C) (B) (M)] def
/cname2 [(R) (Y) (G)] def
/dshow {4 /Times-Roman FS 0 -1 rmoveto (d) show 0 1 rmoveto
        5 /Times-Roman FS} def
/gshow {RBS 0 -50 rmoveto (d) show 0 50 rmoveto RBK} def

%0 1 4 {/pchart exch def %BEG pchart=0,4

/xchart 8 def
%0 4 8 {/xchart exch def %BEG xchart=0,4,8

gsave

/xs 300 def /ys xs def /d2 xs 2 div def /d8 xs 8 div def

72 90 translate

120 -4 moveto
4 /Times-Roman FS
(DE421-3N) show

0.01 MM dup scale

15 setlinewidth

pchart 0 eq {0.5 setgray} if
pchart 1 eq {0.0 setgray} if
pchart 2 eq {1.0 setgray} if
pchart 3 eq {0 1 1 setrgbcolor} if
pchart 4 eq {1 0 0 setrgbcolor} if

0 0  moveto 5400 0 rlineto 0 4000 rlineto -5400 0 rlineto
closepath fill

0.0 setgray
0 0  moveto 5400 0 rlineto 0 4000 rlineto -5400 0 rlineto
closepath stroke

grestore
gsave

72 90 translate

/fakt 2540 4 div def

0.01 MM dup scale

0 0 translate
0 setlinewidth

0 setgray

/xtr 1000 def /ytr 0 def
xtr ytr translate

/xf 1.3 def
/xs 300 xf mul def /ys xs def /d2 xs 2 div def /d8 xs 8 div def
/ymax 3300 def
/xmin 180 xf mul def
/xd 270 xf mul def
/yd 270 xf mul def
/xsd xs xd sub 0.5 mul def
/ysd xs xd sub 0.5 mul def

/fakt 1800 25.4 mul 72 div def

0 setgray
20 setlinewidth

%3x rgbcmy
/id 1 8 div def
/rijn 81 array def %for intermediate storage
/gijn 81 array def /bijn 81 array def

/n -1 def

/lmin xchart 4 idiv def
/lmax lmin def
lmin 1 lmax {/l exch def %l=0,lmax
             /xadd 0 def
             /yadd 0 def
          
%for intermediate storage of l=0,lmax
0 1 01 {/jchart exch def %jchart=0,1
        /xchartj l jchart 3 mul add def
0 1 08 {/j exch def %j=0,7
        /im 8 j sub def
jchart 1 im {/i exch def %i=0,8
        /ia 1 id j mul sub def
        /argb ia def /brgb ia i id mul sub def
        xchartj 0 eq {/r argb def /g brgb def /b brgb def} if
        xchartj 1 eq {/r argb def /g argb def /b brgb def} if
        xchartj 2 eq {/r brgb def /g argb def /b brgb def} if
        xchartj 3 eq {/r brgb def /g argb def /b argb def} if
        xchartj 4 eq {/r brgb def /g brgb def /b argb def} if
        xchartj 5 eq {/r argb def /g brgb def /b argb def} if
        jchart 0 eq {/in i j add def /jn j def}
                    {/in j def /jn i j add def} ifelse
                     rijn in 9 mul jn add r put
                     gijn in 9 mul jn add g put
                     bijn in 9 mul jn add b put
        } for %i=0,7
        } for %j=0,8
        } for %jchart=0,1
        
%for output of l=0,lmax

%        0   1   2   3   4   5   6   7   8
/xchar [(A) (B) (C) (D) (E) (F) (G) (H) (I)] def

TS
/xa xmin xadd add def
/ya ymax yadd sub def
0.5 0.5 0.5 setrgbcolor
xa xsd sub ya xs add xsd sub xs 9 mul xs 9 mul neg rec fill

0 1 08 {/j exch def %j=0,8
0 1 08 {/i exch def %i=0,8
        /r rijn i j 9 mul add get def
        /g gijn i j 9 mul add get def
        /b bijn i j 9 mul add get def
        
        /xa xmin xs j mul add xadd add def
        /ya ymax xs i mul sub yadd sub def
        
        r g b setrgbcolor
        xa ya xd dup rec fill
        RK
        pchart 1 ne {0 setgray} {1 setgray} ifelse
        i 0 eq {xa xd 0.3 mul add ya yd 1.2 mul add moveto xchar j get show} if
        j 0 eq {xa xd 0.8 mul sub ya yd 0.3 mul add moveto i cvishow} if

        RBIK
        i 0 eq
        j 0 eq and {%left top
                    /xald xa xd 2.0 mul sub def
                    /yald ya yd 0.3 mul add def
                    xald yald moveto (W) show gshow
                   } if

        i 8 eq
        j 0 eq and {%left down
                    /xald xa xd 2.0 mul sub def
                    /yald ya yd 0.3 mul add def
                    xald yald moveto cname1 xchart 4 idiv get show gshow
                   } if
        i 0 eq
        j 8 eq and {%right up
                    /xald xa xd 1.3 mul add def
                    /yald ya yd 0.2 mul add def
                    xald yald moveto cname2 xchart 4 idiv get show gshow
                   } if

        i 8 eq
        j 8 eq and {%right down
                    /xald xa xd 1.3 mul add def
                    /yald ya yd 0.3 mul add def
                    xald yald moveto (N) show gshow
                   } if

        } for %i=0,8
        } for %j=0,8

        } for %l=0,lmax
        
xtr neg ytr neg translate
        
showpage
grestore

%} for %xchart=0,4,8

%} for %pchart=0,4

%%Trailer


%%EndDocument
EndEPSF grestore gsave

BeginEPSF
219 MM 108 MM translate
  10 /Times-ISOL1 FS  53 MM 1 MM moveto ( ) show 1 1 scale  -77 -91 translate
%%BeginDocument: Bild 24

%line 459
%!PS-Adobe-3.0 EPSF-3.0 DE421-4,
%%BoundingBox: 70 90 226 206

/FS {findfont exch scalefont setfont} bind def
/MM {72 25.4 div mul} def
%%EndProlog
gsave

8 /Times-Roman FS
72 83 moveto
%!2     (DE421-4,) show

72 90 translate

%! 0.01 MM 0.01 MM scale
%! 15 setlinewidth
%! 0 0  moveto 5400 0 rlineto 0 4000 rlineto -5400 0 rlineto
%! closepath stroke

grestore

showpage
%%Trailer

%%EndDocument
EndEPSF grestore gsave

BeginEPSF
161 MM 08 MM sub 064 MM translate
  10 /Times-ISOL1 FS  53 MM 1 MM moveto ( ) show 1 1 scale  -77 -91 translate
%%BeginDocument: Bild 25

%line 469
%!PS-Adobe-3.0 EPSF-3.0 DE421-8N
%%BoundingBox: 70 90 226 206

%START PDFDE011.EPS
/pdfmark18 where {pop} {userdict /pdfmark18 /cleartomark load put} ifelse
/languagelevel where {pop languagelevel} {1} ifelse
2 lt { userdict (<<) cvn ([) cvn load put
       userdict (>>) cvn (]) cvn load put} if
[ /Title (PostScript pictures: farbe.li.tu-berlin.de/DE42/DE42.HTM)
  /Author (compare K. Richter "Computergrafik ...": ISBN 3-8007-1775-1)
  /Subject (goto: http://farbe.li.tu-berlin.de http://130.149.60.45/~farbmetrik)
  /Keywords (image reproduction, colour devices)
  /Creator (klaus.richter@mac.com)
  /CreationDate (D:2018060112000)
  /ModDate (D:20180601112000)
/DOCINFO pdfmark18
[ /View [ /Fit ]
/DOCVIEW pdfmark18
%END  PDFDE011

/BeginEPSF {% def               % Prepare for EPS file
/b4_Inc_state save def          % Save state for cleanup
/dict_count countdictstack def
/op_count count 1 sub def       % Count objects on op stack
userdict begin                  % Make userdict current dict
/showpage {} def
0 setgray 0 setlinecap
1 setlinewidth 0 setlinejoin
10 setmiterlimit [] 0 setdash newpath
/languagelevel where            % If level not equal to 1 then
 {pop languagelevel where       % If level not equal to 1 then
 1 ne
 {false setstrokeadjust false setoverprint
 } if
} if
} bind def

/EndEPSF  {% def              % End for EPS file
 count op_count sub {pop} repeat
 countdictstack dict_count sub {end} repeat	% Clean up dict stack
 b4_Inc_state restore
} bind def


% !AUSTAUSCH Times-Roman -> Times-Roman-ISOLatin1=Times-I
 
/Times-Roman findfont dup length dict  begin
{1 index /FID ne {def} {pop pop} ifelse }forall
/Encoding ISOLatin1Encoding def
currentdict end
/Times-ISOL1 exch definefont pop
 
/Times-Italic findfont dup length dict  begin
{1 index /FID ne {def} {pop pop} ifelse }forall
/Encoding ISOLatin1Encoding def
currentdict end
/TimesI-ISOL1 exch definefont pop
 
/Times-Bold findfont dup length dict  begin
{1 index /FID ne {def} {pop pop} ifelse }forall
/Encoding ISOLatin1Encoding def
currentdict end
/TimesB-ISOL1 exch definefont pop
 
/Times-BoldItalic findfont dup length dict  begin
{1 index /FID ne {def} {pop pop} ifelse }forall
/Encoding ISOLatin1Encoding def
currentdict end
/TimesBI-ISOL1 exch definefont pop
 
/FS {findfont exch scalefont setfont} bind def
/MM {72 25.4 div mul} def /str {8 string } bind def
 
/TK {250 16.67 div /Times-ISOL1 FS} bind def
/TM {300 16.67 div /Times-ISOL1 FS} bind def
/TG {350 16.67 div /Times-ISOL1 FS} bind def
 
/TIK {250 16.67 div /TimesI-ISOL1 FS} bind def
/TIM {300 16.67 div /TimesI-ISOL1 FS} bind def
/TIG {350 16.67 div /TimesI-ISOL1 FS} bind def
 
/TBK {250 16.67 div /TimesB-ISOL1 FS} bind def
/TBM {300 16.67 div /TimesB-ISOL1 FS} bind def
/TBG {350 16.67 div /TimesB-ISOL1 FS} bind def
 
/TBIK {250 16.67 div /TimesBI-ISOL1 FS} bind def
/TBIM {300 16.67 div /TimesBI-ISOL1 FS} bind def
/TBIG {350 16.67 div /TimesBI-ISOL1 FS} bind def

/RK {250 16.67 div /Times-Roman FS} bind def
/RM {300 16.67 div /Times-Roman FS} bind def
/RG {350 16.67 div /Times-Roman FS} bind def

/RIK {250 16.67 div /Times-Italic FS} bind def
/RIM {300 16.67 div /Times-Italic FS} bind def
/RIG {350 16.67 div /Times-Italic FS} bind def

/RBK {250 16.67 div /Times-Bold FS} bind def
/RBM {300 16.67 div /Times-Bold FS} bind def
/RBG {350 16.67 div /Times-Bold FS} bind def

/RBIK {250 16.67 div /Times-BoldItalic FS} bind def
/RBIM {300 16.67 div /Times-BoldItalic FS} bind def
/RBIG {350 16.67 div /Times-BoldItalic FS} bind def

/tolvfcol    %Farbkreis-Reihenfolge
[ (000) (F00) (FF0) (0F0) (0FF) (00F) (F0F) (FFF)
  (777) (700) (770) (070) (077) (007) (707) (F07) %15=R
  (333) (F77) (FF7) (7F7) (7FF) (77F) (F7F) (07F) %23=B
  (BBB) (F70) (7F0) (0F7) (07F) (70F) (F07) (0F7) %31=G
] def
 
/tcmyfcol    %Farbkreis-Reihenfolge
[ (FFF) (0FF) (00F) (F0F) (F00) (FF0) (0F0) (000)
  (888) (8FF) (88F) (F8F) (F88) (FF8) (8F8) (0F8) %15=R
  (CCC) (088) (008) (808) (800) (880) (080) (F80) %23=B
  (444) (08F) (80F) (F08) (F80) (8F0) (0F8) (F08) %31=G
] def
 
/tcmykfcol   %Farbkreis-Reihenfolge
[ (000F) (0FF0) (00F0) (F0F0) (F000) (FF00) (0F00) (0000)
  (0008) (0FF8) (00F8) (F0F8) (F008) (FF08) (0F08) (0F80) %15=R
  (000C) (0880) (0080) (8080) (8000) (8800) (0800) (F800) %23=B
  (0004) (0F80) (80F0) (F080) (F800) (8F00) (0F80) (F080) %31=G
] def
 
/tolvfcols    %Farbkreis-Reihenfolge
[ (000*) (F00*) (FF0*) (0F0*) (0FF*) (00F*) (F0F*) (FFF*)
  (777*) (700*) (770*) (070*) (077*) (007*) (707*) (F07*) %15=R
  (333*) (F77*) (FF7*) (7F7*) (7FF*) (77F*) (F7F*) (07F*) %23=B
  (BBB*) (F70*) (7F0*) (0F7*) (07F*) (70F*) (F07*) (0F7*) %31=G
] def
 
/tcmyfcols    %Farbkreis-Reihenfolge
[ (FFF*) (0FF*) (00F*) (F0F*) (F00*) (FF0*) (0F0*) (000*)
  (888*) (8FF*) (88F*) (F8F*) (F88*) (FF8*) (8F8*) (0F8*) %15=R
  (CCC*) (088*) (008*) (808*) (800*) (880*) (080*) (F80*) %23=B
  (444*) (08F*) (80F*) (F08*) (F80*) (8F0*) (0F8*) (F08*) %31=G
] def
 
/tcmykfcols   %Farbkreis-Reihenfolge
[ (000F*) (0FF0*) (00F0*) (F0F0*) (F000*) (FF00*) (0F00*) (0000*)
  (0008*) (0FF8*) (00F8*) (F0F8*) (F008*) (FF08*) (0F08*) (0F80*) %15=R
  (000C*) (0880*) (0080*) (8080*) (8000*) (8800*) (0800*) (F800*) %23=B
  (0004*) (0F80*) (80F0*) (F080*) (F800*) (8F00*) (0F80*) (F080*) %31=G
] def
 
/fcolors     %CMYN 32 Testfarben Nr. 0 bis 31; Farbkreis-Reihenfolge
[{0.0 0.0 0.0 1.0}  {0.0 1.0 1.0 0.0}  {0.0 0.0 1.0 0.0}  {1.0 0.0 1.0 0.0}
 {1.0 0.0 0.0 0.0}  {1.0 1.0 0.0 0.0}  {0.0 1.0 0.0 0.0}  {0.0 0.0 0.0 0.0}
 
 {0.0 0.0 0.0 0.5}  {0.0 1.0 1.0 0.5}  {0.0 0.0 1.0 0.5}  {1.0 0.0 1.0 0.5}
 {1.0 0.0 0.0 0.5}  {1.0 1.0 0.0 0.5}  {0.0 1.0 0.0 0.5}  {0.0 1.0 0.5 0.0}
 
 {0.0 0.0 0.0 0.75} {0.0 0.5 0.5 0.0}  {0.0 0.0 0.5 0.0}  {0.5 0.0 0.5 0.0}
 {0.5 0.0 0.0 0.0}  {0.5 0.5 0.0 0.0}  {0.0 0.5 0.0 0.0}  {1.0 0.5 0.0 0.0}
 
 {0.0 0.0 0.0 0.25} {0.0 0.5 1.0 0.0}  {0.5 0.0 1.0 0.0}  {1.0 0.0 0.5 0.0}
 {1.0 0.5 0.0 0.0}  {0.5 1.0 0.0 0.0}  {0.0 1.0 0.5 0.0}  {1.0 0.0 0.5 0.0}
] def
 
/fak 0.5 def
 
/Far     %Farbkreis-Reihenfolge
 [ 0  1  2  3  4  5  6  7
   8  9 10 11 12 13 14 15 %R
  16 17 18 19 20 21 22 23 %B
  24 25 26 27 28 29 30 31 %G
 ] def
 
/cFar     %Kompensativ-Farbkreis-Reihenfolge
 [ 8  4  5  6  1  2  3  0
   0 20 21 22 17 18 19 31 %G
  24 12 13 14  9 10 11  2 %J
  16 28 29 30 25 26 27 15 %R
 ] def
 
/Btx    %Farbkreis- -> %Btx-Reihenfolge
 [ 0  1  3  2  5  6  4  7
   8  9 11 10 13 14 12 15  %R
  16 17 19 18 21 22 20 23  %B
  24 25 26 27 28 29 30 31  %G
 ] def
 
/cBtx    %Farbkreis- -> %Kompensativ-Btx-Reihenfolge
 [ 7  4  6  5  2  3  1  0
   8 20 22 21 18 19 17 31 %G
  24 12 14 13 10 11  9  2 %J
  16 25 26 27 28 29 30 15 %R
 ] def
 
/rec %x, y width heigth
  {/heigth exch def /width exch def
   moveto width 0 rlineto 0 heigth rlineto width neg 0 rlineto
   closepath } bind def
 
/colrecfi %x y width heigth c m y k
  {setrgbcolor rec fill} bind def
 
/colrecst %x y width heigth c m y k
  {setrgbcolor rec stroke} bind def
 
/tzo {0.0 1.0 1.0 0.0} bind def %Reproduktionsfarben
/tzl {1.0 0.0 1.0 0.0} bind def
/tzv {1.0 1.0 0.0 0.0} bind def
/tzc {1.0 0.0 0.0 0.0} bind def
/tzm {0.0 1.0 0.0 0.0} bind def
/tzy {0.0 0.0 1.0 0.0} bind def
 
/tzn {0.0 0.0 0.0 1.00} bind def %Graureihe
/tzd {0.0 0.0 0.0 0.75} bind def
/tzz {0.0 0.0 0.0 0.50} bind def
/tzh {0.0 0.0 0.0 0.25} bind def
/tzw {0.0 0.0 0.0 0.00} bind def
 
/tzr {0.0 1.0 0.5 0.0} bind def %Elementarfarben
/tzg {1.0 0.0 0.5 0.0} bind def
/tzb {1.0 0.5 0.0 0.0} bind def
/tzj {0.0 0.0 1.0 0.0} bind def
 
/tzrz {0.0 1.0 0.5 0.5} bind def %Elementarfarben vergraut
/tzgz {1.0 0.0 0.5 0.5} bind def
/tzbz {1.0 0.5 0.0 0.5} bind def
/tzjz {0.0 0.0 1.0 0.5} bind def
 
/tfo {tzo setcmykcolor} bind def
/tfl {tzl setcmykcolor} bind def
/tfv {tzv setcmykcolor} bind def
/tfc {tzc setcmykcolor} bind def
/tfm {tzm setcmykcolor} bind def
/tfy {tzy setcmykcolor} bind def
 
/tfn {tzn setcmykcolor} bind def
/tfd {tzd setcmykcolor} bind def
/tfz {tzz setcmykcolor} bind def
/tfh {tzh setcmykcolor} bind def
/tfw {tzw setcmykcolor} bind def
 
/tfr {tzr setcmykcolor} bind def
/tfg {tzg setcmykcolor} bind def
/tfb {tzb setcmykcolor} bind def
/tfj {tzj setcmykcolor} bind def
 
/tfrz {tzrz setcmykcolor} bind def
/tfgz {tzgz setcmykcolor} bind def
/tfbz {tzbz setcmykcolor} bind def
/tfjz {tzjz setcmykcolor} bind def

%
% - %This is ps3d.inc ----------------------------------

% - Copyright Bill Casselman
% - Original version 1.0 November, 1998
% - Version 1.1 December, 1999
% -      Took out aliases for moveto etc.
% -      Made display-matrix a 3 x 4 homogeneous matrix, added it to the 3d gstack 
% -      Allowed arbitrary eye location, 3d -> 2d projects onto z = 0 plane
% -      Although fancy stuff not yet implemented
% -      Made ght a variable
% -      Version 1.1 is *not* backwards compatible!
% - Version 1.2 August, 2002
% -      Thorough interpretation of matrices as arrays of columns and point vectors as rows
% -      And some speed up
% -      Similar rewriting of matrix.inc
% -      Again, backwards incompatible!
% - Version 1.3 August, 2003
% -      Rewriting shade for efficiency
% - Thanks to Jim Blinn's book `A trip down the graphics pipeline'
% - for several suggestions that (I hope) made this code cleaner 
% - by suggesting how useful homogeneous coordinates were.
% November 10, 2003: added fancier shading
% December 17, 2003: changed arguments for mkpath procedures

% ------------------------------------------------


% - Inserting matrix.inc ----------------------

% - Vector calculations (usually good in any number of dimensions) ----------

% - matrices in this package are usually laid out in a single array by columns ---
% - i.e. [ column1 column 2 ... ]
% - but sometimes as a double array [ [ column1] [column2] ... ] 

% <double array>  /to-single-array
% <single-array> /to-double-array
% <n> /identity
% <u> <v> /dot-product
% <u> <c> /vector-scale
% <u> <v> /vector-add
% <u> <v> /vectorssub
% <u> /vector-length
% <u> <v> cross-product
% <axis> <angle> /rotation-matrix3d
% v [a b c] /euclidean-reflect
% [a b c] /reflection-matrix-3d
% <m> <n> /matrix-mul
% <m> <v> /matrix-vector
% <v> <m> /vector-matrix 
% <m> /transpose
% <m> 3x3-det
% <m> /3x3-inverse
% <u> <v> /angle-between
% <x> /acos
% <x> <a> <a^v> /skew-reflect
% <a> <a^v> /skew-reflection-matrix

% - matrices in this package are laid out in a single array by columns ---------

% a double array: cannot be empty - just lays out all items
/to-single-array {
% [ [. . . ][ . . . ] ] => [ . . . . . . ]
[
	exch { % successive rows
		aload pop
	} forall
]
} def

% ----------------------------------------------

% [ ... ] a square matrix made into an array of columns
/to-double-array { 4 dict begin
/A exch def
/N A length sqrt round cvi def
/i 0 def
[
N {
	[
	N {
		A i get
		/i i 1 add def
	} repeat
	]
} repeat
]
end } def

% ----------------------------------------

% returns the nxn identity matrix as single array
/identity { 1 dict begin
/n exch def
[
  n 1 sub {
    1 
    n {
      0
	} repeat 
  } repeat
  1
]
end } def

% --- vector algebra --------------------------------

% u v -> u.v
/dot-product { 1 dict begin
/v exch def
0 0	     		% u s i
3 2 roll { 		% s i u[i]
  v 			% s i u[i] v
  2 index get mul 	% s i u[i]*v[i]
  3 2 roll		% i u[i]*v[i] s
  add exch 1 add	% s i
} forall
pop
end } def

% v c -> c.v
/vector-scale { 1 dict begin
/c exch def
[ exch
{ 		% s i u[i]
  c mul			% s i u[i] v 
} forall
]
end } def

% u v -> u+v
/vector-add { 1 dict begin
/v exch def
[ exch
0 	     	% u i
exch { 		% i u[i]
  v 		% i u[i] v
  2 index get add 	% i u[i]+v[i]
  exch 1 add	% i
} forall
pop
]
end } def

% u v -> u-v
/vector-sub { 1 dict begin
/v exch def
[ exch
0 	     	% u i
exch { 		% i u[i]
  v 		% i u[i] v
  2 index get sub 	% i u[i]+v[i]
  exch 1 add	% i
} forall
pop
]
end } def

% [x y z ... ] -> r
% watch out for overflow

/vector-length { 1 dict begin
dup
% find maximum entry
/max 0 def
{ % max 
  abs dup max gt {
    % if abs gt max
    /max exch def
  } {
    pop
  } ifelse
} forall

max 0 ne {
  0 exch 
  {  % 0 v[i]
    max div dup mul add
  } forall
  sqrt
  max mul
} {
  pop 0
} ifelse
end } def

% v -> v/|v|
/normalized { 1 dict begin
dup 			% v v
vector-length /r exch def
[ exch
  {
    r div
  } forall
]
end } def

% u v
% u0 u1 u2
% v0 v1 v2
% -> u x v
/cross-product {
2 dict begin
/v exch def
/u exch def
[
  u 1 get v 2 get mul
  v 1 get u 2 get mul sub

  v 0 get u 2 get mul
  u 0 get v 2 get mul sub

  u 0 get v 1 get mul
  v 0 get u 1 get mul sub
]
end
} def

% --------------------------------------------------------------

% axis A -> a matrix
/rotation-matrix3d {
8 dict begin
dup 
cos /c exch def
sin /s exch def
/a exch def
/r a vector-length def
/a0 a 0 get r div def
/a1	a 1 get r div def
/a2 a 2 get r div def

[

% e = [1 0 0] etc.
% e0 = (e.a)a, e# = e - e0, e* = a x e = a x e0 + a x e# = a x e#
/x a0 def
/e0 [a0 x mul
     a1 x mul 
     a2 x mul] def
/e# [1 e0 0 get sub 
     e0 1 get neg 
     e0 2 get neg] def
% [a0 a1 a2]
% [ 1  0  0]
/e* [0 
     a2 
     a1 neg
    ] def
e# 0 get c mul e* 0 get s mul add e0 0 get add 
e# 1 get c mul e* 1 get s mul add e0 1 get add 
e# 2 get c mul e* 2 get s mul add e0 2 get add 

/x a1 def
/e0 [a0 x mul a1 x mul a2 x mul] def
/e# [e0 0 get neg 
     1 e0 1 get sub 
     e0 2 get neg] def
% [a0 a1 a2]
% [ 0  1  0]
/e* [a2 neg 
     0
     a0
    ] def
e# 0 get c mul e* 0 get s mul add e0 0 get add 
e# 1 get c mul e* 1 get s mul add e0 1 get add 
e# 2 get c mul e* 2 get s mul add e0 2 get add 

/x a2 def
/e0 [a0 x mul a1 x mul a2 x mul] def
/e# [e0 0 get neg
     e0 1 get neg
     1 e0 2 get sub] def
% [a0 a1 a2]
% [ 0  0  1]
/e* [a1 
     a0 neg
     0
    ] def
e# 0 get c mul e* 0 get s mul add e0 0 get add 
e# 1 get c mul e* 1 get s mul add e0 1 get add 
e# 2 get c mul e* 2 get s mul add e0 2 get add 

]
% [ r0 r1 r2 r3 r4 r5 r6 r7 r8 ] -> [r0 r3 r6 r1 r4 r7 r2 r5 r8 ]
/r exch def
[
	r 0 get 
	r 3 get
	r 6 get
	r 1 get
	r 4 get
	r 7 get
	r 2 get
	r 5 get
	r 8 get
] 
end
} def

% v a -> v - 2(a.v)/(a.a) a
/euclidean-reflect { 16 dict begin
/a exch def
/v exch def
/N a length def
/d a v dot-product a dup dot-product div 2 mul def
[
  0
  v {
    % i v[i]
    exch dup 1 add					% v[i] i i+1
	3 1 roll							  % i+1 v[i] i
    a exch get d mul 				% i+1 v[i] a[i]*d
	sub										% i+1 v[i]-d*a[i]
	exch									% rv[i] i+1
  } forall
  pop
]
end } def

% f = [A B C] => linear 3d transformation: f not necessarily normalized
% Rv = v - 2 <f', v> f'

/reflection-matrix3d {
3 dict begin
aload pop
/C exch def
/B exch def
/A exch def
/r [ A B C ] vector-length def
/A A r div def
/B B r div def
/C C r div def
[
  1 A A mul dup add sub   B A mul dup add neg   C A mul dup add neg
    A B mul dup add neg 1 B B mul dup add sub   C B mul dup add neg
    A C mul dup add neg   B C mul dup add neg 1 C C mul dup add sub
]
end
} def

/matrix-mul {
8 dict begin
/B exch def
/A exch def
/n A length sqrt round cvi def
%  0    1  ...
%  n  n+1 ...
% 2n 2n+1 ...
[
  0
  n {
    % i = initial index of the column on the stack = 0, n, 2n ... 
    % after all previous entries
    dup n add exch 0	
    n {
	  % i+n i j on stack
      % j = initial index of the row
	  2 copy 1 add % i+n i j i j+1
	  4 2 roll	% i+n i j+1 i j
	  /ell exch def
      /k exch def
	  % i+n i j+1 
      0
      n {
		% i+n i j+1 s
        A ell get B k get mul add
        /k k 1 add def
        /ell ell n add def
      } repeat
	  4 1 roll
	  % s i+n i j+1
   	} repeat
    pop pop	% s i+n
  } repeat
  pop
]
end
} def

% A v: A = [ column 1, column 2, ... , column n ]
/matrix-vector {
8 dict begin
/v exch def
/r v length def
/A exch def
/c A length r idiv def
[
  0 1 c 1 sub {
	/i exch def
    % i = initial index of the row
    0 0
    r {
		% s j on stack
		dup 1 add	% s j j+1
		3 1 roll		% j+1 s j
      	v exch get A i get mul add	% j+1 s
		exch
   	  	/i i r add def
    } repeat
	% s r
	pop
  } for
]
end
} def

% v A: A = [ column1 column2 ... ]
/vector-matrix {
8 dict begin
/A exch def
/v exch def
/c v length def
/r A length c idiv def
[
  /i 0 def 
  r {
    % i = initial index of the row
    /j 0 def
    0
    c {
      A i get v j get mul add
      /j j 1 add def
   	  /i i 1 add def
    } repeat
  } repeat
]
end
} def

% a square matrix m x m
% [i, j] = n*i + j

/transpose {
4 dict begin
/M exch def
/n M length sqrt round cvi def
[
/k 0 def
n {
  /i k def
  n { 
    M i get
    /i i n add def
  } repeat
  /k k 1 add def
} repeat
]

end
} def

/3x3-det {
1 dict begin
/m exch def

m 0 get 
m 4 get mul
m 8 get mul

m 1 get 
m 5 get mul
m 6 get mul
add

m 2 get 
m 3 get mul
m 7 get mul
add

m 2 get 
m 4 get mul
m 6 get mul
sub

m 1 get 
m 3 get mul
m 8 get mul
sub

m 0 get 
m 5 get mul
m 7 get mul
sub

end
} def

/3x3-inverse {
2 dict begin
/m exch def
/d m 3x3-det def
[
   m 4 get m 8 get mul 
   m 5 get m 7 get mul sub
   d div
   
   m 2 get m 7 get mul 
   m 1 get m 8 get mul sub
   d div
   
   m 1 get m 5 get mul 
   m 4 get m 2 get mul sub
   d div

   m 5 get m 6 get mul 
   m 3 get m 8 get mul sub
   d div
   
   m 0 get m 8 get mul 
   m 2 get m 6 get mul sub
   d div
   
   m 2 get m 3 get mul 
   m 0 get m 5 get mul sub
   d div

   m 3 get m 7 get mul 
   m 6 get m 4 get mul sub
   d div
   
   m 1 get m 6 get mul 
   m 0 get m 7 get mul sub
   d div
   
   m 0 get m 4 get mul 
   m 1 get m 3 get mul sub
   d div
]
end
} def

/acos {
dup dup % x x x
mul 1 sub neg % x 1-x^2
sqrt exch atan
} def

% u v

/angle-between {
dup vector-length
% u v |v|
3 1 roll
% |v| u v
1 index 
% |v| u v u
dot-product
% |v| u u.v
exch vector-length
% |v| u.v |u|
div exch div
acos
} def

% x a av -> x - <a, x> av

/skew-reflect { 4 dict begin
/av exch def
/a exch def
/x exch def
/d x a dot-product def
[
	0 1 x length 1 sub {
		/i exch def
		x i get av i get d mul sub
	} for
]
end } def

% a av -> matrix
/skew-reflection-matrix { 8 dict begin
/av exch def
/a exch def
/n a length def
[
	0 1 n 1 sub {
		/i exch def
		[ n {0} repeat ] dup i 1 put
		% e[i] 
		a av skew-reflect
	} for
]
to-single-array
transpose
end } def

% - closing matrix.inc ------------------------

% - Defining PostScript commands' equivalents ----------

% - Coordinates in three dimensions -------------------

% There are three steps to drawing something in 3D:
% 1.  Converting from user 3d coords to default 3d coords
% 2.  Projecting onto (x, y)-plane
% 3.  Drawing the image on that plane
% These are more or less independent.  
% The last step is completely controlled by the usual PS stuff.
% The first and second are handled by 3d stuff here.

% - Initialize and manipulate the 3d gstack -----------

/gmax 64 def
/ght 0 def

% gstack = [[t0 d0 dm0] [t1 d2 dm1] [t2 d2 dm2] ... [t(gmax-1) d(gmax-1) dm(gmax-1)] ]

% the ctm is t[ght]
% the dual ctm is at d[ght]
% they are 4 x 4
% display-matrix = 3 x 4

/gstack3d gmax array def

% start with orthogonal projection to positive z-axis
gstack3d 0 [
  [ 1 0 0 0 
    0 1 0 0
    0 0 1 0
    0 0 0 1] 
  [ 1 0 0 0 
    0 1 0 0
    0 0 1 0
    0 0 0 1]
  [ 1 0 0 0
    0 1 0 0
    0 0 0 1]
] put

/gsave3d {
  /ctm gstack3d ght get def
  /ght ght 1 add def 
  ght gmax eq {
    (3d graphics stack overflow!) ==
    quit
  } if
  gstack3d 
    ght
    [ ctm 0 get ctm 1 get ctm 2 get ] 
  put
} def

/grestore3d {
  /ght ght 1 sub def
  ght 0 lt {
     (3d graphics stack underflow!) ==
     quit
  } if
} def

% n - restores to depth n

/gpop3d {
/ght exch def
} def

% [T T* dm]: sets cgfx3d = [T T* dm]

/gset3d {
gstack3d  		% [T T* d] g 
ght			    % [T T* d] g ght
3 2 roll 		    % g ght [T T* d]
put 
} def

% => [T T* dm]

/cgfx3d {
  gstack3d ght get
} def

/ctm3d {
  gstack3d ght get 0 get
} def

/cim3d {
  gstack3d ght get 1 get
} def

/cdm3d {
  gstack3d ght get 2 get
} def

% cpt3d isthe last 3d point drawn to

/currentpoint3d {
cpt3d
cgfx3d 1 get transform3d
aload pop     % x y z w 
pop			
} def

% - Sets up projection into 2D -------------------
		
% O = [x y z w] 
% sets display-matrix perspective onto z = 0 plane

/display-matrix {
  cgfx3d 2 get
} def

% [z0 0 -x0 0
%  0 z0 -y0 0
%  0 0 -w0 z0]
% (transposed)
% gives perspective onto point in z=0 plane
% from [x0 y0 z0 w0]

/set-eye {
4 dict begin
aload pop
/w0 exch def
/z0 exch def
/y0 exch def
/x0 exch def
gstack3d ght get
2 
[ z0 0 x0 neg 0 
  0 z0 y0 neg 0
  0 0 w0 neg z0]
put
end
} def

/get-eye { 1 dict begin
/d display-matrix def
[d 2 get neg d 6 get neg d 0 get d 10 get neg]
end } def

/get-virtual-eye {
get-eye cgfx3d 1 get transform3d
} def

% - backwards compatibility -----------------------------

/origin { get-eye } def
/eye { get-eye } def
/set-display { set-eye } def

% - Manipulate the current transformation matrix -----

% x y z

/translate3d {
8 dict begin
/z exch def
/y exch def
/x exch def
/ctm cgfx3d def
/T ctm 0 get def
[
[
  T 0 get 
  T 1 get 
  T 2 get 
  T 0 get x  mul
  T 1 get y  mul
  add
  T 2 get z  mul
  add
  T 3 get 
  add
  
  T 4 get 
  T 5 get 
  T 6 get
  T 4 get x  mul
  T 5 get y  mul
  add
  T 6 get z  mul
  add
  T 7 get 
  add
   
  T 8 get 
  T 9 get 
  T 10 get
  T 8 get x  mul
  T 9 get y  mul
  add
  T 10 get z  mul
  add
  T 11 get 
  add
   
  T 12 get 
  T 13 get 
  T 14 get
  T 12 get x  mul
  T 13 get y  mul
  add
  T 14 get z  mul
  add
  T 15 get 
  add
]
/T ctm 1 get def
[
  T 0 get T 12 get x mul sub 
  T 1 get T 13 get x mul sub 
  T 2 get T 14 get x mul sub 
  T 3 get T 15 get x mul sub 

  T 4 get T 12 get y mul sub 
  T 5 get T 13 get y mul sub 
  T 6 get T 14 get y mul sub 
  T 7 get T 15 get y mul sub 

  T 8 get T 12 get z mul sub 
  T 9 get T 13 get z mul sub 
  T 10 get T 14 get z mul sub 
  T 11 get T 15 get z mul sub 

  T 12 get
  T 13 get
  T 14 get
  T 15 get
]
  ctm 2 get
]
end
gset3d
} def

% ------------------------------------------------------

% axis A

/rotate3d { 4 dict begin
rotation-matrix3d
/R exch def
/C cgfx3d def
/T C 0 get def
[
[
  % first row
  T 0 get R 0 get mul
  T 1 get R 3 get mul
  add
  T 2 get R 6 get mul
  add
  
  T 0 get R 1 get mul
  T 1 get R 4 get mul
  add
  T 2 get R 7 get mul
  add
  
  T 0 get R 2 get mul
  T 1 get R 5 get mul
  add
  T 2 get R 8 get mul
  add
  
  T 3 get
  
  % second row
  T 4 get R 0 get mul
  T 5 get R 3 get mul
  add
  T 6 get R 6 get mul
  add
  
  T 4 get R 1 get mul
  T 5 get R 4 get mul
  add
  T 6 get R 7 get mul
  add
  
  T 4 get R 2 get mul
  T 5 get R 5 get mul
  add
  T 6 get R 8 get mul
  add
  
  T 7 get
  
  % third row
  T 8 get R 0 get mul
  T 9 get R 3 get mul
  add
  T 10 get R 6 get mul
  add
  
  T 8 get R 1 get mul
  T 9 get R 4 get mul
  add
  T 10 get R 7 get mul
  add
  
  T 8 get R 2 get mul
  T 9 get R 5 get mul
  add
  T 10 get R 8 get mul
  add
  
  T 11 get
  
  % fourth row
  T 12 get R 0 get mul
  T 13 get R 3 get mul
  add
  T 14 get R 6 get mul
  add
  
  T 12 get R 1 get mul
  T 13 get R 4 get mul
  add
  T 14 get R 7 get mul
  add
  
  T 12 get R 2 get mul
  T 13 get R 5 get mul
  add
  T 14 get R 8 get mul
  add
  
  T 15 get
]
/T C 1 get def
% T = T^-1
% => R^-1 T^-1 
[
  R 0 get T 0 get mul
  R 3 get T 4 get mul add
  R 6 get T 8 get mul add
  
  R 0 get T 1 get mul
  R 3 get T 5 get mul add
  R 6 get T 9 get mul add
  
  R 0 get T 2 get mul
  R 3 get T 6 get mul add
  R 6 get T 10 get mul add
  
  R 0 get T 3 get mul
  R 3 get T 7 get mul add
  R 6 get T 11 get mul add
  
  % ------------------------
  
  R 1 get T 0 get mul
  R 4 get T 4 get mul add
  R 7 get T 8 get mul add
  
  R 1 get T 1 get mul
  R 4 get T 5 get mul add
  R 7 get T 9 get mul add
  
  R 1 get T 2 get mul
  R 4 get T 6 get mul add
  R 7 get T 10 get mul add
  
  R 1 get T 3 get mul
  R 4 get T 7 get mul add
  R 7 get T 11 get mul add
  
  % ------------------------
  
  R 2 get T 0 get mul
  R 5 get T 4 get mul add
  R 8 get T 8 get mul add
  
  R 2 get T 1 get mul
  R 5 get T 5 get mul add
  R 8 get T 9 get mul add
  
  R 2 get T 2 get mul
  R 5 get T 6 get mul add
  R 8 get T 10 get mul add
  
  R 2 get T 3 get mul
  R 5 get T 7 get mul add
  R 8 get T 11 get mul add

  T 12 get
  T 13 get
  T 14 get
  T 15 get  
]
  C 2 get
]
end
gset3d
} def


% f = [A B C D] P
% f = 0 is the *affine* reflection plane
% v = v* + v0 with v* on f = 0 and v0 in P-direction => v* - v0
% The map is Q => f(P)*Q - 2*f(Q)P
% It is of order two.
%
% f(P) I -
%
% 2A*P[0] 2B*P[0] 2C*P[0] 2D*P[0]
% 2A*P[1] 2B*P[1] 2C*P[1] 2D*P[1]
% 2A*P[2] 2B*P[2] 2C*P[2] 2D*P[2]
% 2A*P[3] 2B*P[3] 2C*P[3] 2D*P[3]
%
% Matrix = f(P) I - P f
% set s0 = (T row 0)*P
% T x this =
% f(P)T[0,0]-A*s -B*s -C*s -D*s

/affine-reflect3d { 4 dict begin
aload pop
/P3 exch def
/P2 exch def
/P1 exch def
/P0 exch def
aload pop
/D exch def
/C exch def
/B exch def
/A exch def

/fP 
  A P0 mul 
  B P1 mul add
  C P2 mul add
  D P3 mul add
def
/A A dup add def
/B B dup add def
/C C dup add def
/D D dup add def
[
/T cgfx3d 0 get def
[
  /s % = (T row 1)*P
  T 0 get P0 mul
  T 1 get P1 mul add
  T 2 get P2 mul add
  T 3 get P3 mul add
  def
  
  fP T 0 get mul
    A s mul sub
  fP T 1 get mul
    B s mul sub
  fP T 2 get mul
    C s mul sub
  fP T 3 get mul
    D s mul sub

  /s % = (T row 1)*P
  T 4 get P0 mul
  T 5 get P1 mul add
  T 6 get P2 mul add
  T 7 get P3 mul add
  def
  
  fP T 4 get mul
    A s mul sub
  fP T 5 get mul
    B s mul sub
  fP T 6 get mul
    C s mul sub
  fP T 7 get mul
    D s mul sub

  /s % = (T row 2)*P
  T 8 get P0 mul
  T 9 get P1 mul add
  T 10 get P2 mul add
  T 11 get P3 mul add
  def
  
  fP T 8 get mul
    A s mul sub
  fP T 9 get mul
    B s mul sub
  fP T 10 get mul
    C s mul sub
  fP T 11 get mul
    D s mul sub

  /s % = (T row 3)*P
  T 12 get P0 mul
  T 13 get P1 mul add
  T 14 get P2 mul add
  T 15 get P3 mul add
  def
  
  fP T 12 get mul
    A s mul sub
  fP T 13 get mul
    B s mul sub
  fP T 14 get mul
    C s mul sub
  fP T 15 get mul
    D s mul sub
]
/T cgfx3d 1 get def
/f0 		
  % f paired with columns of T
  T 0 get A mul
  T 4 get B mul add
  T 8 get C mul add
  T 12 get D mul add
def

/f1 		
  % f paired with columns of T
  T 1 get A mul
  T 5 get B mul add
  T 9 get C mul add
  T 13 get D mul add
def

/f2 		
  % f paired with columns of T
  T 2 get A mul
  T 6 get B mul add
  T 10 get C mul add
  T 14 get D mul add
def

/f3 		
  % f paired with columns of T
  T 3 get A mul
  T 7 get B mul add
  T 11 get C mul add
  T 15 get D mul add
def

[
  fP T 0 get mul
    f0 P0 get mul sub
  fP T 1 get mul
    f1 P0 get mul sub
  fP T 2 get mul
    f2 P0 get mul sub
  fP T 3 get mul
    f3 P0 get mul sub
  fP T 4 get mul
    f0 P1 get mul sub
  fP T 5 get mul
    f1 P1 get mul sub
  fP T 6 get mul
    f2 P1 get mul sub
  fP T 7 get mul
    f3 P1 get mul sub
  fP T 8 get mul
    f0 P2 get mul sub
  fP T 9 get mul
    f1 P2 get mul sub
  fP T 10 get mul
    f2 P2 get mul sub
  fP T 11 get mul
    f3 P2 get mul sub
  fP T 12 get mul
    f0 P3 get mul sub
  fP T 13 get mul
    f1 P3 get mul sub
  fP T 14 get mul
    f2 P3 get mul sub
  fP T 15 get mul
    f3 P3 get mul sub
]
  cgfx3d 2 get
] 
end
gset3d
} def

% 3x3 M 

/concat3d {
4 dict begin
/M exch def
[
/T cgfx3d 0 get def
  [
    T 0 get M 0 get mul
    T 1 get M 3 get mul add
    T 2 get M 6 get mul add

    T 0 get M 1 get mul
    T 1 get M 4 get mul add
    T 2 get M 7 get mul add
     
    T 0 get M 2 get mul
    T 1 get M 5 get mul add
    T 2 get M 8 get mul add
    
    T 3 get
     
    T 4 get M 0 get mul
    T 5 get M 3 get mul add
    T 6 get M 6 get mul add

    T 4 get M 1 get mul
    T 5 get M 4 get mul add
    T 6 get M 7 get mul add
     
    T 4 get M 2 get mul
    T 5 get M 5 get mul add
    T 6 get M 8 get mul add
    
    T 7 get
     
    T 8 get M 0 get mul
    T 9 get M 3 get mul add
    T 10 get M 6 get mul add

    T 8 get M 1 get mul
    T 9 get M 4 get mul add
    T 10 get M 7 get mul add
     
    T 8 get M 2 get mul
    T 9 get M 5 get mul add
    T 10 get M 8 get mul add
    
    T 11 get
     
    T 12 get M 0 get mul
    T 13 get M 3 get mul add
    T 14 get M 6 get mul add

    T 12 get M 1 get mul
    T 13 get M 4 get mul add
    T 14 get M 7 get mul add
     
    T 12 get M 2 get mul
    T 13 get M 5 get mul add
    T 14 get M 8 get mul add
    
    T 15 get
     
  ]
/T cgfx3d 1 get def
/M M 3x3-inverse def
  [
    M 0 get T 0 get mul
    M 1 get T 4 get mul add
    M 2 get T 8 get mul add
    
    M 0 get T 1 get mul
    M 1 get T 5 get mul add
    M 2 get T 9 get mul add
    
    M 0 get T 2 get mul
    M 1 get T 6 get mul add
    M 2 get T 10 get mul add
    
    M 0 get T 3 get mul
    M 1 get T 7 get mul add
    M 2 get T 11 get mul add
    
    % -----------------------------
    
    M 3 get T 0 get mul
    M 4 get T 4 get mul add
    M 5 get T 8 get mul add
    
    M 3 get T 1 get mul
    M 4 get T 5 get mul add
    M 5 get T 9 get mul add
    
    M 3 get T 2 get mul
    M 4 get T 6 get mul add
    M 5 get T 10 get mul add
    
    M 3 get T 3 get mul
    M 4 get T 7 get mul add
    M 5 get T 11 get mul add
    
    % -----------------------------
    
    M 6 get T 0 get mul
    M 7 get T 4 get mul add
    M 8 get T 8 get mul add
    
    M 6 get T 1 get mul
    M 7 get T 5 get mul add
    M 8 get T 9 get mul add
    
    M 6 get T 2 get mul
    M 7 get T 6 get mul add
    M 8 get T 10 get mul add
    
    M 6 get T 3 get mul
    M 7 get T 7 get mul add
    M 8 get T 11 get mul add
    
    % -----------------------------
    
    T 12 get
    T 13 get
    T 14 get
    T 15 get
  ]
  cgfx3d 2 get
]
end
gset3d
} def

%
% v => v - 2 <v, a> a
%
% Matrix = I - 2 a a
% a

/reflect3d { 4 dict begin
reflection-matrix3d 
concat3d
end } def

% [x y z w] [a00 a01 a02 a03 ... ]
% but the vector is a linear function
% so it is multiplying by transpose
% if T is the current ctm3d, the point P -> P T transform3d
% but the plane f=0 -> f T^{-1} dual-transform3d

/dual-transform3d { 4 dict begin
/v exch def
/T exch def
[
  v 0 get T 0 get mul
  v 1 get T 4 get mul add
  v 2 get T 8 get mul add
  v 3 get T 12 get mul add
  
  v 0 get T 1 get mul
  v 1 get T 5 get mul add
  v 2 get T 9 get mul add
  v 3 get T 13 get mul add
  
  v 0 get T 2 get mul
  v 1 get T 6 get mul add
  v 2 get T 10 get mul add
  v 3 get T 14 get mul add
  
  v 0 get T 3 get mul
  v 1 get T 7 get mul add
  v 2 get T 11 get mul add
  v 3 get T 15 get mul add
]
end } def

% 4d to 3d homogeneous
/project3d { 4 dict begin
/T exch def
/v exch def
[
  T 0 get v 0 get mul
  T 1 get v 1 get mul
  add 
  T 2 get v 2 get mul 
  add
  T 3 get v 3 get mul 
  add

  T 4 get v 0 get mul
  T 5 get v 1 get mul
  add 
  T 6 get v 2 get mul 
  add
  T 7 get v 3 get mul 
  add

  T 8 get v 0 get mul
  T 9 get v 1 get mul
  add 
  T 10 get v 2 get mul 
  add
  T 11 get v 3 get mul 
  add
] 
end } def

% [x y z w] [a00 a01 a02 a03 ... ]

/transform3d {
4 dict begin
/T exch def
/v exch def
[
T 0 get v 0 get mul
T 1 get v 1 get mul
add 
T 2 get v 2 get mul 
add
T 3 get v 3 get mul 
add

T 4 get v 0 get mul
T 5 get v 1 get mul
add 
T 6 get v 2 get mul 
add
T 7 get v 3 get mul 
add

T 8 get v 0 get mul
T 9 get v 1 get mul
add 
T 10 get v 2 get mul 
add
T 11 get v 3 get mul 
add

T 12 get v 0 get mul
T 13 get v 1 get mul
add 
T 14 get v 2 get mul 
add
T 15 get v 3 get mul 
add

] 
end
} def

% sx sy sz

/scale3d {
8 dict begin
/sz exch def
/sy exch def
/sx exch def
/T cgfx3d 0 get def
[
[
  T 0 get sx mul
  T 1 get sy mul
  T 2 get sz mul
  T 3 get 
  
  T 4 get sx mul
  T 5 get sy mul
  T 6 get sz mul
  T 7 get 
  
  T 8 get sx mul
  T 9 get sy mul
  T 10 get sz mul
  T 11 get 
 
  T 12 get sx mul
  T 13 get sy mul
  T 14 get sz mul
  T 15 get 
]
/T cgfx3d 1 get def
[
  T 0 get sx div
  T 1 get sx div
  T 2 get sx div
  T 3 get sx div
  
  T 4 get sy div
  T 5 get sy div
  T 6 get sy div
  T 7 get sy div
  
  T 8 get sz div
  T 9 get sz div
  T 10 get sz div
  T 11 get sz div
 
  T 12 get 
  T 13 get 
  T 14 get 
  T 15 get 
]
  cgfx3d 2 get
]
end
gset3d
} def

% [ <9> ] i

/row {
4 dict begin
/i exch def
/a exch def
a length 9 eq {
  /i i 3 mul def
  /n i 2 add def
} {
  /i i 4 mul def
  /n i 3 add def
} ifelse
[
  i 1 n {
    a exch get
  } for
]
end
} def

% projects from P onto f=Ax+By+Cz+D=0
% two parameters: f = [A B C D] and P
% The map is Q => f(P)*Q - f(Q)P
% It is idempotent.
%
% f(P) I -
%
% A*P[0] A*P[1] A*P[2] A*P[3]
% B*P[0] B*P[1] B*P[2] B*P[3]
% C*P[0] C*P[1] C*P[2] C*P[3]
% D*P[0] D*P[1] D*P[2] D*P[3]
%
% Matrix = f(P) I - P f
% set s0 = (T row 0)*P
% T x this =
% f(P)T[0,0]-A*s -B*s -C*s -D*s

/plane-project {
12 dict begin
aload pop
/P3 exch def
/P2 exch def
/P1 exch def
/P0 exch def
aload pop
/D exch def
/C exch def
/B exch def
/A exch def

/fP 
  A P0 mul 
  B P1 mul add
  C P2 mul add
  D P3 mul add
def
[
/T cgfx3d 0 get def
[
  /s % = (T row 0)*P
  	T 0 get P0 mul
  	T 1 get P1 mul add
  	T 2 get P2 mul add
  	T 3 get P3 mul add
  def
  
  fP T 0 get mul
    A s mul sub
  fP T 1 get mul
    B s mul sub
  fP T 2 get mul
    C s mul sub
  fP T 3 get mul
    D s mul sub


  /s % = (T row 1)*P
  T 4 get P0 mul
  T 5 get P1 mul add
  T 6 get P2 mul add
  T 7 get P3 mul add
  def
  
  fP T 4 get mul
    A s mul sub
  fP T 5 get mul
    B s mul sub
  fP T 6 get mul
    C s mul sub
  fP T 7 get mul
    D s mul sub


  /s % = (T row 2)*P
  T 8 get P0 mul
  T 9 get P1 mul add
  T 10 get P2 mul add
  T 11 get P3 mul add
  def
  
  fP T 8 get mul
    A s mul sub
  fP T 9 get mul
    B s mul sub
  fP T 10 get mul
    C s mul sub
  fP T 11 get mul
    D s mul sub

  /s % = (T row 3)*P
  T 12 get P0 mul
  T 13 get P1 mul add
  T 14 get P2 mul add
  T 15 get P3 mul add
  def
  
  fP T 12 get mul
    A s mul sub
  fP T 13 get mul
    B s mul sub
  fP T 14 get mul
    C s mul sub
  fP T 15 get mul
    D s mul sub
]
/T cgfx3d 1 get def
[
  /s T 0 get T 1 get add T 2 get add T 3 get add def
  s A mul
  s B mul
  s C mul
  s D mul
  /s T 4 get T 5 get add T 6 get add T 7 get add def
  s A mul
  s B mul
  s C mul
  s D mul
  /s T 8 get T 9 get add T 10 get add T 11 get add def
  s A mul
  s B mul
  s C mul
  s D mul
  /s T 12 get T 13 get add T 14 get add T 15 get add def
  s A mul
  s B mul
  s C mul
  s D mul
]
  cgfx3d 2 get
] 
end
gset3d
} def

% - Drawing commands in 3D --------------------------

% P displayed = [x y w z] => [X Y W] -> [X/W Y/W]

/render {
8 dict begin
aload pop
/v3 exch def
/v2 exch def
/v1 exch def
/v0 exch def
/T display-matrix def
/x
  T 0 get v0 mul 
  T 1 get v1 mul add
  T 2 get v2 mul add
  T 3 get v3 mul add
def
/y 
  T 4 get v0 mul 
  T 5 get v1 mul add
  T 6 get v2 mul add
  T 7 get v3 mul add
def
/w 
  T 8 get v0 mul 
  T 9 get v1 mul add
  T 10 get v2 mul add
  T 11 get v3 mul add
def
w 0 eq {
  (Perspective: division by zero!) ==
  quit
} if
x w div
y w div
end
} def

%  x y z -> x y
/transformto2d {
[ 4 1 roll 1 ] ctm3d transform3d render 
} def

/cpt3d 4 array def
/lm3d 4 array def

% cpt3d is a point in the "real" 3d world

% Should we build the current 3d path for reuse?

% x y z
/moveto3d {
1 [ 5 1 roll ] 
cgfx3d 0 get 
transform3d 
aload pop cpt3d astore 
render moveto
cpt3d aload pop lm3d astore pop
} def

% x y z

/lineto3d {
1 [ 5 1 roll ] 
cgfx3d 0 get 
transform3d 
aload pop cpt3d astore 
render lineto
} def

% x y z

/rmoveto3d {
0 [ 5 1 roll ] cgfx3d 0 get
transform3d 			% [dx dy dz 0]
dup 0 get cpt3d 0 get add	% [dx dy dz 0] x+dx
exch 
dup 1 get cpt3d 1 get add	% x+dx [dx dy dz dw] y+dy
exch
dup 2 get cpt3d 2 get add	% x+dx x+dy [dx dy dz dw] z+dz
exch				% x+dx y+dy z+dz [dx dy dz dw]
3 get cpt3d 3 get add		% x+dx x+dy z+dz w+dw
cpt3d astore
render moveto
cpt3d aload pop lm3d astore pop
} def

% x y z

/rlineto3d {
0 [ 5 1 roll ] cgfx3d 0 get
transform3d 		% [dx dy dz 0]
dup 0 get cpt3d 0 get add	% [dx dy dz 0] x+dx
exch 
dup 1 get cpt3d 1 get add	% x+dx [dx dy dz dw] y+dy
exch
dup 2 get cpt3d 2 get add	% x+dx x+dy [dx dy dz dw] z+dz
exch				% x+dx y+dy z+dz [dx dy dz dw]
3 get cpt3d 3 get add		% x+dx x+dy z+dz w+dw
cpt3d astore  
render lineto
} def

% x1 y1 z1 x2 y2 z2 x3 y3 z3 

/curveto3d { 16 dict begin
/z3 exch def
/y3 exch def
/x3 exch def
/z2 exch def
/y2 exch def
/x2 exch def
/z1 exch def
/y1 exch def
/x1 exch def
% F(t) 
/P0 cpt3d display-matrix project3d def
/P1 [x1 y1 z1 1] cgfx3d 0 get transform3d display-matrix project3d def
/w P0 2 get def
/c P1 2 get w div 1 sub def
/x0 P0 0 get w div def
/x1 P1 0 get w div def
/y0 P0 1 get w div def
/y1 P1 1 get w div def
x1 x0 c mul sub 
y1 y0 c mul sub 
[x3 y3 z3 1] cgfx3d 0 get transform3d aload pop cpt3d astore 
display-matrix project3d /P3 exch def
/P2 [x2 y2 z2 1] cgfx3d 0 get transform3d display-matrix project3d def
% We are assuming the display-matrix has images on { z = 0 }
/w P3 2 get def
/c P2 2 get w div 1 sub def
/x3 P3 0 get w div def
/x2 P2 0 get w div def
/y3 P3 1 get w div def
/y2 P2 1 get w div def
x2 x3 c mul sub 
y2 y3 c mul sub 
x3 y3
curveto
end } def

% - are the next two used? --------------------------------

% dP dQ Q

/dcurveto3d { 16 dict begin
/z3 exch def
/y3 exch def
/x3 exch def
/dz3 exch def
/dy3 exch def
/dx3 exch def
/dz0 exch def
/dy0 exch def
/dx0 exch def
/P0 cpt3d display-matrix project3d def
/dP0 [dx0 dy0 dz0 0] cgfx3d 0 get transform3d display-matrix project3d def
/w P0 3 get def 
% c = 1 - w'/w
/c 1 dP0 3 get w div sub def
  P0 0 get w div c mul dP0 0 get w div add
  P0 1 get w div c mul dP0 1 get w div add
[x3 y3 z3 1] cgfx3d 0 get transform3d aload pop cpt3d astore 
display-matrix project3d /P3 exch def
/dP3 [dx3 dy3 dz3 0] cgfx3d 0 get transform3d display-matrix project3d def
/w P3 3 get def
/c 1 dP3 3 get w div add def
  P3 0 get w div c mul dP3 0 get w div sub
  P3 1 get w div c mul dP3 1 get w div sub
  P3 0 get w div
  P3 1 get w div
curveto
end
} def

% dP dQ Q

/dcurveto { 8 dict begin
/y3 exch def
/x3 exch def
/dy3 exch def
/dx3 exch def
/dy0 exch def
/dx0 exch def
currentpoint dy0 add exch dx0 add exch
x3 dx3 sub y3 dy3 sub
x3 y3 
curveto
end } def

% - are the above two used? ----------------------------

/closepath3d {
closepath
lm3d aload pop cpt3d astore pop
} def

% - Conversion from 2d to 3D ---------------------------

/2d-path-convert {
[
  { % x y
    [ 3 1 roll 0 {moveto3d}]
  }
  { % x y
    [ 3 1 roll 0 {lineto3d}]
  }
  { % x1 y1 x2 y2 x3 y3
    [ 7 1 roll
    0 5 1 roll
    0 3 1 roll
    0 {curveto3d} ]
  }
  {
    [ {closepath3d} ]
  }
  pathforall
]
newpath
{
  aload pop exec
} forall
} def

% -----------------------------------------------

% For a simple currentpoint:

/mkpath3dDict 8 dict def

mkpath3dDict begin

/pathcount {
0 
{pop pop 
  pop 1 exit}
{pop pop 
  pop 1 exit}
{pop pop pop pop pop pop 
  pop 1 exit}
{ pop 1 exit}
pathforall
} def

/thereisacurrentpoint {
pathcount
0 gt
{true}
{false}
ifelse
} def

end

% ---------------------------------------------

% stack: t0 t1 N [parameters] /f 

/mkpath3d { load 
/f exch def
/pars exch def
12 dict begin
/N exch def
/t1 exch def
/t exch def

/h t1 t sub N div def
/h3 h 0.333333 mul def

pars t f aload pop
/velocity exch def
/position exch def
/p [ position aload pop 1 ] 
cgfx3d 0 get transform3d display-matrix project3d def
/v [ velocity aload pop 0 ] 
cgfx3d 0 get transform3d display-matrix project3d def

% p v = homogeneous position and velocity
% p/p[3] v/p[3] - (v[3]/p[3])(p/p[3]) = inhomogeneous ones
% = p/w v/w - c*p/w

/w p 3 get def
/c v 3 get w div def
thereisacurrentpoint {
  p 0 get w div p 1 get w div lineto
} {
  p 0 get w div p 1 get w div moveto
} ifelse

N {				% x y = currentpoint
  p 0 get 
    v 0 get 
    p 0 get c mul 
    sub 
    h3 mul 
  add 
  w div
  
  p 1 get 
    v 1 get 
    p 1 get c mul 
    sub 
    h3 mul 
  add
  w div

/t t h add def

pars t f aload pop
/velocity exch def
/position exch def
/p [ position aload pop 1 ] 
cgfx3d 0 get transform3d display-matrix project3d def
/v [ velocity aload pop 0 ] 
cgfx3d 0 get transform3d display-matrix project3d def
/w p 3 get def
/c v 3 get w div def

  p 0 get 
    v 0 get 
    p 0 get c mul 
    sub 
    h3 mul 
  sub 
  w div
  
  p 1 get 
    v 1 get 
    p 1 get c mul 
    sub 
    h3 mul 
  sub
  w div

p 0 get w div
p 1 get w div
curveto

} repeat
end % local dict
} def

% makes polygon out of control points

/mkcontrolpath3d { load
mkpath3dDict begin
1 dict begin
/f exch def
/pars exch def
/N exch def
/t1 exch def
/t exch def

/h t1 t sub N div def
/h3 h 0.333333 mul def

pars t f aload pop
/velocity exch def
/position exch def

position aload pop
thereisacurrentpoint {
	lineto3d
} {
	moveto3d
} ifelse

N {				% x y = currentpoint
% currentpoint pixel pop

position 0 get
velocity 0 get		% x dx/dt
h3 mul add
position 1 get
velocity 1 get		% y dy/dt
h3 mul add
position 2 get
velocity 2 get		% z dz/dt
h3 mul add

lineto3d

/t t h add def

pars t f aload pop
/velocity exch def
/position exch def

position 0 get
velocity 0 get 
h3 mul sub
position 1 get
velocity 1 get 
h3 mul sub
position 2 get
velocity 2 get 
h3 mul sub

lineto3d

position 0 get
position 1 get
position 2 get

lineto3d

} repeat
end % local dict
end % mkpath3d dict
} def

% -----------------------------------------------

% makes polygon from endpoints

/mkpolypath3d { load
/f exch def
/pars exch def
mkpath3dDict begin
1 dict begin
/N exch def
/t1 exch def
/t exch def

/h t1 t sub N div def
/h3 h 0.333333 mul def

pars t f aload pop
/velocity exch def
/position exch def

position aload pop
thereisacurrentpoint {
	lineto3d
} {
	moveto3d
} ifelse

N {				% x y = currentpoint
% currentpoint pixel pop

/t t h add def

pars t f aload pop
/velocity exch def
/position exch def

position 0 get
position 1 get
position 2 get
lineto3d

} repeat
end % local dict
end % mkpath3d dict
} def

% ---------------------------------------------

% length width

/plainarrow3d {
5 dict begin
/shaftwidth exch def
/arrowlength exch def
/headwidth shaftwidth 3 mul def
/headlength headwidth def
/shaftlength arrowlength shaftwidth 2.5 mul sub def
0 0 0 moveto3d
0 shaftwidth 0.5 mul 0 lineto3d
% shaftlength 0 0 rlineto3d
shaftlength shaftwidth 0.5 mul 0 lineto3d
arrowlength headlength sub headwidth 0.5 mul 0 lineto3d
arrowlength 0 0 lineto3d
arrowlength headlength sub headwidth -0.5 mul 0 lineto3d
shaftlength shaftwidth -0.5 mul 0 lineto3d
0 shaftwidth -0.5 mul 0 lineto3d
0 0 0 lineto3d
end
} def

% length width

/plainarrowtail3d {
5 dict begin
/shaftwidth exch def
/arrowlength exch def
0 0 0 moveto3d
0 shaftwidth 0.5 mul 0 lineto3d
arrowlength 0 0 rlineto3d
0 shaftwidth neg 0 rlineto3d
arrowlength neg 0 0 rlineto3d
0 0 0 lineto3d
end
} def

% --- shading ------------------------------------------------------------------

% all the shade input routines have as one argument a number between -1 and 1
% the result of a calculation of the dot-product of two unit vectors

% linear interpolation: s [a b] -> a + (b-a)*t

/lshade { % s [a b]
exch 1 add 2 div 	% t in [0 1]
% [a b] t
exch aload 0 get		% t a b a
4 1 roll 				% a t a b
sub mul sub			% a - t(a-b)
} def

%  # in [-1 1] & coefficient array [A B C D]: 
% A etc = control points, A = min, D = max
% 1 = facing towards, -1 = facing away from light
% x -> (x+1)/2 = 0.5(x+1) takes [-1, 1] -> [0, 1]
% evaluate by Horner's method

/shade {                             % t [array]
exch                                 % [array] t
1 add 0.5 mul 	                     % a t now in [0 1]
1 1 index sub                        % a t s=1-t
dup dup mul                          % a t s s^2
dup 2 index mul                      % a t s s^2 s^3
5 -1 roll aload pop                  % t s s^2 s^3 a0 a1 a2 a3=P0
7 index mul                          % t s s^2 s^3 a0 a1 a2 a3.t
exch                                 % t s s^2 s^3 a0 a1 a3.t a2
7 -1 roll                            % t s^2 s^3 a0 a1 a3.t a2 s
mul 3 mul add                        % t s^2 s^3 a0 a1 a3.t+3.a2.s=P1
5 index mul                          % t s^2 s^3 a0 a1 P1.t
exch                                 % t s^2 s^3 a0 P1.t a1
5 -1 roll                            % t s^3 a0 P1.t a1 s^2
mul 3 mul add                        % t s^3 a0 P1.t+3.a1.s^2=P2
4 -1 roll mul                        % s^3 a0 P2.t
3 1 roll mul add                     % P2.t + a0.s^3=P3
} def

% t y=[ y0 y1 ... yn ]
/bernstein { % t y 
  % constants y n t s=1-t
  % variables k C P
  dup length % t y n+1
  1 sub      % t y n
  3 -1 roll 1 % y n t 1
  1 index sub % y n t s
  % constants in place
  1           % y n t s k
  3 index 3 index mul % y n t s k C=nt
  5 index 0 get       % y n t s k C P=y0
  5 index {           % y n t s k C P
    % P -> s.P + C.y[k]
    % C -> C.t.(n-k)/(k+1) 
    % k -> k+1
    3 index mul       % y n t s k C P.s
    1 index           % y n t s k C P.s C
    7 index           % y n t s k C P.s C y 
    4 index get mul add  % y n t s k C P.s+C.y[k]=new P
    3 1 roll          % y n t s P* k C
    5 index           % y n t s P* k C n
    2 index sub mul   % y n t s P* k C.(n-k)
    1 index 1 add div % y n t s P* k C.(n-k)/(k+1)
    4 index mul       % y n t s P* k C*
    3 1 roll 1 add    % y n t s C* P* k*
    3 1 roll          % y n t s k* C* P*
  } repeat
  7 1 roll 6 { pop } repeat
} def

% shading: s in [-1 1] and y a Bernstein array B -> t -> B(t)
/bshade { exch 
1 add 2 div 
exch bernstein
} def

% ---------------------------------------------------------------------------------

% input: [pars] /fcn s0 s1 t0 t1 ns nt
% the fcn: [pars] s t -> f_{pars}(s, t)
% output: a polygonal surface of faces [ normal-fcn triangle ]

/mksurface {
16 dict begin
/nt exch def
/ns exch def
/t1 exch def
/t0 exch def
/s1 exch def
/s0 exch def
/ds s1 s0 sub ns div def
/dt t1 t0 sub nt div def
/f exch cvx def
/pars exch def
/P [
  /s s0 def
  ns 1 add {
    [
      /t t0 def
      nt 1 add {
        pars s t f
        /t t dt add def
      } repeat
    ]
    /s s ds add def
  } repeat
] def
% P[i][j] = f(s0 + i.ds, t0 + j.dt)
[
  0 1 ns 1 sub {
    /i exch def
    0 1 nt 1 sub {
      /j exch def
      % an array of triangles (i, j, 0) + (i, j, 1) 
      % dividing the rectangles in two
      /P00 P i get j get def
      /P10 P i 1 add get j get def
      /P01 P i get j 1 add get def
      /P11 P i 1 add get j 1 add get def
      % normal
      /Q P10 P00 vector-sub P01 P00 vector-sub cross-product def
      /r Q vector-length def
      r 0 ne {
        [
          [ Q aload pop Q P10 dot-product neg ]
          % array of pointers to three vertices
          [ P00 P10 P01 ]
        ] 
      } if
      /Q P01 P11 vector-sub P10 P11 vector-sub cross-product def
      /r Q vector-length def
      r 0 ne {
        [
          [ Q aload pop Q P01 dot-product neg ]
          % array of pointers to three vertices
          [ P10 P11 P01 ]
        ]
      } if
    } for
  } for
]
end
} def

% an array of vertices 
% traversed according to right hand rule
% output normalized

/normal-function {
2 dict begin
/a exch def
/n 
  a 1 get a 0 get vector-sub 
  a 2 get a 1 get vector-sub 
  cross-product 
def
/r n 0 get dup mul n 1 get dup mul add n 2 get dup mul add sqrt def
r 0 gt {
  /n [ n 0 get r div n 1 get r div n 2 get r div ] def
  [
    n aload pop
    a 0 get n dot-product neg
  ]
}{ [] } ifelse
end
} def

% --- light ------------------------------------------------

% should be part of the graphics environment

/set-light { /light-source exch def } def

/get-virtual-light {
  light-source cgfx3d 1 get transform3d
} def


 
%%EndProlog
gsave
%lanindL2 START  20000505
/lanind 1 def
/lantex [(G) (E) (S) (F) (I) (J) (M)] def
/showde {0 lanind eq {show} {pop} ifelse} bind def
/showen {1 lanind eq {show} {pop} ifelse} bind def
/showes {3 lanind eq {show} {pop} ifelse} bind def
/showfr {2 lanind eq {show} {pop} ifelse} bind def
/showit {4 lanind eq {show} {pop} ifelse} bind def
/showjp {5 lanind eq {show} {pop} ifelse} bind def
/showm  {6 lanind eq {show} {pop} ifelse} bind def
 
/lanindg where {pop /lanind1 lanindg def /lanind2 lanindg def}
               {/lanind1 1 def /lanind2 1 def} ifelse

/lanind lanind1 def
%lanind1 1 lanind2 {/lanind exch def %output showpage

%ps3d.inc

gsave

72 90 translate

250 -7 moveto
6 /Times-Roman FS
(DE421-7N) show

0 0 translate	
0 0 moveto
(XYZ) show 

0.01 MM 0.01 MM scale
15 setlinewidth
0 0  moveto 5400 0 rlineto 0 4000 rlineto -5400 0 rlineto
closepath stroke

grestore
gsave

72 90 translate

/fakt 2540 4 div def

%0.01 MM dup scale

18 18 scale

0.1 0.1 translate

/ymax 5000 def
/xmin 180 def

/fakt 1 def

1 0 0 setrgbcolor

[0 0 5 fakt mul 1 fakt mul] set-eye

[0 1 fakt mul 0] 30 rotate3d

0 setlinewidth
0 1 0 setrgbcolor
0 0 0 moveto3d 10 fakt mul 0 0 rlineto3d 
               0 06 fakt mul 0 rlineto3d
              -10 fakt mul 0 0 rlineto3d
closepath stroke

showpage

%%Trailer


%%EndDocument
EndEPSF grestore gsave

BeginEPSF
219 MM 064 MM translate
  10 /Times-ISOL1 FS  53 MM 1 MM moveto ( ) show 1 1 scale  -77 -91 translate
%%BeginDocument: Bild 26

%line 479
%!PS-Adobe-3.0 EPSF-3.0 DE421-8N
%%BoundingBox: 70 90 226 206

%START PDFDE011.EPS
/pdfmark18 where {pop} {userdict /pdfmark18 /cleartomark load put} ifelse
/languagelevel where {pop languagelevel} {1} ifelse
2 lt { userdict (<<) cvn ([) cvn load put
       userdict (>>) cvn (]) cvn load put} if
[ /Title (PostScript pictures: farbe.li.tu-berlin.de/DE42/DE42.HTM)
  /Author (compare K. Richter "Computergrafik ...": ISBN 3-8007-1775-1)
  /Subject (goto: http://farbe.li.tu-berlin.de http://130.149.60.45/~farbmetrik)
  /Keywords (image reproduction, colour devices)
  /Creator (klaus.richter@mac.com)
  /CreationDate (D:2018060112000)
  /ModDate (D:20180601112000)
/DOCINFO pdfmark18
[ /View [ /Fit ]
/DOCVIEW pdfmark18
%END  PDFDE011

/BeginEPSF {% def               % Prepare for EPS file
/b4_Inc_state save def          % Save state for cleanup
/dict_count countdictstack def
/op_count count 1 sub def       % Count objects on op stack
userdict begin                  % Make userdict current dict
/showpage {} def
0 setgray 0 setlinecap
1 setlinewidth 0 setlinejoin
10 setmiterlimit [] 0 setdash newpath
/languagelevel where            % If level not equal to 1 then
 {pop languagelevel where       % If level not equal to 1 then
 1 ne
 {false setstrokeadjust false setoverprint
 } if
} if
} bind def

/EndEPSF  {% def              % End for EPS file
 count op_count sub {pop} repeat
 countdictstack dict_count sub {end} repeat	% Clean up dict stack
 b4_Inc_state restore
} bind def


% !AUSTAUSCH Times-Roman -> Times-Roman-ISOLatin1=Times-I
 
/Times-Roman findfont dup length dict  begin
{1 index /FID ne {def} {pop pop} ifelse }forall
/Encoding ISOLatin1Encoding def
currentdict end
/Times-ISOL1 exch definefont pop
 
/Times-Italic findfont dup length dict  begin
{1 index /FID ne {def} {pop pop} ifelse }forall
/Encoding ISOLatin1Encoding def
currentdict end
/TimesI-ISOL1 exch definefont pop
 
/Times-Bold findfont dup length dict  begin
{1 index /FID ne {def} {pop pop} ifelse }forall
/Encoding ISOLatin1Encoding def
currentdict end
/TimesB-ISOL1 exch definefont pop
 
/Times-BoldItalic findfont dup length dict  begin
{1 index /FID ne {def} {pop pop} ifelse }forall
/Encoding ISOLatin1Encoding def
currentdict end
/TimesBI-ISOL1 exch definefont pop
 
/FS {findfont exch scalefont setfont} bind def
/MM {72 25.4 div mul} def /str {8 string } bind def
 
/TK {250 16.67 div /Times-ISOL1 FS} bind def
/TM {300 16.67 div /Times-ISOL1 FS} bind def
/TG {350 16.67 div /Times-ISOL1 FS} bind def
 
/TIK {250 16.67 div /TimesI-ISOL1 FS} bind def
/TIM {300 16.67 div /TimesI-ISOL1 FS} bind def
/TIG {350 16.67 div /TimesI-ISOL1 FS} bind def
 
/TBK {250 16.67 div /TimesB-ISOL1 FS} bind def
/TBM {300 16.67 div /TimesB-ISOL1 FS} bind def
/TBG {350 16.67 div /TimesB-ISOL1 FS} bind def
 
/TBIK {250 16.67 div /TimesBI-ISOL1 FS} bind def
/TBIM {300 16.67 div /TimesBI-ISOL1 FS} bind def
/TBIG {350 16.67 div /TimesBI-ISOL1 FS} bind def

/RK {250 16.67 div /Times-Roman FS} bind def
/RM {300 16.67 div /Times-Roman FS} bind def
/RG {350 16.67 div /Times-Roman FS} bind def

/RIK {250 16.67 div /Times-Italic FS} bind def
/RIM {300 16.67 div /Times-Italic FS} bind def
/RIG {350 16.67 div /Times-Italic FS} bind def

/RBK {250 16.67 div /Times-Bold FS} bind def
/RBM {300 16.67 div /Times-Bold FS} bind def
/RBG {350 16.67 div /Times-Bold FS} bind def

/RBIK {250 16.67 div /Times-BoldItalic FS} bind def
/RBIM {300 16.67 div /Times-BoldItalic FS} bind def
/RBIG {350 16.67 div /Times-BoldItalic FS} bind def

/tolvfcol    %Farbkreis-Reihenfolge
[ (000) (F00) (FF0) (0F0) (0FF) (00F) (F0F) (FFF)
  (777) (700) (770) (070) (077) (007) (707) (F07) %15=R
  (333) (F77) (FF7) (7F7) (7FF) (77F) (F7F) (07F) %23=B
  (BBB) (F70) (7F0) (0F7) (07F) (70F) (F07) (0F7) %31=G
] def
 
/tcmyfcol    %Farbkreis-Reihenfolge
[ (FFF) (0FF) (00F) (F0F) (F00) (FF0) (0F0) (000)
  (888) (8FF) (88F) (F8F) (F88) (FF8) (8F8) (0F8) %15=R
  (CCC) (088) (008) (808) (800) (880) (080) (F80) %23=B
  (444) (08F) (80F) (F08) (F80) (8F0) (0F8) (F08) %31=G
] def
 
/tcmykfcol   %Farbkreis-Reihenfolge
[ (000F) (0FF0) (00F0) (F0F0) (F000) (FF00) (0F00) (0000)
  (0008) (0FF8) (00F8) (F0F8) (F008) (FF08) (0F08) (0F80) %15=R
  (000C) (0880) (0080) (8080) (8000) (8800) (0800) (F800) %23=B
  (0004) (0F80) (80F0) (F080) (F800) (8F00) (0F80) (F080) %31=G
] def
 
/tolvfcols    %Farbkreis-Reihenfolge
[ (000*) (F00*) (FF0*) (0F0*) (0FF*) (00F*) (F0F*) (FFF*)
  (777*) (700*) (770*) (070*) (077*) (007*) (707*) (F07*) %15=R
  (333*) (F77*) (FF7*) (7F7*) (7FF*) (77F*) (F7F*) (07F*) %23=B
  (BBB*) (F70*) (7F0*) (0F7*) (07F*) (70F*) (F07*) (0F7*) %31=G
] def
 
/tcmyfcols    %Farbkreis-Reihenfolge
[ (FFF*) (0FF*) (00F*) (F0F*) (F00*) (FF0*) (0F0*) (000*)
  (888*) (8FF*) (88F*) (F8F*) (F88*) (FF8*) (8F8*) (0F8*) %15=R
  (CCC*) (088*) (008*) (808*) (800*) (880*) (080*) (F80*) %23=B
  (444*) (08F*) (80F*) (F08*) (F80*) (8F0*) (0F8*) (F08*) %31=G
] def
 
/tcmykfcols   %Farbkreis-Reihenfolge
[ (000F*) (0FF0*) (00F0*) (F0F0*) (F000*) (FF00*) (0F00*) (0000*)
  (0008*) (0FF8*) (00F8*) (F0F8*) (F008*) (FF08*) (0F08*) (0F80*) %15=R
  (000C*) (0880*) (0080*) (8080*) (8000*) (8800*) (0800*) (F800*) %23=B
  (0004*) (0F80*) (80F0*) (F080*) (F800*) (8F00*) (0F80*) (F080*) %31=G
] def
 
/fcolors     %CMYN 32 Testfarben Nr. 0 bis 31; Farbkreis-Reihenfolge
[{0.0 0.0 0.0 1.0}  {0.0 1.0 1.0 0.0}  {0.0 0.0 1.0 0.0}  {1.0 0.0 1.0 0.0}
 {1.0 0.0 0.0 0.0}  {1.0 1.0 0.0 0.0}  {0.0 1.0 0.0 0.0}  {0.0 0.0 0.0 0.0}
 
 {0.0 0.0 0.0 0.5}  {0.0 1.0 1.0 0.5}  {0.0 0.0 1.0 0.5}  {1.0 0.0 1.0 0.5}
 {1.0 0.0 0.0 0.5}  {1.0 1.0 0.0 0.5}  {0.0 1.0 0.0 0.5}  {0.0 1.0 0.5 0.0}
 
 {0.0 0.0 0.0 0.75} {0.0 0.5 0.5 0.0}  {0.0 0.0 0.5 0.0}  {0.5 0.0 0.5 0.0}
 {0.5 0.0 0.0 0.0}  {0.5 0.5 0.0 0.0}  {0.0 0.5 0.0 0.0}  {1.0 0.5 0.0 0.0}
 
 {0.0 0.0 0.0 0.25} {0.0 0.5 1.0 0.0}  {0.5 0.0 1.0 0.0}  {1.0 0.0 0.5 0.0}
 {1.0 0.5 0.0 0.0}  {0.5 1.0 0.0 0.0}  {0.0 1.0 0.5 0.0}  {1.0 0.0 0.5 0.0}
] def
 
/fak 0.5 def
 
/Far     %Farbkreis-Reihenfolge
 [ 0  1  2  3  4  5  6  7
   8  9 10 11 12 13 14 15 %R
  16 17 18 19 20 21 22 23 %B
  24 25 26 27 28 29 30 31 %G
 ] def
 
/cFar     %Kompensativ-Farbkreis-Reihenfolge
 [ 8  4  5  6  1  2  3  0
   0 20 21 22 17 18 19 31 %G
  24 12 13 14  9 10 11  2 %J
  16 28 29 30 25 26 27 15 %R
 ] def
 
/Btx    %Farbkreis- -> %Btx-Reihenfolge
 [ 0  1  3  2  5  6  4  7
   8  9 11 10 13 14 12 15  %R
  16 17 19 18 21 22 20 23  %B
  24 25 26 27 28 29 30 31  %G
 ] def
 
/cBtx    %Farbkreis- -> %Kompensativ-Btx-Reihenfolge
 [ 7  4  6  5  2  3  1  0
   8 20 22 21 18 19 17 31 %G
  24 12 14 13 10 11  9  2 %J
  16 25 26 27 28 29 30 15 %R
 ] def
 
/rec %x, y width heigth
  {/heigth exch def /width exch def
   moveto width 0 rlineto 0 heigth rlineto width neg 0 rlineto
   closepath } bind def
 
/colrecfi %x y width heigth c m y k
  {setrgbcolor rec fill} bind def
 
/colrecst %x y width heigth c m y k
  {setrgbcolor rec stroke} bind def
 
/tzo {0.0 1.0 1.0 0.0} bind def %Reproduktionsfarben
/tzl {1.0 0.0 1.0 0.0} bind def
/tzv {1.0 1.0 0.0 0.0} bind def
/tzc {1.0 0.0 0.0 0.0} bind def
/tzm {0.0 1.0 0.0 0.0} bind def
/tzy {0.0 0.0 1.0 0.0} bind def
 
/tzn {0.0 0.0 0.0 1.00} bind def %Graureihe
/tzd {0.0 0.0 0.0 0.75} bind def
/tzz {0.0 0.0 0.0 0.50} bind def
/tzh {0.0 0.0 0.0 0.25} bind def
/tzw {0.0 0.0 0.0 0.00} bind def
 
/tzr {0.0 1.0 0.5 0.0} bind def %Elementarfarben
/tzg {1.0 0.0 0.5 0.0} bind def
/tzb {1.0 0.5 0.0 0.0} bind def
/tzj {0.0 0.0 1.0 0.0} bind def
 
/tzrz {0.0 1.0 0.5 0.5} bind def %Elementarfarben vergraut
/tzgz {1.0 0.0 0.5 0.5} bind def
/tzbz {1.0 0.5 0.0 0.5} bind def
/tzjz {0.0 0.0 1.0 0.5} bind def
 
/tfo {tzo setcmykcolor} bind def
/tfl {tzl setcmykcolor} bind def
/tfv {tzv setcmykcolor} bind def
/tfc {tzc setcmykcolor} bind def
/tfm {tzm setcmykcolor} bind def
/tfy {tzy setcmykcolor} bind def
 
/tfn {tzn setcmykcolor} bind def
/tfd {tzd setcmykcolor} bind def
/tfz {tzz setcmykcolor} bind def
/tfh {tzh setcmykcolor} bind def
/tfw {tzw setcmykcolor} bind def
 
/tfr {tzr setcmykcolor} bind def
/tfg {tzg setcmykcolor} bind def
/tfb {tzb setcmykcolor} bind def
/tfj {tzj setcmykcolor} bind def
 
/tfrz {tzrz setcmykcolor} bind def
/tfgz {tzgz setcmykcolor} bind def
/tfbz {tzbz setcmykcolor} bind def
/tfjz {tzjz setcmykcolor} bind def

%
% - %This is ps3d.inc ----------------------------------

% - Copyright Bill Casselman
% - Original version 1.0 November, 1998
% - Version 1.1 December, 1999
% -      Took out aliases for moveto etc.
% -      Made display-matrix a 3 x 4 homogeneous matrix, added it to the 3d gstack 
% -      Allowed arbitrary eye location, 3d -> 2d projects onto z = 0 plane
% -      Although fancy stuff not yet implemented
% -      Made ght a variable
% -      Version 1.1 is *not* backwards compatible!
% - Version 1.2 August, 2002
% -      Thorough interpretation of matrices as arrays of columns and point vectors as rows
% -      And some speed up
% -      Similar rewriting of matrix.inc
% -      Again, backwards incompatible!
% - Version 1.3 August, 2003
% -      Rewriting shade for efficiency
% - Thanks to Jim Blinn's book `A trip down the graphics pipeline'
% - for several suggestions that (I hope) made this code cleaner 
% - by suggesting how useful homogeneous coordinates were.
% November 10, 2003: added fancier shading
% December 17, 2003: changed arguments for mkpath procedures

% ------------------------------------------------


% - Inserting matrix.inc ----------------------

% - Vector calculations (usually good in any number of dimensions) ----------

% - matrices in this package are usually laid out in a single array by columns ---
% - i.e. [ column1 column 2 ... ]
% - but sometimes as a double array [ [ column1] [column2] ... ] 

% <double array>  /to-single-array
% <single-array> /to-double-array
% <n> /identity
% <u> <v> /dot-product
% <u> <c> /vector-scale
% <u> <v> /vector-add
% <u> <v> /vectorssub
% <u> /vector-length
% <u> <v> cross-product
% <axis> <angle> /rotation-matrix3d
% v [a b c] /euclidean-reflect
% [a b c] /reflection-matrix-3d
% <m> <n> /matrix-mul
% <m> <v> /matrix-vector
% <v> <m> /vector-matrix 
% <m> /transpose
% <m> 3x3-det
% <m> /3x3-inverse
% <u> <v> /angle-between
% <x> /acos
% <x> <a> <a^v> /skew-reflect
% <a> <a^v> /skew-reflection-matrix

% - matrices in this package are laid out in a single array by columns ---------

% a double array: cannot be empty - just lays out all items
/to-single-array {
% [ [. . . ][ . . . ] ] => [ . . . . . . ]
[
	exch { % successive rows
		aload pop
	} forall
]
} def

% ----------------------------------------------

% [ ... ] a square matrix made into an array of columns
/to-double-array { 4 dict begin
/A exch def
/N A length sqrt round cvi def
/i 0 def
[
N {
	[
	N {
		A i get
		/i i 1 add def
	} repeat
	]
} repeat
]
end } def

% ----------------------------------------

% returns the nxn identity matrix as single array
/identity { 1 dict begin
/n exch def
[
  n 1 sub {
    1 
    n {
      0
	} repeat 
  } repeat
  1
]
end } def

% --- vector algebra --------------------------------

% u v -> u.v
/dot-product { 1 dict begin
/v exch def
0 0	     		% u s i
3 2 roll { 		% s i u[i]
  v 			% s i u[i] v
  2 index get mul 	% s i u[i]*v[i]
  3 2 roll		% i u[i]*v[i] s
  add exch 1 add	% s i
} forall
pop
end } def

% v c -> c.v
/vector-scale { 1 dict begin
/c exch def
[ exch
{ 		% s i u[i]
  c mul			% s i u[i] v 
} forall
]
end } def

% u v -> u+v
/vector-add { 1 dict begin
/v exch def
[ exch
0 	     	% u i
exch { 		% i u[i]
  v 		% i u[i] v
  2 index get add 	% i u[i]+v[i]
  exch 1 add	% i
} forall
pop
]
end } def

% u v -> u-v
/vector-sub { 1 dict begin
/v exch def
[ exch
0 	     	% u i
exch { 		% i u[i]
  v 		% i u[i] v
  2 index get sub 	% i u[i]+v[i]
  exch 1 add	% i
} forall
pop
]
end } def

% [x y z ... ] -> r
% watch out for overflow

/vector-length { 1 dict begin
dup
% find maximum entry
/max 0 def
{ % max 
  abs dup max gt {
    % if abs gt max
    /max exch def
  } {
    pop
  } ifelse
} forall

max 0 ne {
  0 exch 
  {  % 0 v[i]
    max div dup mul add
  } forall
  sqrt
  max mul
} {
  pop 0
} ifelse
end } def

% v -> v/|v|
/normalized { 1 dict begin
dup 			% v v
vector-length /r exch def
[ exch
  {
    r div
  } forall
]
end } def

% u v
% u0 u1 u2
% v0 v1 v2
% -> u x v
/cross-product {
2 dict begin
/v exch def
/u exch def
[
  u 1 get v 2 get mul
  v 1 get u 2 get mul sub

  v 0 get u 2 get mul
  u 0 get v 2 get mul sub

  u 0 get v 1 get mul
  v 0 get u 1 get mul sub
]
end
} def

% --------------------------------------------------------------

% axis A -> a matrix
/rotation-matrix3d {
8 dict begin
dup 
cos /c exch def
sin /s exch def
/a exch def
/r a vector-length def
/a0 a 0 get r div def
/a1	a 1 get r div def
/a2 a 2 get r div def

[

% e = [1 0 0] etc.
% e0 = (e.a)a, e# = e - e0, e* = a x e = a x e0 + a x e# = a x e#
/x a0 def
/e0 [a0 x mul
     a1 x mul 
     a2 x mul] def
/e# [1 e0 0 get sub 
     e0 1 get neg 
     e0 2 get neg] def
% [a0 a1 a2]
% [ 1  0  0]
/e* [0 
     a2 
     a1 neg
    ] def
e# 0 get c mul e* 0 get s mul add e0 0 get add 
e# 1 get c mul e* 1 get s mul add e0 1 get add 
e# 2 get c mul e* 2 get s mul add e0 2 get add 

/x a1 def
/e0 [a0 x mul a1 x mul a2 x mul] def
/e# [e0 0 get neg 
     1 e0 1 get sub 
     e0 2 get neg] def
% [a0 a1 a2]
% [ 0  1  0]
/e* [a2 neg 
     0
     a0
    ] def
e# 0 get c mul e* 0 get s mul add e0 0 get add 
e# 1 get c mul e* 1 get s mul add e0 1 get add 
e# 2 get c mul e* 2 get s mul add e0 2 get add 

/x a2 def
/e0 [a0 x mul a1 x mul a2 x mul] def
/e# [e0 0 get neg
     e0 1 get neg
     1 e0 2 get sub] def
% [a0 a1 a2]
% [ 0  0  1]
/e* [a1 
     a0 neg
     0
    ] def
e# 0 get c mul e* 0 get s mul add e0 0 get add 
e# 1 get c mul e* 1 get s mul add e0 1 get add 
e# 2 get c mul e* 2 get s mul add e0 2 get add 

]
% [ r0 r1 r2 r3 r4 r5 r6 r7 r8 ] -> [r0 r3 r6 r1 r4 r7 r2 r5 r8 ]
/r exch def
[
	r 0 get 
	r 3 get
	r 6 get
	r 1 get
	r 4 get
	r 7 get
	r 2 get
	r 5 get
	r 8 get
] 
end
} def

% v a -> v - 2(a.v)/(a.a) a
/euclidean-reflect { 16 dict begin
/a exch def
/v exch def
/N a length def
/d a v dot-product a dup dot-product div 2 mul def
[
  0
  v {
    % i v[i]
    exch dup 1 add					% v[i] i i+1
	3 1 roll							  % i+1 v[i] i
    a exch get d mul 				% i+1 v[i] a[i]*d
	sub										% i+1 v[i]-d*a[i]
	exch									% rv[i] i+1
  } forall
  pop
]
end } def

% f = [A B C] => linear 3d transformation: f not necessarily normalized
% Rv = v - 2 <f', v> f'

/reflection-matrix3d {
3 dict begin
aload pop
/C exch def
/B exch def
/A exch def
/r [ A B C ] vector-length def
/A A r div def
/B B r div def
/C C r div def
[
  1 A A mul dup add sub   B A mul dup add neg   C A mul dup add neg
    A B mul dup add neg 1 B B mul dup add sub   C B mul dup add neg
    A C mul dup add neg   B C mul dup add neg 1 C C mul dup add sub
]
end
} def

/matrix-mul {
8 dict begin
/B exch def
/A exch def
/n A length sqrt round cvi def
%  0    1  ...
%  n  n+1 ...
% 2n 2n+1 ...
[
  0
  n {
    % i = initial index of the column on the stack = 0, n, 2n ... 
    % after all previous entries
    dup n add exch 0	
    n {
	  % i+n i j on stack
      % j = initial index of the row
	  2 copy 1 add % i+n i j i j+1
	  4 2 roll	% i+n i j+1 i j
	  /ell exch def
      /k exch def
	  % i+n i j+1 
      0
      n {
		% i+n i j+1 s
        A ell get B k get mul add
        /k k 1 add def
        /ell ell n add def
      } repeat
	  4 1 roll
	  % s i+n i j+1
   	} repeat
    pop pop	% s i+n
  } repeat
  pop
]
end
} def

% A v: A = [ column 1, column 2, ... , column n ]
/matrix-vector {
8 dict begin
/v exch def
/r v length def
/A exch def
/c A length r idiv def
[
  0 1 c 1 sub {
	/i exch def
    % i = initial index of the row
    0 0
    r {
		% s j on stack
		dup 1 add	% s j j+1
		3 1 roll		% j+1 s j
      	v exch get A i get mul add	% j+1 s
		exch
   	  	/i i r add def
    } repeat
	% s r
	pop
  } for
]
end
} def

% v A: A = [ column1 column2 ... ]
/vector-matrix {
8 dict begin
/A exch def
/v exch def
/c v length def
/r A length c idiv def
[
  /i 0 def 
  r {
    % i = initial index of the row
    /j 0 def
    0
    c {
      A i get v j get mul add
      /j j 1 add def
   	  /i i 1 add def
    } repeat
  } repeat
]
end
} def

% a square matrix m x m
% [i, j] = n*i + j

/transpose {
4 dict begin
/M exch def
/n M length sqrt round cvi def
[
/k 0 def
n {
  /i k def
  n { 
    M i get
    /i i n add def
  } repeat
  /k k 1 add def
} repeat
]

end
} def

/3x3-det {
1 dict begin
/m exch def

m 0 get 
m 4 get mul
m 8 get mul

m 1 get 
m 5 get mul
m 6 get mul
add

m 2 get 
m 3 get mul
m 7 get mul
add

m 2 get 
m 4 get mul
m 6 get mul
sub

m 1 get 
m 3 get mul
m 8 get mul
sub

m 0 get 
m 5 get mul
m 7 get mul
sub

end
} def

/3x3-inverse {
2 dict begin
/m exch def
/d m 3x3-det def
[
   m 4 get m 8 get mul 
   m 5 get m 7 get mul sub
   d div
   
   m 2 get m 7 get mul 
   m 1 get m 8 get mul sub
   d div
   
   m 1 get m 5 get mul 
   m 4 get m 2 get mul sub
   d div

   m 5 get m 6 get mul 
   m 3 get m 8 get mul sub
   d div
   
   m 0 get m 8 get mul 
   m 2 get m 6 get mul sub
   d div
   
   m 2 get m 3 get mul 
   m 0 get m 5 get mul sub
   d div

   m 3 get m 7 get mul 
   m 6 get m 4 get mul sub
   d div
   
   m 1 get m 6 get mul 
   m 0 get m 7 get mul sub
   d div
   
   m 0 get m 4 get mul 
   m 1 get m 3 get mul sub
   d div
]
end
} def

/acos {
dup dup % x x x
mul 1 sub neg % x 1-x^2
sqrt exch atan
} def

% u v

/angle-between {
dup vector-length
% u v |v|
3 1 roll
% |v| u v
1 index 
% |v| u v u
dot-product
% |v| u u.v
exch vector-length
% |v| u.v |u|
div exch div
acos
} def

% x a av -> x - <a, x> av

/skew-reflect { 4 dict begin
/av exch def
/a exch def
/x exch def
/d x a dot-product def
[
	0 1 x length 1 sub {
		/i exch def
		x i get av i get d mul sub
	} for
]
end } def

% a av -> matrix
/skew-reflection-matrix { 8 dict begin
/av exch def
/a exch def
/n a length def
[
	0 1 n 1 sub {
		/i exch def
		[ n {0} repeat ] dup i 1 put
		% e[i] 
		a av skew-reflect
	} for
]
to-single-array
transpose
end } def

% - closing matrix.inc ------------------------

% - Defining PostScript commands' equivalents ----------

% - Coordinates in three dimensions -------------------

% There are three steps to drawing something in 3D:
% 1.  Converting from user 3d coords to default 3d coords
% 2.  Projecting onto (x, y)-plane
% 3.  Drawing the image on that plane
% These are more or less independent.  
% The last step is completely controlled by the usual PS stuff.
% The first and second are handled by 3d stuff here.

% - Initialize and manipulate the 3d gstack -----------

/gmax 64 def
/ght 0 def

% gstack = [[t0 d0 dm0] [t1 d2 dm1] [t2 d2 dm2] ... [t(gmax-1) d(gmax-1) dm(gmax-1)] ]

% the ctm is t[ght]
% the dual ctm is at d[ght]
% they are 4 x 4
% display-matrix = 3 x 4

/gstack3d gmax array def

% start with orthogonal projection to positive z-axis
gstack3d 0 [
  [ 1 0 0 0 
    0 1 0 0
    0 0 1 0
    0 0 0 1] 
  [ 1 0 0 0 
    0 1 0 0
    0 0 1 0
    0 0 0 1]
  [ 1 0 0 0
    0 1 0 0
    0 0 0 1]
] put

/gsave3d {
  /ctm gstack3d ght get def
  /ght ght 1 add def 
  ght gmax eq {
    (3d graphics stack overflow!) ==
    quit
  } if
  gstack3d 
    ght
    [ ctm 0 get ctm 1 get ctm 2 get ] 
  put
} def

/grestore3d {
  /ght ght 1 sub def
  ght 0 lt {
     (3d graphics stack underflow!) ==
     quit
  } if
} def

% n - restores to depth n

/gpop3d {
/ght exch def
} def

% [T T* dm]: sets cgfx3d = [T T* dm]

/gset3d {
gstack3d  		% [T T* d] g 
ght			    % [T T* d] g ght
3 2 roll 		    % g ght [T T* d]
put 
} def

% => [T T* dm]

/cgfx3d {
  gstack3d ght get
} def

/ctm3d {
  gstack3d ght get 0 get
} def

/cim3d {
  gstack3d ght get 1 get
} def

/cdm3d {
  gstack3d ght get 2 get
} def

% cpt3d isthe last 3d point drawn to

/currentpoint3d {
cpt3d
cgfx3d 1 get transform3d
aload pop     % x y z w 
pop			
} def

% - Sets up projection into 2D -------------------
		
% O = [x y z w] 
% sets display-matrix perspective onto z = 0 plane

/display-matrix {
  cgfx3d 2 get
} def

% [z0 0 -x0 0
%  0 z0 -y0 0
%  0 0 -w0 z0]
% (transposed)
% gives perspective onto point in z=0 plane
% from [x0 y0 z0 w0]

/set-eye {
4 dict begin
aload pop
/w0 exch def
/z0 exch def
/y0 exch def
/x0 exch def
gstack3d ght get
2 
[ z0 0 x0 neg 0 
  0 z0 y0 neg 0
  0 0 w0 neg z0]
put
end
} def

/get-eye { 1 dict begin
/d display-matrix def
[d 2 get neg d 6 get neg d 0 get d 10 get neg]
end } def

/get-virtual-eye {
get-eye cgfx3d 1 get transform3d
} def

% - backwards compatibility -----------------------------

/origin { get-eye } def
/eye { get-eye } def
/set-display { set-eye } def

% - Manipulate the current transformation matrix -----

% x y z

/translate3d {
8 dict begin
/z exch def
/y exch def
/x exch def
/ctm cgfx3d def
/T ctm 0 get def
[
[
  T 0 get 
  T 1 get 
  T 2 get 
  T 0 get x  mul
  T 1 get y  mul
  add
  T 2 get z  mul
  add
  T 3 get 
  add
  
  T 4 get 
  T 5 get 
  T 6 get
  T 4 get x  mul
  T 5 get y  mul
  add
  T 6 get z  mul
  add
  T 7 get 
  add
   
  T 8 get 
  T 9 get 
  T 10 get
  T 8 get x  mul
  T 9 get y  mul
  add
  T 10 get z  mul
  add
  T 11 get 
  add
   
  T 12 get 
  T 13 get 
  T 14 get
  T 12 get x  mul
  T 13 get y  mul
  add
  T 14 get z  mul
  add
  T 15 get 
  add
]
/T ctm 1 get def
[
  T 0 get T 12 get x mul sub 
  T 1 get T 13 get x mul sub 
  T 2 get T 14 get x mul sub 
  T 3 get T 15 get x mul sub 

  T 4 get T 12 get y mul sub 
  T 5 get T 13 get y mul sub 
  T 6 get T 14 get y mul sub 
  T 7 get T 15 get y mul sub 

  T 8 get T 12 get z mul sub 
  T 9 get T 13 get z mul sub 
  T 10 get T 14 get z mul sub 
  T 11 get T 15 get z mul sub 

  T 12 get
  T 13 get
  T 14 get
  T 15 get
]
  ctm 2 get
]
end
gset3d
} def

% ------------------------------------------------------

% axis A

/rotate3d { 4 dict begin
rotation-matrix3d
/R exch def
/C cgfx3d def
/T C 0 get def
[
[
  % first row
  T 0 get R 0 get mul
  T 1 get R 3 get mul
  add
  T 2 get R 6 get mul
  add
  
  T 0 get R 1 get mul
  T 1 get R 4 get mul
  add
  T 2 get R 7 get mul
  add
  
  T 0 get R 2 get mul
  T 1 get R 5 get mul
  add
  T 2 get R 8 get mul
  add
  
  T 3 get
  
  % second row
  T 4 get R 0 get mul
  T 5 get R 3 get mul
  add
  T 6 get R 6 get mul
  add
  
  T 4 get R 1 get mul
  T 5 get R 4 get mul
  add
  T 6 get R 7 get mul
  add
  
  T 4 get R 2 get mul
  T 5 get R 5 get mul
  add
  T 6 get R 8 get mul
  add
  
  T 7 get
  
  % third row
  T 8 get R 0 get mul
  T 9 get R 3 get mul
  add
  T 10 get R 6 get mul
  add
  
  T 8 get R 1 get mul
  T 9 get R 4 get mul
  add
  T 10 get R 7 get mul
  add
  
  T 8 get R 2 get mul
  T 9 get R 5 get mul
  add
  T 10 get R 8 get mul
  add
  
  T 11 get
  
  % fourth row
  T 12 get R 0 get mul
  T 13 get R 3 get mul
  add
  T 14 get R 6 get mul
  add
  
  T 12 get R 1 get mul
  T 13 get R 4 get mul
  add
  T 14 get R 7 get mul
  add
  
  T 12 get R 2 get mul
  T 13 get R 5 get mul
  add
  T 14 get R 8 get mul
  add
  
  T 15 get
]
/T C 1 get def
% T = T^-1
% => R^-1 T^-1 
[
  R 0 get T 0 get mul
  R 3 get T 4 get mul add
  R 6 get T 8 get mul add
  
  R 0 get T 1 get mul
  R 3 get T 5 get mul add
  R 6 get T 9 get mul add
  
  R 0 get T 2 get mul
  R 3 get T 6 get mul add
  R 6 get T 10 get mul add
  
  R 0 get T 3 get mul
  R 3 get T 7 get mul add
  R 6 get T 11 get mul add
  
  % ------------------------
  
  R 1 get T 0 get mul
  R 4 get T 4 get mul add
  R 7 get T 8 get mul add
  
  R 1 get T 1 get mul
  R 4 get T 5 get mul add
  R 7 get T 9 get mul add
  
  R 1 get T 2 get mul
  R 4 get T 6 get mul add
  R 7 get T 10 get mul add
  
  R 1 get T 3 get mul
  R 4 get T 7 get mul add
  R 7 get T 11 get mul add
  
  % ------------------------
  
  R 2 get T 0 get mul
  R 5 get T 4 get mul add
  R 8 get T 8 get mul add
  
  R 2 get T 1 get mul
  R 5 get T 5 get mul add
  R 8 get T 9 get mul add
  
  R 2 get T 2 get mul
  R 5 get T 6 get mul add
  R 8 get T 10 get mul add
  
  R 2 get T 3 get mul
  R 5 get T 7 get mul add
  R 8 get T 11 get mul add

  T 12 get
  T 13 get
  T 14 get
  T 15 get  
]
  C 2 get
]
end
gset3d
} def


% f = [A B C D] P
% f = 0 is the *affine* reflection plane
% v = v* + v0 with v* on f = 0 and v0 in P-direction => v* - v0
% The map is Q => f(P)*Q - 2*f(Q)P
% It is of order two.
%
% f(P) I -
%
% 2A*P[0] 2B*P[0] 2C*P[0] 2D*P[0]
% 2A*P[1] 2B*P[1] 2C*P[1] 2D*P[1]
% 2A*P[2] 2B*P[2] 2C*P[2] 2D*P[2]
% 2A*P[3] 2B*P[3] 2C*P[3] 2D*P[3]
%
% Matrix = f(P) I - P f
% set s0 = (T row 0)*P
% T x this =
% f(P)T[0,0]-A*s -B*s -C*s -D*s

/affine-reflect3d { 4 dict begin
aload pop
/P3 exch def
/P2 exch def
/P1 exch def
/P0 exch def
aload pop
/D exch def
/C exch def
/B exch def
/A exch def

/fP 
  A P0 mul 
  B P1 mul add
  C P2 mul add
  D P3 mul add
def
/A A dup add def
/B B dup add def
/C C dup add def
/D D dup add def
[
/T cgfx3d 0 get def
[
  /s % = (T row 1)*P
  T 0 get P0 mul
  T 1 get P1 mul add
  T 2 get P2 mul add
  T 3 get P3 mul add
  def
  
  fP T 0 get mul
    A s mul sub
  fP T 1 get mul
    B s mul sub
  fP T 2 get mul
    C s mul sub
  fP T 3 get mul
    D s mul sub

  /s % = (T row 1)*P
  T 4 get P0 mul
  T 5 get P1 mul add
  T 6 get P2 mul add
  T 7 get P3 mul add
  def
  
  fP T 4 get mul
    A s mul sub
  fP T 5 get mul
    B s mul sub
  fP T 6 get mul
    C s mul sub
  fP T 7 get mul
    D s mul sub

  /s % = (T row 2)*P
  T 8 get P0 mul
  T 9 get P1 mul add
  T 10 get P2 mul add
  T 11 get P3 mul add
  def
  
  fP T 8 get mul
    A s mul sub
  fP T 9 get mul
    B s mul sub
  fP T 10 get mul
    C s mul sub
  fP T 11 get mul
    D s mul sub

  /s % = (T row 3)*P
  T 12 get P0 mul
  T 13 get P1 mul add
  T 14 get P2 mul add
  T 15 get P3 mul add
  def
  
  fP T 12 get mul
    A s mul sub
  fP T 13 get mul
    B s mul sub
  fP T 14 get mul
    C s mul sub
  fP T 15 get mul
    D s mul sub
]
/T cgfx3d 1 get def
/f0 		
  % f paired with columns of T
  T 0 get A mul
  T 4 get B mul add
  T 8 get C mul add
  T 12 get D mul add
def

/f1 		
  % f paired with columns of T
  T 1 get A mul
  T 5 get B mul add
  T 9 get C mul add
  T 13 get D mul add
def

/f2 		
  % f paired with columns of T
  T 2 get A mul
  T 6 get B mul add
  T 10 get C mul add
  T 14 get D mul add
def

/f3 		
  % f paired with columns of T
  T 3 get A mul
  T 7 get B mul add
  T 11 get C mul add
  T 15 get D mul add
def

[
  fP T 0 get mul
    f0 P0 get mul sub
  fP T 1 get mul
    f1 P0 get mul sub
  fP T 2 get mul
    f2 P0 get mul sub
  fP T 3 get mul
    f3 P0 get mul sub
  fP T 4 get mul
    f0 P1 get mul sub
  fP T 5 get mul
    f1 P1 get mul sub
  fP T 6 get mul
    f2 P1 get mul sub
  fP T 7 get mul
    f3 P1 get mul sub
  fP T 8 get mul
    f0 P2 get mul sub
  fP T 9 get mul
    f1 P2 get mul sub
  fP T 10 get mul
    f2 P2 get mul sub
  fP T 11 get mul
    f3 P2 get mul sub
  fP T 12 get mul
    f0 P3 get mul sub
  fP T 13 get mul
    f1 P3 get mul sub
  fP T 14 get mul
    f2 P3 get mul sub
  fP T 15 get mul
    f3 P3 get mul sub
]
  cgfx3d 2 get
] 
end
gset3d
} def

% 3x3 M 

/concat3d {
4 dict begin
/M exch def
[
/T cgfx3d 0 get def
  [
    T 0 get M 0 get mul
    T 1 get M 3 get mul add
    T 2 get M 6 get mul add

    T 0 get M 1 get mul
    T 1 get M 4 get mul add
    T 2 get M 7 get mul add
     
    T 0 get M 2 get mul
    T 1 get M 5 get mul add
    T 2 get M 8 get mul add
    
    T 3 get
     
    T 4 get M 0 get mul
    T 5 get M 3 get mul add
    T 6 get M 6 get mul add

    T 4 get M 1 get mul
    T 5 get M 4 get mul add
    T 6 get M 7 get mul add
     
    T 4 get M 2 get mul
    T 5 get M 5 get mul add
    T 6 get M 8 get mul add
    
    T 7 get
     
    T 8 get M 0 get mul
    T 9 get M 3 get mul add
    T 10 get M 6 get mul add

    T 8 get M 1 get mul
    T 9 get M 4 get mul add
    T 10 get M 7 get mul add
     
    T 8 get M 2 get mul
    T 9 get M 5 get mul add
    T 10 get M 8 get mul add
    
    T 11 get
     
    T 12 get M 0 get mul
    T 13 get M 3 get mul add
    T 14 get M 6 get mul add

    T 12 get M 1 get mul
    T 13 get M 4 get mul add
    T 14 get M 7 get mul add
     
    T 12 get M 2 get mul
    T 13 get M 5 get mul add
    T 14 get M 8 get mul add
    
    T 15 get
     
  ]
/T cgfx3d 1 get def
/M M 3x3-inverse def
  [
    M 0 get T 0 get mul
    M 1 get T 4 get mul add
    M 2 get T 8 get mul add
    
    M 0 get T 1 get mul
    M 1 get T 5 get mul add
    M 2 get T 9 get mul add
    
    M 0 get T 2 get mul
    M 1 get T 6 get mul add
    M 2 get T 10 get mul add
    
    M 0 get T 3 get mul
    M 1 get T 7 get mul add
    M 2 get T 11 get mul add
    
    % -----------------------------
    
    M 3 get T 0 get mul
    M 4 get T 4 get mul add
    M 5 get T 8 get mul add
    
    M 3 get T 1 get mul
    M 4 get T 5 get mul add
    M 5 get T 9 get mul add
    
    M 3 get T 2 get mul
    M 4 get T 6 get mul add
    M 5 get T 10 get mul add
    
    M 3 get T 3 get mul
    M 4 get T 7 get mul add
    M 5 get T 11 get mul add
    
    % -----------------------------
    
    M 6 get T 0 get mul
    M 7 get T 4 get mul add
    M 8 get T 8 get mul add
    
    M 6 get T 1 get mul
    M 7 get T 5 get mul add
    M 8 get T 9 get mul add
    
    M 6 get T 2 get mul
    M 7 get T 6 get mul add
    M 8 get T 10 get mul add
    
    M 6 get T 3 get mul
    M 7 get T 7 get mul add
    M 8 get T 11 get mul add
    
    % -----------------------------
    
    T 12 get
    T 13 get
    T 14 get
    T 15 get
  ]
  cgfx3d 2 get
]
end
gset3d
} def

%
% v => v - 2 <v, a> a
%
% Matrix = I - 2 a a
% a

/reflect3d { 4 dict begin
reflection-matrix3d 
concat3d
end } def

% [x y z w] [a00 a01 a02 a03 ... ]
% but the vector is a linear function
% so it is multiplying by transpose
% if T is the current ctm3d, the point P -> P T transform3d
% but the plane f=0 -> f T^{-1} dual-transform3d

/dual-transform3d { 4 dict begin
/v exch def
/T exch def
[
  v 0 get T 0 get mul
  v 1 get T 4 get mul add
  v 2 get T 8 get mul add
  v 3 get T 12 get mul add
  
  v 0 get T 1 get mul
  v 1 get T 5 get mul add
  v 2 get T 9 get mul add
  v 3 get T 13 get mul add
  
  v 0 get T 2 get mul
  v 1 get T 6 get mul add
  v 2 get T 10 get mul add
  v 3 get T 14 get mul add
  
  v 0 get T 3 get mul
  v 1 get T 7 get mul add
  v 2 get T 11 get mul add
  v 3 get T 15 get mul add
]
end } def

% 4d to 3d homogeneous
/project3d { 4 dict begin
/T exch def
/v exch def
[
  T 0 get v 0 get mul
  T 1 get v 1 get mul
  add 
  T 2 get v 2 get mul 
  add
  T 3 get v 3 get mul 
  add

  T 4 get v 0 get mul
  T 5 get v 1 get mul
  add 
  T 6 get v 2 get mul 
  add
  T 7 get v 3 get mul 
  add

  T 8 get v 0 get mul
  T 9 get v 1 get mul
  add 
  T 10 get v 2 get mul 
  add
  T 11 get v 3 get mul 
  add
] 
end } def

% [x y z w] [a00 a01 a02 a03 ... ]

/transform3d {
4 dict begin
/T exch def
/v exch def
[
T 0 get v 0 get mul
T 1 get v 1 get mul
add 
T 2 get v 2 get mul 
add
T 3 get v 3 get mul 
add

T 4 get v 0 get mul
T 5 get v 1 get mul
add 
T 6 get v 2 get mul 
add
T 7 get v 3 get mul 
add

T 8 get v 0 get mul
T 9 get v 1 get mul
add 
T 10 get v 2 get mul 
add
T 11 get v 3 get mul 
add

T 12 get v 0 get mul
T 13 get v 1 get mul
add 
T 14 get v 2 get mul 
add
T 15 get v 3 get mul 
add

] 
end
} def

% sx sy sz

/scale3d {
8 dict begin
/sz exch def
/sy exch def
/sx exch def
/T cgfx3d 0 get def
[
[
  T 0 get sx mul
  T 1 get sy mul
  T 2 get sz mul
  T 3 get 
  
  T 4 get sx mul
  T 5 get sy mul
  T 6 get sz mul
  T 7 get 
  
  T 8 get sx mul
  T 9 get sy mul
  T 10 get sz mul
  T 11 get 
 
  T 12 get sx mul
  T 13 get sy mul
  T 14 get sz mul
  T 15 get 
]
/T cgfx3d 1 get def
[
  T 0 get sx div
  T 1 get sx div
  T 2 get sx div
  T 3 get sx div
  
  T 4 get sy div
  T 5 get sy div
  T 6 get sy div
  T 7 get sy div
  
  T 8 get sz div
  T 9 get sz div
  T 10 get sz div
  T 11 get sz div
 
  T 12 get 
  T 13 get 
  T 14 get 
  T 15 get 
]
  cgfx3d 2 get
]
end
gset3d
} def

% [ <9> ] i

/row {
4 dict begin
/i exch def
/a exch def
a length 9 eq {
  /i i 3 mul def
  /n i 2 add def
} {
  /i i 4 mul def
  /n i 3 add def
} ifelse
[
  i 1 n {
    a exch get
  } for
]
end
} def

% projects from P onto f=Ax+By+Cz+D=0
% two parameters: f = [A B C D] and P
% The map is Q => f(P)*Q - f(Q)P
% It is idempotent.
%
% f(P) I -
%
% A*P[0] A*P[1] A*P[2] A*P[3]
% B*P[0] B*P[1] B*P[2] B*P[3]
% C*P[0] C*P[1] C*P[2] C*P[3]
% D*P[0] D*P[1] D*P[2] D*P[3]
%
% Matrix = f(P) I - P f
% set s0 = (T row 0)*P
% T x this =
% f(P)T[0,0]-A*s -B*s -C*s -D*s

/plane-project {
12 dict begin
aload pop
/P3 exch def
/P2 exch def
/P1 exch def
/P0 exch def
aload pop
/D exch def
/C exch def
/B exch def
/A exch def

/fP 
  A P0 mul 
  B P1 mul add
  C P2 mul add
  D P3 mul add
def
[
/T cgfx3d 0 get def
[
  /s % = (T row 0)*P
  	T 0 get P0 mul
  	T 1 get P1 mul add
  	T 2 get P2 mul add
  	T 3 get P3 mul add
  def
  
  fP T 0 get mul
    A s mul sub
  fP T 1 get mul
    B s mul sub
  fP T 2 get mul
    C s mul sub
  fP T 3 get mul
    D s mul sub


  /s % = (T row 1)*P
  T 4 get P0 mul
  T 5 get P1 mul add
  T 6 get P2 mul add
  T 7 get P3 mul add
  def
  
  fP T 4 get mul
    A s mul sub
  fP T 5 get mul
    B s mul sub
  fP T 6 get mul
    C s mul sub
  fP T 7 get mul
    D s mul sub


  /s % = (T row 2)*P
  T 8 get P0 mul
  T 9 get P1 mul add
  T 10 get P2 mul add
  T 11 get P3 mul add
  def
  
  fP T 8 get mul
    A s mul sub
  fP T 9 get mul
    B s mul sub
  fP T 10 get mul
    C s mul sub
  fP T 11 get mul
    D s mul sub

  /s % = (T row 3)*P
  T 12 get P0 mul
  T 13 get P1 mul add
  T 14 get P2 mul add
  T 15 get P3 mul add
  def
  
  fP T 12 get mul
    A s mul sub
  fP T 13 get mul
    B s mul sub
  fP T 14 get mul
    C s mul sub
  fP T 15 get mul
    D s mul sub
]
/T cgfx3d 1 get def
[
  /s T 0 get T 1 get add T 2 get add T 3 get add def
  s A mul
  s B mul
  s C mul
  s D mul
  /s T 4 get T 5 get add T 6 get add T 7 get add def
  s A mul
  s B mul
  s C mul
  s D mul
  /s T 8 get T 9 get add T 10 get add T 11 get add def
  s A mul
  s B mul
  s C mul
  s D mul
  /s T 12 get T 13 get add T 14 get add T 15 get add def
  s A mul
  s B mul
  s C mul
  s D mul
]
  cgfx3d 2 get
] 
end
gset3d
} def

% - Drawing commands in 3D --------------------------

% P displayed = [x y w z] => [X Y W] -> [X/W Y/W]

/render {
8 dict begin
aload pop
/v3 exch def
/v2 exch def
/v1 exch def
/v0 exch def
/T display-matrix def
/x
  T 0 get v0 mul 
  T 1 get v1 mul add
  T 2 get v2 mul add
  T 3 get v3 mul add
def
/y 
  T 4 get v0 mul 
  T 5 get v1 mul add
  T 6 get v2 mul add
  T 7 get v3 mul add
def
/w 
  T 8 get v0 mul 
  T 9 get v1 mul add
  T 10 get v2 mul add
  T 11 get v3 mul add
def
w 0 eq {
  (Perspective: division by zero!) ==
  quit
} if
x w div
y w div
end
} def

%  x y z -> x y
/transformto2d {
[ 4 1 roll 1 ] ctm3d transform3d render 
} def

/cpt3d 4 array def
/lm3d 4 array def

% cpt3d is a point in the "real" 3d world

% Should we build the current 3d path for reuse?

% x y z
/moveto3d {
1 [ 5 1 roll ] 
cgfx3d 0 get 
transform3d 
aload pop cpt3d astore 
render moveto
cpt3d aload pop lm3d astore pop
} def

% x y z

/lineto3d {
1 [ 5 1 roll ] 
cgfx3d 0 get 
transform3d 
aload pop cpt3d astore 
render lineto
} def

% x y z

/rmoveto3d {
0 [ 5 1 roll ] cgfx3d 0 get
transform3d 			% [dx dy dz 0]
dup 0 get cpt3d 0 get add	% [dx dy dz 0] x+dx
exch 
dup 1 get cpt3d 1 get add	% x+dx [dx dy dz dw] y+dy
exch
dup 2 get cpt3d 2 get add	% x+dx x+dy [dx dy dz dw] z+dz
exch				% x+dx y+dy z+dz [dx dy dz dw]
3 get cpt3d 3 get add		% x+dx x+dy z+dz w+dw
cpt3d astore
render moveto
cpt3d aload pop lm3d astore pop
} def

% x y z

/rlineto3d {
0 [ 5 1 roll ] cgfx3d 0 get
transform3d 		% [dx dy dz 0]
dup 0 get cpt3d 0 get add	% [dx dy dz 0] x+dx
exch 
dup 1 get cpt3d 1 get add	% x+dx [dx dy dz dw] y+dy
exch
dup 2 get cpt3d 2 get add	% x+dx x+dy [dx dy dz dw] z+dz
exch				% x+dx y+dy z+dz [dx dy dz dw]
3 get cpt3d 3 get add		% x+dx x+dy z+dz w+dw
cpt3d astore  
render lineto
} def

% x1 y1 z1 x2 y2 z2 x3 y3 z3 

/curveto3d { 16 dict begin
/z3 exch def
/y3 exch def
/x3 exch def
/z2 exch def
/y2 exch def
/x2 exch def
/z1 exch def
/y1 exch def
/x1 exch def
% F(t) 
/P0 cpt3d display-matrix project3d def
/P1 [x1 y1 z1 1] cgfx3d 0 get transform3d display-matrix project3d def
/w P0 2 get def
/c P1 2 get w div 1 sub def
/x0 P0 0 get w div def
/x1 P1 0 get w div def
/y0 P0 1 get w div def
/y1 P1 1 get w div def
x1 x0 c mul sub 
y1 y0 c mul sub 
[x3 y3 z3 1] cgfx3d 0 get transform3d aload pop cpt3d astore 
display-matrix project3d /P3 exch def
/P2 [x2 y2 z2 1] cgfx3d 0 get transform3d display-matrix project3d def
% We are assuming the display-matrix has images on { z = 0 }
/w P3 2 get def
/c P2 2 get w div 1 sub def
/x3 P3 0 get w div def
/x2 P2 0 get w div def
/y3 P3 1 get w div def
/y2 P2 1 get w div def
x2 x3 c mul sub 
y2 y3 c mul sub 
x3 y3
curveto
end } def

% - are the next two used? --------------------------------

% dP dQ Q

/dcurveto3d { 16 dict begin
/z3 exch def
/y3 exch def
/x3 exch def
/dz3 exch def
/dy3 exch def
/dx3 exch def
/dz0 exch def
/dy0 exch def
/dx0 exch def
/P0 cpt3d display-matrix project3d def
/dP0 [dx0 dy0 dz0 0] cgfx3d 0 get transform3d display-matrix project3d def
/w P0 3 get def 
% c = 1 - w'/w
/c 1 dP0 3 get w div sub def
  P0 0 get w div c mul dP0 0 get w div add
  P0 1 get w div c mul dP0 1 get w div add
[x3 y3 z3 1] cgfx3d 0 get transform3d aload pop cpt3d astore 
display-matrix project3d /P3 exch def
/dP3 [dx3 dy3 dz3 0] cgfx3d 0 get transform3d display-matrix project3d def
/w P3 3 get def
/c 1 dP3 3 get w div add def
  P3 0 get w div c mul dP3 0 get w div sub
  P3 1 get w div c mul dP3 1 get w div sub
  P3 0 get w div
  P3 1 get w div
curveto
end
} def

% dP dQ Q

/dcurveto { 8 dict begin
/y3 exch def
/x3 exch def
/dy3 exch def
/dx3 exch def
/dy0 exch def
/dx0 exch def
currentpoint dy0 add exch dx0 add exch
x3 dx3 sub y3 dy3 sub
x3 y3 
curveto
end } def

% - are the above two used? ----------------------------

/closepath3d {
closepath
lm3d aload pop cpt3d astore pop
} def

% - Conversion from 2d to 3D ---------------------------

/2d-path-convert {
[
  { % x y
    [ 3 1 roll 0 {moveto3d}]
  }
  { % x y
    [ 3 1 roll 0 {lineto3d}]
  }
  { % x1 y1 x2 y2 x3 y3
    [ 7 1 roll
    0 5 1 roll
    0 3 1 roll
    0 {curveto3d} ]
  }
  {
    [ {closepath3d} ]
  }
  pathforall
]
newpath
{
  aload pop exec
} forall
} def

% -----------------------------------------------

% For a simple currentpoint:

/mkpath3dDict 8 dict def

mkpath3dDict begin

/pathcount {
0 
{pop pop 
  pop 1 exit}
{pop pop 
  pop 1 exit}
{pop pop pop pop pop pop 
  pop 1 exit}
{ pop 1 exit}
pathforall
} def

/thereisacurrentpoint {
pathcount
0 gt
{true}
{false}
ifelse
} def

end

% ---------------------------------------------

% stack: t0 t1 N [parameters] /f 

/mkpath3d { load 
/f exch def
/pars exch def
12 dict begin
/N exch def
/t1 exch def
/t exch def

/h t1 t sub N div def
/h3 h 0.333333 mul def

pars t f aload pop
/velocity exch def
/position exch def
/p [ position aload pop 1 ] 
cgfx3d 0 get transform3d display-matrix project3d def
/v [ velocity aload pop 0 ] 
cgfx3d 0 get transform3d display-matrix project3d def

% p v = homogeneous position and velocity
% p/p[3] v/p[3] - (v[3]/p[3])(p/p[3]) = inhomogeneous ones
% = p/w v/w - c*p/w

/w p 3 get def
/c v 3 get w div def
thereisacurrentpoint {
  p 0 get w div p 1 get w div lineto
} {
  p 0 get w div p 1 get w div moveto
} ifelse

N {				% x y = currentpoint
  p 0 get 
    v 0 get 
    p 0 get c mul 
    sub 
    h3 mul 
  add 
  w div
  
  p 1 get 
    v 1 get 
    p 1 get c mul 
    sub 
    h3 mul 
  add
  w div

/t t h add def

pars t f aload pop
/velocity exch def
/position exch def
/p [ position aload pop 1 ] 
cgfx3d 0 get transform3d display-matrix project3d def
/v [ velocity aload pop 0 ] 
cgfx3d 0 get transform3d display-matrix project3d def
/w p 3 get def
/c v 3 get w div def

  p 0 get 
    v 0 get 
    p 0 get c mul 
    sub 
    h3 mul 
  sub 
  w div
  
  p 1 get 
    v 1 get 
    p 1 get c mul 
    sub 
    h3 mul 
  sub
  w div

p 0 get w div
p 1 get w div
curveto

} repeat
end % local dict
} def

% makes polygon out of control points

/mkcontrolpath3d { load
mkpath3dDict begin
1 dict begin
/f exch def
/pars exch def
/N exch def
/t1 exch def
/t exch def

/h t1 t sub N div def
/h3 h 0.333333 mul def

pars t f aload pop
/velocity exch def
/position exch def

position aload pop
thereisacurrentpoint {
	lineto3d
} {
	moveto3d
} ifelse

N {				% x y = currentpoint
% currentpoint pixel pop

position 0 get
velocity 0 get		% x dx/dt
h3 mul add
position 1 get
velocity 1 get		% y dy/dt
h3 mul add
position 2 get
velocity 2 get		% z dz/dt
h3 mul add

lineto3d

/t t h add def

pars t f aload pop
/velocity exch def
/position exch def

position 0 get
velocity 0 get 
h3 mul sub
position 1 get
velocity 1 get 
h3 mul sub
position 2 get
velocity 2 get 
h3 mul sub

lineto3d

position 0 get
position 1 get
position 2 get

lineto3d

} repeat
end % local dict
end % mkpath3d dict
} def

% -----------------------------------------------

% makes polygon from endpoints

/mkpolypath3d { load
/f exch def
/pars exch def
mkpath3dDict begin
1 dict begin
/N exch def
/t1 exch def
/t exch def

/h t1 t sub N div def
/h3 h 0.333333 mul def

pars t f aload pop
/velocity exch def
/position exch def

position aload pop
thereisacurrentpoint {
	lineto3d
} {
	moveto3d
} ifelse

N {				% x y = currentpoint
% currentpoint pixel pop

/t t h add def

pars t f aload pop
/velocity exch def
/position exch def

position 0 get
position 1 get
position 2 get
lineto3d

} repeat
end % local dict
end % mkpath3d dict
} def

% ---------------------------------------------

% length width

/plainarrow3d {
5 dict begin
/shaftwidth exch def
/arrowlength exch def
/headwidth shaftwidth 3 mul def
/headlength headwidth def
/shaftlength arrowlength shaftwidth 2.5 mul sub def
0 0 0 moveto3d
0 shaftwidth 0.5 mul 0 lineto3d
% shaftlength 0 0 rlineto3d
shaftlength shaftwidth 0.5 mul 0 lineto3d
arrowlength headlength sub headwidth 0.5 mul 0 lineto3d
arrowlength 0 0 lineto3d
arrowlength headlength sub headwidth -0.5 mul 0 lineto3d
shaftlength shaftwidth -0.5 mul 0 lineto3d
0 shaftwidth -0.5 mul 0 lineto3d
0 0 0 lineto3d
end
} def

% length width

/plainarrowtail3d {
5 dict begin
/shaftwidth exch def
/arrowlength exch def
0 0 0 moveto3d
0 shaftwidth 0.5 mul 0 lineto3d
arrowlength 0 0 rlineto3d
0 shaftwidth neg 0 rlineto3d
arrowlength neg 0 0 rlineto3d
0 0 0 lineto3d
end
} def

% --- shading ------------------------------------------------------------------

% all the shade input routines have as one argument a number between -1 and 1
% the result of a calculation of the dot-product of two unit vectors

% linear interpolation: s [a b] -> a + (b-a)*t

/lshade { % s [a b]
exch 1 add 2 div 	% t in [0 1]
% [a b] t
exch aload 0 get		% t a b a
4 1 roll 				% a t a b
sub mul sub			% a - t(a-b)
} def

%  # in [-1 1] & coefficient array [A B C D]: 
% A etc = control points, A = min, D = max
% 1 = facing towards, -1 = facing away from light
% x -> (x+1)/2 = 0.5(x+1) takes [-1, 1] -> [0, 1]
% evaluate by Horner's method

/shade {                             % t [array]
exch                                 % [array] t
1 add 0.5 mul 	                     % a t now in [0 1]
1 1 index sub                        % a t s=1-t
dup dup mul                          % a t s s^2
dup 2 index mul                      % a t s s^2 s^3
5 -1 roll aload pop                  % t s s^2 s^3 a0 a1 a2 a3=P0
7 index mul                          % t s s^2 s^3 a0 a1 a2 a3.t
exch                                 % t s s^2 s^3 a0 a1 a3.t a2
7 -1 roll                            % t s^2 s^3 a0 a1 a3.t a2 s
mul 3 mul add                        % t s^2 s^3 a0 a1 a3.t+3.a2.s=P1
5 index mul                          % t s^2 s^3 a0 a1 P1.t
exch                                 % t s^2 s^3 a0 P1.t a1
5 -1 roll                            % t s^3 a0 P1.t a1 s^2
mul 3 mul add                        % t s^3 a0 P1.t+3.a1.s^2=P2
4 -1 roll mul                        % s^3 a0 P2.t
3 1 roll mul add                     % P2.t + a0.s^3=P3
} def

% t y=[ y0 y1 ... yn ]
/bernstein { % t y 
  % constants y n t s=1-t
  % variables k C P
  dup length % t y n+1
  1 sub      % t y n
  3 -1 roll 1 % y n t 1
  1 index sub % y n t s
  % constants in place
  1           % y n t s k
  3 index 3 index mul % y n t s k C=nt
  5 index 0 get       % y n t s k C P=y0
  5 index {           % y n t s k C P
    % P -> s.P + C.y[k]
    % C -> C.t.(n-k)/(k+1) 
    % k -> k+1
    3 index mul       % y n t s k C P.s
    1 index           % y n t s k C P.s C
    7 index           % y n t s k C P.s C y 
    4 index get mul add  % y n t s k C P.s+C.y[k]=new P
    3 1 roll          % y n t s P* k C
    5 index           % y n t s P* k C n
    2 index sub mul   % y n t s P* k C.(n-k)
    1 index 1 add div % y n t s P* k C.(n-k)/(k+1)
    4 index mul       % y n t s P* k C*
    3 1 roll 1 add    % y n t s C* P* k*
    3 1 roll          % y n t s k* C* P*
  } repeat
  7 1 roll 6 { pop } repeat
} def

% shading: s in [-1 1] and y a Bernstein array B -> t -> B(t)
/bshade { exch 
1 add 2 div 
exch bernstein
} def

% ---------------------------------------------------------------------------------

% input: [pars] /fcn s0 s1 t0 t1 ns nt
% the fcn: [pars] s t -> f_{pars}(s, t)
% output: a polygonal surface of faces [ normal-fcn triangle ]

/mksurface {
16 dict begin
/nt exch def
/ns exch def
/t1 exch def
/t0 exch def
/s1 exch def
/s0 exch def
/ds s1 s0 sub ns div def
/dt t1 t0 sub nt div def
/f exch cvx def
/pars exch def
/P [
  /s s0 def
  ns 1 add {
    [
      /t t0 def
      nt 1 add {
        pars s t f
        /t t dt add def
      } repeat
    ]
    /s s ds add def
  } repeat
] def
% P[i][j] = f(s0 + i.ds, t0 + j.dt)
[
  0 1 ns 1 sub {
    /i exch def
    0 1 nt 1 sub {
      /j exch def
      % an array of triangles (i, j, 0) + (i, j, 1) 
      % dividing the rectangles in two
      /P00 P i get j get def
      /P10 P i 1 add get j get def
      /P01 P i get j 1 add get def
      /P11 P i 1 add get j 1 add get def
      % normal
      /Q P10 P00 vector-sub P01 P00 vector-sub cross-product def
      /r Q vector-length def
      r 0 ne {
        [
          [ Q aload pop Q P10 dot-product neg ]
          % array of pointers to three vertices
          [ P00 P10 P01 ]
        ] 
      } if
      /Q P01 P11 vector-sub P10 P11 vector-sub cross-product def
      /r Q vector-length def
      r 0 ne {
        [
          [ Q aload pop Q P01 dot-product neg ]
          % array of pointers to three vertices
          [ P10 P11 P01 ]
        ]
      } if
    } for
  } for
]
end
} def

% an array of vertices 
% traversed according to right hand rule
% output normalized

/normal-function {
2 dict begin
/a exch def
/n 
  a 1 get a 0 get vector-sub 
  a 2 get a 1 get vector-sub 
  cross-product 
def
/r n 0 get dup mul n 1 get dup mul add n 2 get dup mul add sqrt def
r 0 gt {
  /n [ n 0 get r div n 1 get r div n 2 get r div ] def
  [
    n aload pop
    a 0 get n dot-product neg
  ]
}{ [] } ifelse
end
} def

% --- light ------------------------------------------------

% should be part of the graphics environment

/set-light { /light-source exch def } def

/get-virtual-light {
  light-source cgfx3d 1 get transform3d
} def


 
%%EndProlog
gsave
%lanindL2 START  20000505
/lanind 1 def
/lantex [(G) (E) (S) (F) (I) (J) (M)] def
/showde {0 lanind eq {show} {pop} ifelse} bind def
/showen {1 lanind eq {show} {pop} ifelse} bind def
/showes {3 lanind eq {show} {pop} ifelse} bind def
/showfr {2 lanind eq {show} {pop} ifelse} bind def
/showit {4 lanind eq {show} {pop} ifelse} bind def
/showjp {5 lanind eq {show} {pop} ifelse} bind def
/showm  {6 lanind eq {show} {pop} ifelse} bind def
 
/lanindg where {pop /lanind1 lanindg def /lanind2 lanindg def}
               {/lanind1 1 def /lanind2 1 def} ifelse

/lanind lanind1 def
%lanind1 1 lanind2 {/lanind exch def %output showpage

%ps3d.inc

gsave

72 90 translate

250 -7 moveto
6 /Times-Roman FS
(DE421-7N) show

0 0 translate	
0 0 moveto
(XYZ) show 

0.01 MM 0.01 MM scale
15 setlinewidth
0 0  moveto 5400 0 rlineto 0 4000 rlineto -5400 0 rlineto
closepath stroke

grestore
gsave

72 90 translate

/fakt 2540 4 div def

%0.01 MM dup scale

09 09 scale

0.1 0.1 translate

/ymax 5000 def
/xmin 180 def

/fakt 2 def

1 0 0 setrgbcolor

[0 0 5 fakt mul 1 ] set-eye

[0 1 fakt mul 0] 30 rotate3d

0 setlinewidth
0 1 0 setrgbcolor
0 0 0 moveto3d 10 fakt mul 0 0 rlineto3d 
               0 06 fakt mul 0 rlineto3d
              -10 fakt mul 0 0 rlineto3d
closepath stroke

showpage

%%Trailer


%%EndDocument
EndEPSF grestore gsave

BeginEPSF
161 MM 08 MM sub 020 MM translate
  10 /Times-ISOL1 FS  53 MM 1 MM moveto ( ) show 1 1 scale  -77 -91 translate
%%BeginDocument: Bild 27

%line 489
%!PS-Adobe-3.0 EPSF-3.0 DE421-7N
%%BoundingBox: 70 90 226 206

%START PDFDE011.EPS
/pdfmark17 where {pop} {userdict /pdfmark17 /cleartomark load put} ifelse
/languagelevel where {pop languagelevel} {1} ifelse
2 lt { userdict (<<) cvn ([) cvn load put
       userdict (>>) cvn (]) cvn load put} if
[ /Title (PostScript pictures: farbe.li.tu-berlin.de/DE42/DE42.HTM)
  /Author (compare K. Richter "Computergrafik ...": ISBN 3-8007-1775-1)
  /Subject (goto: http://farbe.li.tu-berlin.de http://130.149.60.45/~farbmetrik)
  /Keywords (image reproduction, colour devices)
  /Creator (klaus.richter@mac.com)
  /CreationDate (D:2018060112000)
  /ModDate (D:20180601112000)
/DOCINFO pdfmark17
[ /View [ /Fit ]
/DOCVIEW pdfmark17
%END  PDFDE011

/BeginEPSF {% def               % Prepare for EPS file
/b4_Inc_state save def          % Save state for cleanup
/dict_count countdictstack def
/op_count count 1 sub def       % Count objects on op stack
userdict begin                  % Make userdict current dict
/showpage {} def
0 setgray 0 setlinecap
1 setlinewidth 0 setlinejoin
10 setmiterlimit [] 0 setdash newpath
/languagelevel where            % If level not equal to 1 then
 {pop languagelevel where       % If level not equal to 1 then
 1 ne
 {false setstrokeadjust false setoverprint
 } if
} if
} bind def

/EndEPSF  {% def              % End for EPS file
 count op_count sub {pop} repeat
 countdictstack dict_count sub {end} repeat	% Clean up dict stack
 b4_Inc_state restore
} bind def


% !AUSTAUSCH Times-Roman -> Times-Roman-ISOLatin1=Times-I
 
/Times-Roman findfont dup length dict  begin
{1 index /FID ne {def} {pop pop} ifelse }forall
/Encoding ISOLatin1Encoding def
currentdict end
/Times-ISOL1 exch definefont pop
 
/Times-Italic findfont dup length dict  begin
{1 index /FID ne {def} {pop pop} ifelse }forall
/Encoding ISOLatin1Encoding def
currentdict end
/TimesI-ISOL1 exch definefont pop
 
/Times-Bold findfont dup length dict  begin
{1 index /FID ne {def} {pop pop} ifelse }forall
/Encoding ISOLatin1Encoding def
currentdict end
/TimesB-ISOL1 exch definefont pop
 
/Times-BoldItalic findfont dup length dict  begin
{1 index /FID ne {def} {pop pop} ifelse }forall
/Encoding ISOLatin1Encoding def
currentdict end
/TimesBI-ISOL1 exch definefont pop
 
/FS {findfont exch scalefont setfont} bind def
/MM {72 25.4 div mul} def /str {8 string } bind def
 
/TK {250 16.67 div /Times-ISOL1 FS} bind def
/TM {300 16.67 div /Times-ISOL1 FS} bind def
/TG {350 16.67 div /Times-ISOL1 FS} bind def
 
/TIK {250 16.67 div /TimesI-ISOL1 FS} bind def
/TIM {300 16.67 div /TimesI-ISOL1 FS} bind def
/TIG {350 16.67 div /TimesI-ISOL1 FS} bind def
 
/TBK {250 16.67 div /TimesB-ISOL1 FS} bind def
/TBM {300 16.67 div /TimesB-ISOL1 FS} bind def
/TBG {350 16.67 div /TimesB-ISOL1 FS} bind def
 
/TBIK {250 16.67 div /TimesBI-ISOL1 FS} bind def
/TBIM {300 16.67 div /TimesBI-ISOL1 FS} bind def
/TBIG {350 16.67 div /TimesBI-ISOL1 FS} bind def

/RK {250 16.67 div /Times-Roman FS} bind def
/RM {300 16.67 div /Times-Roman FS} bind def
/RG {350 16.67 div /Times-Roman FS} bind def

/RIK {250 16.67 div /Times-Italic FS} bind def
/RIM {300 16.67 div /Times-Italic FS} bind def
/RIG {350 16.67 div /Times-Italic FS} bind def

/RBK {250 16.67 div /Times-Bold FS} bind def
/RBM {300 16.67 div /Times-Bold FS} bind def
/RBG {350 16.67 div /Times-Bold FS} bind def

/RBIK {250 16.67 div /Times-BoldItalic FS} bind def
/RBIM {300 16.67 div /Times-BoldItalic FS} bind def
/RBIG {350 16.67 div /Times-BoldItalic FS} bind def

/tolvfcol    %Farbkreis-Reihenfolge
[ (000) (F00) (FF0) (0F0) (0FF) (00F) (F0F) (FFF)
  (777) (700) (770) (070) (077) (007) (707) (F07) %15=R
  (333) (F77) (FF7) (7F7) (7FF) (77F) (F7F) (07F) %23=B
  (BBB) (F70) (7F0) (0F7) (07F) (70F) (F07) (0F7) %31=G
] def
 
/tcmyfcol    %Farbkreis-Reihenfolge
[ (FFF) (0FF) (00F) (F0F) (F00) (FF0) (0F0) (000)
  (888) (8FF) (88F) (F8F) (F88) (FF8) (8F8) (0F8) %15=R
  (CCC) (088) (008) (808) (800) (880) (080) (F80) %23=B
  (444) (08F) (80F) (F08) (F80) (8F0) (0F8) (F08) %31=G
] def
 
/tcmykfcol   %Farbkreis-Reihenfolge
[ (000F) (0FF0) (00F0) (F0F0) (F000) (FF00) (0F00) (0000)
  (0008) (0FF8) (00F8) (F0F8) (F008) (FF08) (0F08) (0F80) %15=R
  (000C) (0880) (0080) (8080) (8000) (8800) (0800) (F800) %23=B
  (0004) (0F80) (80F0) (F080) (F800) (8F00) (0F80) (F080) %31=G
] def
 
/tolvfcols    %Farbkreis-Reihenfolge
[ (000*) (F00*) (FF0*) (0F0*) (0FF*) (00F*) (F0F*) (FFF*)
  (777*) (700*) (770*) (070*) (077*) (007*) (707*) (F07*) %15=R
  (333*) (F77*) (FF7*) (7F7*) (7FF*) (77F*) (F7F*) (07F*) %23=B
  (BBB*) (F70*) (7F0*) (0F7*) (07F*) (70F*) (F07*) (0F7*) %31=G
] def
 
/tcmyfcols    %Farbkreis-Reihenfolge
[ (FFF*) (0FF*) (00F*) (F0F*) (F00*) (FF0*) (0F0*) (000*)
  (888*) (8FF*) (88F*) (F8F*) (F88*) (FF8*) (8F8*) (0F8*) %15=R
  (CCC*) (088*) (008*) (808*) (800*) (880*) (080*) (F80*) %23=B
  (444*) (08F*) (80F*) (F08*) (F80*) (8F0*) (0F8*) (F08*) %31=G
] def
 
/tcmykfcols   %Farbkreis-Reihenfolge
[ (000F*) (0FF0*) (00F0*) (F0F0*) (F000*) (FF00*) (0F00*) (0000*)
  (0008*) (0FF8*) (00F8*) (F0F8*) (F008*) (FF08*) (0F08*) (0F80*) %15=R
  (000C*) (0880*) (0080*) (8080*) (8000*) (8800*) (0800*) (F800*) %23=B
  (0004*) (0F80*) (80F0*) (F080*) (F800*) (8F00*) (0F80*) (F080*) %31=G
] def
 
/fcolors     %CMYN 32 Testfarben Nr. 0 bis 31; Farbkreis-Reihenfolge
[{0.0 0.0 0.0 1.0}  {0.0 1.0 1.0 0.0}  {0.0 0.0 1.0 0.0}  {1.0 0.0 1.0 0.0}
 {1.0 0.0 0.0 0.0}  {1.0 1.0 0.0 0.0}  {0.0 1.0 0.0 0.0}  {0.0 0.0 0.0 0.0}
 
 {0.0 0.0 0.0 0.5}  {0.0 1.0 1.0 0.5}  {0.0 0.0 1.0 0.5}  {1.0 0.0 1.0 0.5}
 {1.0 0.0 0.0 0.5}  {1.0 1.0 0.0 0.5}  {0.0 1.0 0.0 0.5}  {0.0 1.0 0.5 0.0}
 
 {0.0 0.0 0.0 0.75} {0.0 0.5 0.5 0.0}  {0.0 0.0 0.5 0.0}  {0.5 0.0 0.5 0.0}
 {0.5 0.0 0.0 0.0}  {0.5 0.5 0.0 0.0}  {0.0 0.5 0.0 0.0}  {1.0 0.5 0.0 0.0}
 
 {0.0 0.0 0.0 0.25} {0.0 0.5 1.0 0.0}  {0.5 0.0 1.0 0.0}  {1.0 0.0 0.5 0.0}
 {1.0 0.5 0.0 0.0}  {0.5 1.0 0.0 0.0}  {0.0 1.0 0.5 0.0}  {1.0 0.0 0.5 0.0}
] def
 
/fak 0.5 def
 
/Far     %Farbkreis-Reihenfolge
 [ 0  1  2  3  4  5  6  7
   8  9 10 11 12 13 14 15 %R
  16 17 18 19 20 21 22 23 %B
  24 25 26 27 28 29 30 31 %G
 ] def
 
/cFar     %Kompensativ-Farbkreis-Reihenfolge
 [ 8  4  5  6  1  2  3  0
   0 20 21 22 17 18 19 31 %G
  24 12 13 14  9 10 11  2 %J
  16 28 29 30 25 26 27 15 %R
 ] def
 
/Btx    %Farbkreis- -> %Btx-Reihenfolge
 [ 0  1  3  2  5  6  4  7
   8  9 11 10 13 14 12 15  %R
  16 17 19 18 21 22 20 23  %B
  24 25 26 27 28 29 30 31  %G
 ] def
 
/cBtx    %Farbkreis- -> %Kompensativ-Btx-Reihenfolge
 [ 7  4  6  5  2  3  1  0
   8 20 22 21 18 19 17 31 %G
  24 12 14 13 10 11  9  2 %J
  16 25 26 27 28 29 30 15 %R
 ] def
 
/rec %x, y width heigth
  {/heigth exch def /width exch def
   moveto width 0 rlineto 0 heigth rlineto width neg 0 rlineto
   closepath } bind def
 
/colrecfi %x y width heigth c m y k
  {setrgbcolor rec fill} bind def
 
/colrecst %x y width heigth c m y k
  {setrgbcolor rec stroke} bind def
 
/tzo {0.0 1.0 1.0 0.0} bind def %Reproduktionsfarben
/tzl {1.0 0.0 1.0 0.0} bind def
/tzv {1.0 1.0 0.0 0.0} bind def
/tzc {1.0 0.0 0.0 0.0} bind def
/tzm {0.0 1.0 0.0 0.0} bind def
/tzy {0.0 0.0 1.0 0.0} bind def
 
/tzn {0.0 0.0 0.0 1.00} bind def %Graureihe
/tzd {0.0 0.0 0.0 0.75} bind def
/tzz {0.0 0.0 0.0 0.50} bind def
/tzh {0.0 0.0 0.0 0.25} bind def
/tzw {0.0 0.0 0.0 0.00} bind def
 
/tzr {0.0 1.0 0.5 0.0} bind def %Elementarfarben
/tzg {1.0 0.0 0.5 0.0} bind def
/tzb {1.0 0.5 0.0 0.0} bind def
/tzj {0.0 0.0 1.0 0.0} bind def
 
/tzrz {0.0 1.0 0.5 0.5} bind def %Elementarfarben vergraut
/tzgz {1.0 0.0 0.5 0.5} bind def
/tzbz {1.0 0.5 0.0 0.5} bind def
/tzjz {0.0 0.0 1.0 0.5} bind def
 
/tfo {tzo setcmykcolor} bind def
/tfl {tzl setcmykcolor} bind def
/tfv {tzv setcmykcolor} bind def
/tfc {tzc setcmykcolor} bind def
/tfm {tzm setcmykcolor} bind def
/tfy {tzy setcmykcolor} bind def
 
/tfn {tzn setcmykcolor} bind def
/tfd {tzd setcmykcolor} bind def
/tfz {tzz setcmykcolor} bind def
/tfh {tzh setcmykcolor} bind def
/tfw {tzw setcmykcolor} bind def
 
/tfr {tzr setcmykcolor} bind def
/tfg {tzg setcmykcolor} bind def
/tfb {tzb setcmykcolor} bind def
/tfj {tzj setcmykcolor} bind def
 
/tfrz {tzrz setcmykcolor} bind def
/tfgz {tzgz setcmykcolor} bind def
/tfbz {tzbz setcmykcolor} bind def
/tfjz {tzjz setcmykcolor} bind def

%
% - %This is ps3d.inc ----------------------------------

% - Copyright Bill Casselman
% - Original version 1.0 November, 1998
% - Version 1.1 December, 1999
% -      Took out aliases for moveto etc.
% -      Made display-matrix a 3 x 4 homogeneous matrix, added it to the 3d gstack 
% -      Allowed arbitrary eye location, 3d -> 2d projects onto z = 0 plane
% -      Although fancy stuff not yet implemented
% -      Made ght a variable
% -      Version 1.1 is *not* backwards compatible!
% - Version 1.2 August, 2002
% -      Thorough interpretation of matrices as arrays of columns and point vectors as rows
% -      And some speed up
% -      Similar rewriting of matrix.inc
% -      Again, backwards incompatible!
% - Version 1.3 August, 2003
% -      Rewriting shade for efficiency
% - Thanks to Jim Blinn's book `A trip down the graphics pipeline'
% - for several suggestions that (I hope) made this code cleaner 
% - by suggesting how useful homogeneous coordinates were.
% November 10, 2003: added fancier shading
% December 17, 2003: changed arguments for mkpath procedures

% ------------------------------------------------


% - Inserting matrix.inc ----------------------

% - Vector calculations (usually good in any number of dimensions) ----------

% - matrices in this package are usually laid out in a single array by columns ---
% - i.e. [ column1 column 2 ... ]
% - but sometimes as a double array [ [ column1] [column2] ... ] 

% <double array>  /to-single-array
% <single-array> /to-double-array
% <n> /identity
% <u> <v> /dot-product
% <u> <c> /vector-scale
% <u> <v> /vector-add
% <u> <v> /vectorssub
% <u> /vector-length
% <u> <v> cross-product
% <axis> <angle> /rotation-matrix3d
% v [a b c] /euclidean-reflect
% [a b c] /reflection-matrix-3d
% <m> <n> /matrix-mul
% <m> <v> /matrix-vector
% <v> <m> /vector-matrix 
% <m> /transpose
% <m> 3x3-det
% <m> /3x3-inverse
% <u> <v> /angle-between
% <x> /acos
% <x> <a> <a^v> /skew-reflect
% <a> <a^v> /skew-reflection-matrix

% - matrices in this package are laid out in a single array by columns ---------

% a double array: cannot be empty - just lays out all items
/to-single-array {
% [ [. . . ][ . . . ] ] => [ . . . . . . ]
[
	exch { % successive rows
		aload pop
	} forall
]
} def

% ----------------------------------------------

% [ ... ] a square matrix made into an array of columns
/to-double-array { 4 dict begin
/A exch def
/N A length sqrt round cvi def
/i 0 def
[
N {
	[
	N {
		A i get
		/i i 1 add def
	} repeat
	]
} repeat
]
end } def

% ----------------------------------------

% returns the nxn identity matrix as single array
/identity { 1 dict begin
/n exch def
[
  n 1 sub {
    1 
    n {
      0
	} repeat 
  } repeat
  1
]
end } def

% --- vector algebra --------------------------------

% u v -> u.v
/dot-product { 1 dict begin
/v exch def
0 0	     		% u s i
3 2 roll { 		% s i u[i]
  v 			% s i u[i] v
  2 index get mul 	% s i u[i]*v[i]
  3 2 roll		% i u[i]*v[i] s
  add exch 1 add	% s i
} forall
pop
end } def

% v c -> c.v
/vector-scale { 1 dict begin
/c exch def
[ exch
{ 		% s i u[i]
  c mul			% s i u[i] v 
} forall
]
end } def

% u v -> u+v
/vector-add { 1 dict begin
/v exch def
[ exch
0 	     	% u i
exch { 		% i u[i]
  v 		% i u[i] v
  2 index get add 	% i u[i]+v[i]
  exch 1 add	% i
} forall
pop
]
end } def

% u v -> u-v
/vector-sub { 1 dict begin
/v exch def
[ exch
0 	     	% u i
exch { 		% i u[i]
  v 		% i u[i] v
  2 index get sub 	% i u[i]+v[i]
  exch 1 add	% i
} forall
pop
]
end } def

% [x y z ... ] -> r
% watch out for overflow

/vector-length { 1 dict begin
dup
% find maximum entry
/max 0 def
{ % max 
  abs dup max gt {
    % if abs gt max
    /max exch def
  } {
    pop
  } ifelse
} forall

max 0 ne {
  0 exch 
  {  % 0 v[i]
    max div dup mul add
  } forall
  sqrt
  max mul
} {
  pop 0
} ifelse
end } def

% v -> v/|v|
/normalized { 1 dict begin
dup 			% v v
vector-length /r exch def
[ exch
  {
    r div
  } forall
]
end } def

% u v
% u0 u1 u2
% v0 v1 v2
% -> u x v
/cross-product {
2 dict begin
/v exch def
/u exch def
[
  u 1 get v 2 get mul
  v 1 get u 2 get mul sub

  v 0 get u 2 get mul
  u 0 get v 2 get mul sub

  u 0 get v 1 get mul
  v 0 get u 1 get mul sub
]
end
} def

% --------------------------------------------------------------

% axis A -> a matrix
/rotation-matrix3d {
8 dict begin
dup 
cos /c exch def
sin /s exch def
/a exch def
/r a vector-length def
/a0 a 0 get r div def
/a1	a 1 get r div def
/a2 a 2 get r div def

[

% e = [1 0 0] etc.
% e0 = (e.a)a, e# = e - e0, e* = a x e = a x e0 + a x e# = a x e#
/x a0 def
/e0 [a0 x mul
     a1 x mul 
     a2 x mul] def
/e# [1 e0 0 get sub 
     e0 1 get neg 
     e0 2 get neg] def
% [a0 a1 a2]
% [ 1  0  0]
/e* [0 
     a2 
     a1 neg
    ] def
e# 0 get c mul e* 0 get s mul add e0 0 get add 
e# 1 get c mul e* 1 get s mul add e0 1 get add 
e# 2 get c mul e* 2 get s mul add e0 2 get add 

/x a1 def
/e0 [a0 x mul a1 x mul a2 x mul] def
/e# [e0 0 get neg 
     1 e0 1 get sub 
     e0 2 get neg] def
% [a0 a1 a2]
% [ 0  1  0]
/e* [a2 neg 
     0
     a0
    ] def
e# 0 get c mul e* 0 get s mul add e0 0 get add 
e# 1 get c mul e* 1 get s mul add e0 1 get add 
e# 2 get c mul e* 2 get s mul add e0 2 get add 

/x a2 def
/e0 [a0 x mul a1 x mul a2 x mul] def
/e# [e0 0 get neg
     e0 1 get neg
     1 e0 2 get sub] def
% [a0 a1 a2]
% [ 0  0  1]
/e* [a1 
     a0 neg
     0
    ] def
e# 0 get c mul e* 0 get s mul add e0 0 get add 
e# 1 get c mul e* 1 get s mul add e0 1 get add 
e# 2 get c mul e* 2 get s mul add e0 2 get add 

]
% [ r0 r1 r2 r3 r4 r5 r6 r7 r8 ] -> [r0 r3 r6 r1 r4 r7 r2 r5 r8 ]
/r exch def
[
	r 0 get 
	r 3 get
	r 6 get
	r 1 get
	r 4 get
	r 7 get
	r 2 get
	r 5 get
	r 8 get
] 
end
} def

% v a -> v - 2(a.v)/(a.a) a
/euclidean-reflect { 16 dict begin
/a exch def
/v exch def
/N a length def
/d a v dot-product a dup dot-product div 2 mul def
[
  0
  v {
    % i v[i]
    exch dup 1 add					% v[i] i i+1
	3 1 roll							  % i+1 v[i] i
    a exch get d mul 				% i+1 v[i] a[i]*d
	sub										% i+1 v[i]-d*a[i]
	exch									% rv[i] i+1
  } forall
  pop
]
end } def

% f = [A B C] => linear 3d transformation: f not necessarily normalized
% Rv = v - 2 <f', v> f'

/reflection-matrix3d {
3 dict begin
aload pop
/C exch def
/B exch def
/A exch def
/r [ A B C ] vector-length def
/A A r div def
/B B r div def
/C C r div def
[
  1 A A mul dup add sub   B A mul dup add neg   C A mul dup add neg
    A B mul dup add neg 1 B B mul dup add sub   C B mul dup add neg
    A C mul dup add neg   B C mul dup add neg 1 C C mul dup add sub
]
end
} def

/matrix-mul {
8 dict begin
/B exch def
/A exch def
/n A length sqrt round cvi def
%  0    1  ...
%  n  n+1 ...
% 2n 2n+1 ...
[
  0
  n {
    % i = initial index of the column on the stack = 0, n, 2n ... 
    % after all previous entries
    dup n add exch 0	
    n {
	  % i+n i j on stack
      % j = initial index of the row
	  2 copy 1 add % i+n i j i j+1
	  4 2 roll	% i+n i j+1 i j
	  /ell exch def
      /k exch def
	  % i+n i j+1 
      0
      n {
		% i+n i j+1 s
        A ell get B k get mul add
        /k k 1 add def
        /ell ell n add def
      } repeat
	  4 1 roll
	  % s i+n i j+1
   	} repeat
    pop pop	% s i+n
  } repeat
  pop
]
end
} def

% A v: A = [ column 1, column 2, ... , column n ]
/matrix-vector {
8 dict begin
/v exch def
/r v length def
/A exch def
/c A length r idiv def
[
  0 1 c 1 sub {
	/i exch def
    % i = initial index of the row
    0 0
    r {
		% s j on stack
		dup 1 add	% s j j+1
		3 1 roll		% j+1 s j
      	v exch get A i get mul add	% j+1 s
		exch
   	  	/i i r add def
    } repeat
	% s r
	pop
  } for
]
end
} def

% v A: A = [ column1 column2 ... ]
/vector-matrix {
8 dict begin
/A exch def
/v exch def
/c v length def
/r A length c idiv def
[
  /i 0 def 
  r {
    % i = initial index of the row
    /j 0 def
    0
    c {
      A i get v j get mul add
      /j j 1 add def
   	  /i i 1 add def
    } repeat
  } repeat
]
end
} def

% a square matrix m x m
% [i, j] = n*i + j

/transpose {
4 dict begin
/M exch def
/n M length sqrt round cvi def
[
/k 0 def
n {
  /i k def
  n { 
    M i get
    /i i n add def
  } repeat
  /k k 1 add def
} repeat
]

end
} def

/3x3-det {
1 dict begin
/m exch def

m 0 get 
m 4 get mul
m 8 get mul

m 1 get 
m 5 get mul
m 6 get mul
add

m 2 get 
m 3 get mul
m 7 get mul
add

m 2 get 
m 4 get mul
m 6 get mul
sub

m 1 get 
m 3 get mul
m 8 get mul
sub

m 0 get 
m 5 get mul
m 7 get mul
sub

end
} def

/3x3-inverse {
2 dict begin
/m exch def
/d m 3x3-det def
[
   m 4 get m 8 get mul 
   m 5 get m 7 get mul sub
   d div
   
   m 2 get m 7 get mul 
   m 1 get m 8 get mul sub
   d div
   
   m 1 get m 5 get mul 
   m 4 get m 2 get mul sub
   d div

   m 5 get m 6 get mul 
   m 3 get m 8 get mul sub
   d div
   
   m 0 get m 8 get mul 
   m 2 get m 6 get mul sub
   d div
   
   m 2 get m 3 get mul 
   m 0 get m 5 get mul sub
   d div

   m 3 get m 7 get mul 
   m 6 get m 4 get mul sub
   d div
   
   m 1 get m 6 get mul 
   m 0 get m 7 get mul sub
   d div
   
   m 0 get m 4 get mul 
   m 1 get m 3 get mul sub
   d div
]
end
} def

/acos {
dup dup % x x x
mul 1 sub neg % x 1-x^2
sqrt exch atan
} def

% u v

/angle-between {
dup vector-length
% u v |v|
3 1 roll
% |v| u v
1 index 
% |v| u v u
dot-product
% |v| u u.v
exch vector-length
% |v| u.v |u|
div exch div
acos
} def

% x a av -> x - <a, x> av

/skew-reflect { 4 dict begin
/av exch def
/a exch def
/x exch def
/d x a dot-product def
[
	0 1 x length 1 sub {
		/i exch def
		x i get av i get d mul sub
	} for
]
end } def

% a av -> matrix
/skew-reflection-matrix { 8 dict begin
/av exch def
/a exch def
/n a length def
[
	0 1 n 1 sub {
		/i exch def
		[ n {0} repeat ] dup i 1 put
		% e[i] 
		a av skew-reflect
	} for
]
to-single-array
transpose
end } def

% - closing matrix.inc ------------------------

% - Defining PostScript commands' equivalents ----------

% - Coordinates in three dimensions -------------------

% There are three steps to drawing something in 3D:
% 1.  Converting from user 3d coords to default 3d coords
% 2.  Projecting onto (x, y)-plane
% 3.  Drawing the image on that plane
% These are more or less independent.  
% The last step is completely controlled by the usual PS stuff.
% The first and second are handled by 3d stuff here.

% - Initialize and manipulate the 3d gstack -----------

/gmax 64 def
/ght 0 def

% gstack = [[t0 d0 dm0] [t1 d2 dm1] [t2 d2 dm2] ... [t(gmax-1) d(gmax-1) dm(gmax-1)] ]

% the ctm is t[ght]
% the dual ctm is at d[ght]
% they are 4 x 4
% display-matrix = 3 x 4

/gstack3d gmax array def

% start with orthogonal projection to positive z-axis
gstack3d 0 [
  [ 1 0 0 0 
    0 1 0 0
    0 0 1 0
    0 0 0 1] 
  [ 1 0 0 0 
    0 1 0 0
    0 0 1 0
    0 0 0 1]
  [ 1 0 0 0
    0 1 0 0
    0 0 0 1]
] put

/gsave3d {
  /ctm gstack3d ght get def
  /ght ght 1 add def 
  ght gmax eq {
    (3d graphics stack overflow!) ==
    quit
  } if
  gstack3d 
    ght
    [ ctm 0 get ctm 1 get ctm 2 get ] 
  put
} def

/grestore3d {
  /ght ght 1 sub def
  ght 0 lt {
     (3d graphics stack underflow!) ==
     quit
  } if
} def

% n - restores to depth n

/gpop3d {
/ght exch def
} def

% [T T* dm]: sets cgfx3d = [T T* dm]

/gset3d {
gstack3d  		% [T T* d] g 
ght			    % [T T* d] g ght
3 2 roll 		    % g ght [T T* d]
put 
} def

% => [T T* dm]

/cgfx3d {
  gstack3d ght get
} def

/ctm3d {
  gstack3d ght get 0 get
} def

/cim3d {
  gstack3d ght get 1 get
} def

/cdm3d {
  gstack3d ght get 2 get
} def

% cpt3d isthe last 3d point drawn to

/currentpoint3d {
cpt3d
cgfx3d 1 get transform3d
aload pop     % x y z w 
pop			
} def

% - Sets up projection into 2D -------------------
		
% O = [x y z w] 
% sets display-matrix perspective onto z = 0 plane

/display-matrix {
  cgfx3d 2 get
} def

% [z0 0 -x0 0
%  0 z0 -y0 0
%  0 0 -w0 z0]
% (transposed)
% gives perspective onto point in z=0 plane
% from [x0 y0 z0 w0]

/set-eye {
4 dict begin
aload pop
/w0 exch def
/z0 exch def
/y0 exch def
/x0 exch def
gstack3d ght get
2 
[ z0 0 x0 neg 0 
  0 z0 y0 neg 0
  0 0 w0 neg z0]
put
end
} def

/get-eye { 1 dict begin
/d display-matrix def
[d 2 get neg d 6 get neg d 0 get d 10 get neg]
end } def

/get-virtual-eye {
get-eye cgfx3d 1 get transform3d
} def

% - backwards compatibility -----------------------------

/origin { get-eye } def
/eye { get-eye } def
/set-display { set-eye } def

% - Manipulate the current transformation matrix -----

% x y z

/translate3d {
8 dict begin
/z exch def
/y exch def
/x exch def
/ctm cgfx3d def
/T ctm 0 get def
[
[
  T 0 get 
  T 1 get 
  T 2 get 
  T 0 get x  mul
  T 1 get y  mul
  add
  T 2 get z  mul
  add
  T 3 get 
  add
  
  T 4 get 
  T 5 get 
  T 6 get
  T 4 get x  mul
  T 5 get y  mul
  add
  T 6 get z  mul
  add
  T 7 get 
  add
   
  T 8 get 
  T 9 get 
  T 10 get
  T 8 get x  mul
  T 9 get y  mul
  add
  T 10 get z  mul
  add
  T 11 get 
  add
   
  T 12 get 
  T 13 get 
  T 14 get
  T 12 get x  mul
  T 13 get y  mul
  add
  T 14 get z  mul
  add
  T 15 get 
  add
]
/T ctm 1 get def
[
  T 0 get T 12 get x mul sub 
  T 1 get T 13 get x mul sub 
  T 2 get T 14 get x mul sub 
  T 3 get T 15 get x mul sub 

  T 4 get T 12 get y mul sub 
  T 5 get T 13 get y mul sub 
  T 6 get T 14 get y mul sub 
  T 7 get T 15 get y mul sub 

  T 8 get T 12 get z mul sub 
  T 9 get T 13 get z mul sub 
  T 10 get T 14 get z mul sub 
  T 11 get T 15 get z mul sub 

  T 12 get
  T 13 get
  T 14 get
  T 15 get
]
  ctm 2 get
]
end
gset3d
} def

% ------------------------------------------------------

% axis A

/rotate3d { 4 dict begin
rotation-matrix3d
/R exch def
/C cgfx3d def
/T C 0 get def
[
[
  % first row
  T 0 get R 0 get mul
  T 1 get R 3 get mul
  add
  T 2 get R 6 get mul
  add
  
  T 0 get R 1 get mul
  T 1 get R 4 get mul
  add
  T 2 get R 7 get mul
  add
  
  T 0 get R 2 get mul
  T 1 get R 5 get mul
  add
  T 2 get R 8 get mul
  add
  
  T 3 get
  
  % second row
  T 4 get R 0 get mul
  T 5 get R 3 get mul
  add
  T 6 get R 6 get mul
  add
  
  T 4 get R 1 get mul
  T 5 get R 4 get mul
  add
  T 6 get R 7 get mul
  add
  
  T 4 get R 2 get mul
  T 5 get R 5 get mul
  add
  T 6 get R 8 get mul
  add
  
  T 7 get
  
  % third row
  T 8 get R 0 get mul
  T 9 get R 3 get mul
  add
  T 10 get R 6 get mul
  add
  
  T 8 get R 1 get mul
  T 9 get R 4 get mul
  add
  T 10 get R 7 get mul
  add
  
  T 8 get R 2 get mul
  T 9 get R 5 get mul
  add
  T 10 get R 8 get mul
  add
  
  T 11 get
  
  % fourth row
  T 12 get R 0 get mul
  T 13 get R 3 get mul
  add
  T 14 get R 6 get mul
  add
  
  T 12 get R 1 get mul
  T 13 get R 4 get mul
  add
  T 14 get R 7 get mul
  add
  
  T 12 get R 2 get mul
  T 13 get R 5 get mul
  add
  T 14 get R 8 get mul
  add
  
  T 15 get
]
/T C 1 get def
% T = T^-1
% => R^-1 T^-1 
[
  R 0 get T 0 get mul
  R 3 get T 4 get mul add
  R 6 get T 8 get mul add
  
  R 0 get T 1 get mul
  R 3 get T 5 get mul add
  R 6 get T 9 get mul add
  
  R 0 get T 2 get mul
  R 3 get T 6 get mul add
  R 6 get T 10 get mul add
  
  R 0 get T 3 get mul
  R 3 get T 7 get mul add
  R 6 get T 11 get mul add
  
  % ------------------------
  
  R 1 get T 0 get mul
  R 4 get T 4 get mul add
  R 7 get T 8 get mul add
  
  R 1 get T 1 get mul
  R 4 get T 5 get mul add
  R 7 get T 9 get mul add
  
  R 1 get T 2 get mul
  R 4 get T 6 get mul add
  R 7 get T 10 get mul add
  
  R 1 get T 3 get mul
  R 4 get T 7 get mul add
  R 7 get T 11 get mul add
  
  % ------------------------
  
  R 2 get T 0 get mul
  R 5 get T 4 get mul add
  R 8 get T 8 get mul add
  
  R 2 get T 1 get mul
  R 5 get T 5 get mul add
  R 8 get T 9 get mul add
  
  R 2 get T 2 get mul
  R 5 get T 6 get mul add
  R 8 get T 10 get mul add
  
  R 2 get T 3 get mul
  R 5 get T 7 get mul add
  R 8 get T 11 get mul add

  T 12 get
  T 13 get
  T 14 get
  T 15 get  
]
  C 2 get
]
end
gset3d
} def


% f = [A B C D] P
% f = 0 is the *affine* reflection plane
% v = v* + v0 with v* on f = 0 and v0 in P-direction => v* - v0
% The map is Q => f(P)*Q - 2*f(Q)P
% It is of order two.
%
% f(P) I -
%
% 2A*P[0] 2B*P[0] 2C*P[0] 2D*P[0]
% 2A*P[1] 2B*P[1] 2C*P[1] 2D*P[1]
% 2A*P[2] 2B*P[2] 2C*P[2] 2D*P[2]
% 2A*P[3] 2B*P[3] 2C*P[3] 2D*P[3]
%
% Matrix = f(P) I - P f
% set s0 = (T row 0)*P
% T x this =
% f(P)T[0,0]-A*s -B*s -C*s -D*s

/affine-reflect3d { 4 dict begin
aload pop
/P3 exch def
/P2 exch def
/P1 exch def
/P0 exch def
aload pop
/D exch def
/C exch def
/B exch def
/A exch def

/fP 
  A P0 mul 
  B P1 mul add
  C P2 mul add
  D P3 mul add
def
/A A dup add def
/B B dup add def
/C C dup add def
/D D dup add def
[
/T cgfx3d 0 get def
[
  /s % = (T row 1)*P
  T 0 get P0 mul
  T 1 get P1 mul add
  T 2 get P2 mul add
  T 3 get P3 mul add
  def
  
  fP T 0 get mul
    A s mul sub
  fP T 1 get mul
    B s mul sub
  fP T 2 get mul
    C s mul sub
  fP T 3 get mul
    D s mul sub

  /s % = (T row 1)*P
  T 4 get P0 mul
  T 5 get P1 mul add
  T 6 get P2 mul add
  T 7 get P3 mul add
  def
  
  fP T 4 get mul
    A s mul sub
  fP T 5 get mul
    B s mul sub
  fP T 6 get mul
    C s mul sub
  fP T 7 get mul
    D s mul sub

  /s % = (T row 2)*P
  T 8 get P0 mul
  T 9 get P1 mul add
  T 10 get P2 mul add
  T 11 get P3 mul add
  def
  
  fP T 8 get mul
    A s mul sub
  fP T 9 get mul
    B s mul sub
  fP T 10 get mul
    C s mul sub
  fP T 11 get mul
    D s mul sub

  /s % = (T row 3)*P
  T 12 get P0 mul
  T 13 get P1 mul add
  T 14 get P2 mul add
  T 15 get P3 mul add
  def
  
  fP T 12 get mul
    A s mul sub
  fP T 13 get mul
    B s mul sub
  fP T 14 get mul
    C s mul sub
  fP T 15 get mul
    D s mul sub
]
/T cgfx3d 1 get def
/f0 		
  % f paired with columns of T
  T 0 get A mul
  T 4 get B mul add
  T 8 get C mul add
  T 12 get D mul add
def

/f1 		
  % f paired with columns of T
  T 1 get A mul
  T 5 get B mul add
  T 9 get C mul add
  T 13 get D mul add
def

/f2 		
  % f paired with columns of T
  T 2 get A mul
  T 6 get B mul add
  T 10 get C mul add
  T 14 get D mul add
def

/f3 		
  % f paired with columns of T
  T 3 get A mul
  T 7 get B mul add
  T 11 get C mul add
  T 15 get D mul add
def

[
  fP T 0 get mul
    f0 P0 get mul sub
  fP T 1 get mul
    f1 P0 get mul sub
  fP T 2 get mul
    f2 P0 get mul sub
  fP T 3 get mul
    f3 P0 get mul sub
  fP T 4 get mul
    f0 P1 get mul sub
  fP T 5 get mul
    f1 P1 get mul sub
  fP T 6 get mul
    f2 P1 get mul sub
  fP T 7 get mul
    f3 P1 get mul sub
  fP T 8 get mul
    f0 P2 get mul sub
  fP T 9 get mul
    f1 P2 get mul sub
  fP T 10 get mul
    f2 P2 get mul sub
  fP T 11 get mul
    f3 P2 get mul sub
  fP T 12 get mul
    f0 P3 get mul sub
  fP T 13 get mul
    f1 P3 get mul sub
  fP T 14 get mul
    f2 P3 get mul sub
  fP T 15 get mul
    f3 P3 get mul sub
]
  cgfx3d 2 get
] 
end
gset3d
} def

% 3x3 M 

/concat3d {
4 dict begin
/M exch def
[
/T cgfx3d 0 get def
  [
    T 0 get M 0 get mul
    T 1 get M 3 get mul add
    T 2 get M 6 get mul add

    T 0 get M 1 get mul
    T 1 get M 4 get mul add
    T 2 get M 7 get mul add
     
    T 0 get M 2 get mul
    T 1 get M 5 get mul add
    T 2 get M 8 get mul add
    
    T 3 get
     
    T 4 get M 0 get mul
    T 5 get M 3 get mul add
    T 6 get M 6 get mul add

    T 4 get M 1 get mul
    T 5 get M 4 get mul add
    T 6 get M 7 get mul add
     
    T 4 get M 2 get mul
    T 5 get M 5 get mul add
    T 6 get M 8 get mul add
    
    T 7 get
     
    T 8 get M 0 get mul
    T 9 get M 3 get mul add
    T 10 get M 6 get mul add

    T 8 get M 1 get mul
    T 9 get M 4 get mul add
    T 10 get M 7 get mul add
     
    T 8 get M 2 get mul
    T 9 get M 5 get mul add
    T 10 get M 8 get mul add
    
    T 11 get
     
    T 12 get M 0 get mul
    T 13 get M 3 get mul add
    T 14 get M 6 get mul add

    T 12 get M 1 get mul
    T 13 get M 4 get mul add
    T 14 get M 7 get mul add
     
    T 12 get M 2 get mul
    T 13 get M 5 get mul add
    T 14 get M 8 get mul add
    
    T 15 get
     
  ]
/T cgfx3d 1 get def
/M M 3x3-inverse def
  [
    M 0 get T 0 get mul
    M 1 get T 4 get mul add
    M 2 get T 8 get mul add
    
    M 0 get T 1 get mul
    M 1 get T 5 get mul add
    M 2 get T 9 get mul add
    
    M 0 get T 2 get mul
    M 1 get T 6 get mul add
    M 2 get T 10 get mul add
    
    M 0 get T 3 get mul
    M 1 get T 7 get mul add
    M 2 get T 11 get mul add
    
    % -----------------------------
    
    M 3 get T 0 get mul
    M 4 get T 4 get mul add
    M 5 get T 8 get mul add
    
    M 3 get T 1 get mul
    M 4 get T 5 get mul add
    M 5 get T 9 get mul add
    
    M 3 get T 2 get mul
    M 4 get T 6 get mul add
    M 5 get T 10 get mul add
    
    M 3 get T 3 get mul
    M 4 get T 7 get mul add
    M 5 get T 11 get mul add
    
    % -----------------------------
    
    M 6 get T 0 get mul
    M 7 get T 4 get mul add
    M 8 get T 8 get mul add
    
    M 6 get T 1 get mul
    M 7 get T 5 get mul add
    M 8 get T 9 get mul add
    
    M 6 get T 2 get mul
    M 7 get T 6 get mul add
    M 8 get T 10 get mul add
    
    M 6 get T 3 get mul
    M 7 get T 7 get mul add
    M 8 get T 11 get mul add
    
    % -----------------------------
    
    T 12 get
    T 13 get
    T 14 get
    T 15 get
  ]
  cgfx3d 2 get
]
end
gset3d
} def

%
% v => v - 2 <v, a> a
%
% Matrix = I - 2 a a
% a

/reflect3d { 4 dict begin
reflection-matrix3d 
concat3d
end } def

% [x y z w] [a00 a01 a02 a03 ... ]
% but the vector is a linear function
% so it is multiplying by transpose
% if T is the current ctm3d, the point P -> P T transform3d
% but the plane f=0 -> f T^{-1} dual-transform3d

/dual-transform3d { 4 dict begin
/v exch def
/T exch def
[
  v 0 get T 0 get mul
  v 1 get T 4 get mul add
  v 2 get T 8 get mul add
  v 3 get T 12 get mul add
  
  v 0 get T 1 get mul
  v 1 get T 5 get mul add
  v 2 get T 9 get mul add
  v 3 get T 13 get mul add
  
  v 0 get T 2 get mul
  v 1 get T 6 get mul add
  v 2 get T 10 get mul add
  v 3 get T 14 get mul add
  
  v 0 get T 3 get mul
  v 1 get T 7 get mul add
  v 2 get T 11 get mul add
  v 3 get T 15 get mul add
]
end } def

% 4d to 3d homogeneous
/project3d { 4 dict begin
/T exch def
/v exch def
[
  T 0 get v 0 get mul
  T 1 get v 1 get mul
  add 
  T 2 get v 2 get mul 
  add
  T 3 get v 3 get mul 
  add

  T 4 get v 0 get mul
  T 5 get v 1 get mul
  add 
  T 6 get v 2 get mul 
  add
  T 7 get v 3 get mul 
  add

  T 8 get v 0 get mul
  T 9 get v 1 get mul
  add 
  T 10 get v 2 get mul 
  add
  T 11 get v 3 get mul 
  add
] 
end } def

% [x y z w] [a00 a01 a02 a03 ... ]

/transform3d {
4 dict begin
/T exch def
/v exch def
[
T 0 get v 0 get mul
T 1 get v 1 get mul
add 
T 2 get v 2 get mul 
add
T 3 get v 3 get mul 
add

T 4 get v 0 get mul
T 5 get v 1 get mul
add 
T 6 get v 2 get mul 
add
T 7 get v 3 get mul 
add

T 8 get v 0 get mul
T 9 get v 1 get mul
add 
T 10 get v 2 get mul 
add
T 11 get v 3 get mul 
add

T 12 get v 0 get mul
T 13 get v 1 get mul
add 
T 14 get v 2 get mul 
add
T 15 get v 3 get mul 
add

] 
end
} def

% sx sy sz

/scale3d {
8 dict begin
/sz exch def
/sy exch def
/sx exch def
/T cgfx3d 0 get def
[
[
  T 0 get sx mul
  T 1 get sy mul
  T 2 get sz mul
  T 3 get 
  
  T 4 get sx mul
  T 5 get sy mul
  T 6 get sz mul
  T 7 get 
  
  T 8 get sx mul
  T 9 get sy mul
  T 10 get sz mul
  T 11 get 
 
  T 12 get sx mul
  T 13 get sy mul
  T 14 get sz mul
  T 15 get 
]
/T cgfx3d 1 get def
[
  T 0 get sx div
  T 1 get sx div
  T 2 get sx div
  T 3 get sx div
  
  T 4 get sy div
  T 5 get sy div
  T 6 get sy div
  T 7 get sy div
  
  T 8 get sz div
  T 9 get sz div
  T 10 get sz div
  T 11 get sz div
 
  T 12 get 
  T 13 get 
  T 14 get 
  T 15 get 
]
  cgfx3d 2 get
]
end
gset3d
} def

% [ <9> ] i

/row {
4 dict begin
/i exch def
/a exch def
a length 9 eq {
  /i i 3 mul def
  /n i 2 add def
} {
  /i i 4 mul def
  /n i 3 add def
} ifelse
[
  i 1 n {
    a exch get
  } for
]
end
} def

% projects from P onto f=Ax+By+Cz+D=0
% two parameters: f = [A B C D] and P
% The map is Q => f(P)*Q - f(Q)P
% It is idempotent.
%
% f(P) I -
%
% A*P[0] A*P[1] A*P[2] A*P[3]
% B*P[0] B*P[1] B*P[2] B*P[3]
% C*P[0] C*P[1] C*P[2] C*P[3]
% D*P[0] D*P[1] D*P[2] D*P[3]
%
% Matrix = f(P) I - P f
% set s0 = (T row 0)*P
% T x this =
% f(P)T[0,0]-A*s -B*s -C*s -D*s

/plane-project {
12 dict begin
aload pop
/P3 exch def
/P2 exch def
/P1 exch def
/P0 exch def
aload pop
/D exch def
/C exch def
/B exch def
/A exch def

/fP 
  A P0 mul 
  B P1 mul add
  C P2 mul add
  D P3 mul add
def
[
/T cgfx3d 0 get def
[
  /s % = (T row 0)*P
  	T 0 get P0 mul
  	T 1 get P1 mul add
  	T 2 get P2 mul add
  	T 3 get P3 mul add
  def
  
  fP T 0 get mul
    A s mul sub
  fP T 1 get mul
    B s mul sub
  fP T 2 get mul
    C s mul sub
  fP T 3 get mul
    D s mul sub


  /s % = (T row 1)*P
  T 4 get P0 mul
  T 5 get P1 mul add
  T 6 get P2 mul add
  T 7 get P3 mul add
  def
  
  fP T 4 get mul
    A s mul sub
  fP T 5 get mul
    B s mul sub
  fP T 6 get mul
    C s mul sub
  fP T 7 get mul
    D s mul sub


  /s % = (T row 2)*P
  T 8 get P0 mul
  T 9 get P1 mul add
  T 10 get P2 mul add
  T 11 get P3 mul add
  def
  
  fP T 8 get mul
    A s mul sub
  fP T 9 get mul
    B s mul sub
  fP T 10 get mul
    C s mul sub
  fP T 11 get mul
    D s mul sub

  /s % = (T row 3)*P
  T 12 get P0 mul
  T 13 get P1 mul add
  T 14 get P2 mul add
  T 15 get P3 mul add
  def
  
  fP T 12 get mul
    A s mul sub
  fP T 13 get mul
    B s mul sub
  fP T 14 get mul
    C s mul sub
  fP T 15 get mul
    D s mul sub
]
/T cgfx3d 1 get def
[
  /s T 0 get T 1 get add T 2 get add T 3 get add def
  s A mul
  s B mul
  s C mul
  s D mul
  /s T 4 get T 5 get add T 6 get add T 7 get add def
  s A mul
  s B mul
  s C mul
  s D mul
  /s T 8 get T 9 get add T 10 get add T 11 get add def
  s A mul
  s B mul
  s C mul
  s D mul
  /s T 12 get T 13 get add T 14 get add T 15 get add def
  s A mul
  s B mul
  s C mul
  s D mul
]
  cgfx3d 2 get
] 
end
gset3d
} def

% - Drawing commands in 3D --------------------------

% P displayed = [x y w z] => [X Y W] -> [X/W Y/W]

/render {
8 dict begin
aload pop
/v3 exch def
/v2 exch def
/v1 exch def
/v0 exch def
/T display-matrix def
/x
  T 0 get v0 mul 
  T 1 get v1 mul add
  T 2 get v2 mul add
  T 3 get v3 mul add
def
/y 
  T 4 get v0 mul 
  T 5 get v1 mul add
  T 6 get v2 mul add
  T 7 get v3 mul add
def
/w 
  T 8 get v0 mul 
  T 9 get v1 mul add
  T 10 get v2 mul add
  T 11 get v3 mul add
def
w 0 eq {
  (Perspective: division by zero!) ==
  quit
} if
x w div
y w div
end
} def

%  x y z -> x y
/transformto2d {
[ 4 1 roll 1 ] ctm3d transform3d render 
} def

/cpt3d 4 array def
/lm3d 4 array def

% cpt3d is a point in the "real" 3d world

% Should we build the current 3d path for reuse?

% x y z
/moveto3d {
1 [ 5 1 roll ] 
cgfx3d 0 get 
transform3d 
aload pop cpt3d astore 
render moveto
cpt3d aload pop lm3d astore pop
} def

% x y z

/lineto3d {
1 [ 5 1 roll ] 
cgfx3d 0 get 
transform3d 
aload pop cpt3d astore 
render lineto
} def

% x y z

/rmoveto3d {
0 [ 5 1 roll ] cgfx3d 0 get
transform3d 			% [dx dy dz 0]
dup 0 get cpt3d 0 get add	% [dx dy dz 0] x+dx
exch 
dup 1 get cpt3d 1 get add	% x+dx [dx dy dz dw] y+dy
exch
dup 2 get cpt3d 2 get add	% x+dx x+dy [dx dy dz dw] z+dz
exch				% x+dx y+dy z+dz [dx dy dz dw]
3 get cpt3d 3 get add		% x+dx x+dy z+dz w+dw
cpt3d astore
render moveto
cpt3d aload pop lm3d astore pop
} def

% x y z

/rlineto3d {
0 [ 5 1 roll ] cgfx3d 0 get
transform3d 		% [dx dy dz 0]
dup 0 get cpt3d 0 get add	% [dx dy dz 0] x+dx
exch 
dup 1 get cpt3d 1 get add	% x+dx [dx dy dz dw] y+dy
exch
dup 2 get cpt3d 2 get add	% x+dx x+dy [dx dy dz dw] z+dz
exch				% x+dx y+dy z+dz [dx dy dz dw]
3 get cpt3d 3 get add		% x+dx x+dy z+dz w+dw
cpt3d astore  
render lineto
} def

% x1 y1 z1 x2 y2 z2 x3 y3 z3 

/curveto3d { 16 dict begin
/z3 exch def
/y3 exch def
/x3 exch def
/z2 exch def
/y2 exch def
/x2 exch def
/z1 exch def
/y1 exch def
/x1 exch def
% F(t) 
/P0 cpt3d display-matrix project3d def
/P1 [x1 y1 z1 1] cgfx3d 0 get transform3d display-matrix project3d def
/w P0 2 get def
/c P1 2 get w div 1 sub def
/x0 P0 0 get w div def
/x1 P1 0 get w div def
/y0 P0 1 get w div def
/y1 P1 1 get w div def
x1 x0 c mul sub 
y1 y0 c mul sub 
[x3 y3 z3 1] cgfx3d 0 get transform3d aload pop cpt3d astore 
display-matrix project3d /P3 exch def
/P2 [x2 y2 z2 1] cgfx3d 0 get transform3d display-matrix project3d def
% We are assuming the display-matrix has images on { z = 0 }
/w P3 2 get def
/c P2 2 get w div 1 sub def
/x3 P3 0 get w div def
/x2 P2 0 get w div def
/y3 P3 1 get w div def
/y2 P2 1 get w div def
x2 x3 c mul sub 
y2 y3 c mul sub 
x3 y3
curveto
end } def

% - are the next two used? --------------------------------

% dP dQ Q

/dcurveto3d { 16 dict begin
/z3 exch def
/y3 exch def
/x3 exch def
/dz3 exch def
/dy3 exch def
/dx3 exch def
/dz0 exch def
/dy0 exch def
/dx0 exch def
/P0 cpt3d display-matrix project3d def
/dP0 [dx0 dy0 dz0 0] cgfx3d 0 get transform3d display-matrix project3d def
/w P0 3 get def 
% c = 1 - w'/w
/c 1 dP0 3 get w div sub def
  P0 0 get w div c mul dP0 0 get w div add
  P0 1 get w div c mul dP0 1 get w div add
[x3 y3 z3 1] cgfx3d 0 get transform3d aload pop cpt3d astore 
display-matrix project3d /P3 exch def
/dP3 [dx3 dy3 dz3 0] cgfx3d 0 get transform3d display-matrix project3d def
/w P3 3 get def
/c 1 dP3 3 get w div add def
  P3 0 get w div c mul dP3 0 get w div sub
  P3 1 get w div c mul dP3 1 get w div sub
  P3 0 get w div
  P3 1 get w div
curveto
end
} def

% dP dQ Q

/dcurveto { 8 dict begin
/y3 exch def
/x3 exch def
/dy3 exch def
/dx3 exch def
/dy0 exch def
/dx0 exch def
currentpoint dy0 add exch dx0 add exch
x3 dx3 sub y3 dy3 sub
x3 y3 
curveto
end } def

% - are the above two used? ----------------------------

/closepath3d {
closepath
lm3d aload pop cpt3d astore pop
} def

% - Conversion from 2d to 3D ---------------------------

/2d-path-convert {
[
  { % x y
    [ 3 1 roll 0 {moveto3d}]
  }
  { % x y
    [ 3 1 roll 0 {lineto3d}]
  }
  { % x1 y1 x2 y2 x3 y3
    [ 7 1 roll
    0 5 1 roll
    0 3 1 roll
    0 {curveto3d} ]
  }
  {
    [ {closepath3d} ]
  }
  pathforall
]
newpath
{
  aload pop exec
} forall
} def

% -----------------------------------------------

% For a simple currentpoint:

/mkpath3dDict 8 dict def

mkpath3dDict begin

/pathcount {
0 
{pop pop 
  pop 1 exit}
{pop pop 
  pop 1 exit}
{pop pop pop pop pop pop 
  pop 1 exit}
{ pop 1 exit}
pathforall
} def

/thereisacurrentpoint {
pathcount
0 gt
{true}
{false}
ifelse
} def

end

% ---------------------------------------------

% stack: t0 t1 N [parameters] /f 

/mkpath3d { load 
/f exch def
/pars exch def
12 dict begin
/N exch def
/t1 exch def
/t exch def

/h t1 t sub N div def
/h3 h 0.333333 mul def

pars t f aload pop
/velocity exch def
/position exch def
/p [ position aload pop 1 ] 
cgfx3d 0 get transform3d display-matrix project3d def
/v [ velocity aload pop 0 ] 
cgfx3d 0 get transform3d display-matrix project3d def

% p v = homogeneous position and velocity
% p/p[3] v/p[3] - (v[3]/p[3])(p/p[3]) = inhomogeneous ones
% = p/w v/w - c*p/w

/w p 3 get def
/c v 3 get w div def
thereisacurrentpoint {
  p 0 get w div p 1 get w div lineto
} {
  p 0 get w div p 1 get w div moveto
} ifelse

N {				% x y = currentpoint
  p 0 get 
    v 0 get 
    p 0 get c mul 
    sub 
    h3 mul 
  add 
  w div
  
  p 1 get 
    v 1 get 
    p 1 get c mul 
    sub 
    h3 mul 
  add
  w div

/t t h add def

pars t f aload pop
/velocity exch def
/position exch def
/p [ position aload pop 1 ] 
cgfx3d 0 get transform3d display-matrix project3d def
/v [ velocity aload pop 0 ] 
cgfx3d 0 get transform3d display-matrix project3d def
/w p 3 get def
/c v 3 get w div def

  p 0 get 
    v 0 get 
    p 0 get c mul 
    sub 
    h3 mul 
  sub 
  w div
  
  p 1 get 
    v 1 get 
    p 1 get c mul 
    sub 
    h3 mul 
  sub
  w div

p 0 get w div
p 1 get w div
curveto

} repeat
end % local dict
} def

% makes polygon out of control points

/mkcontrolpath3d { load
mkpath3dDict begin
1 dict begin
/f exch def
/pars exch def
/N exch def
/t1 exch def
/t exch def

/h t1 t sub N div def
/h3 h 0.333333 mul def

pars t f aload pop
/velocity exch def
/position exch def

position aload pop
thereisacurrentpoint {
	lineto3d
} {
	moveto3d
} ifelse

N {				% x y = currentpoint
% currentpoint pixel pop

position 0 get
velocity 0 get		% x dx/dt
h3 mul add
position 1 get
velocity 1 get		% y dy/dt
h3 mul add
position 2 get
velocity 2 get		% z dz/dt
h3 mul add

lineto3d

/t t h add def

pars t f aload pop
/velocity exch def
/position exch def

position 0 get
velocity 0 get 
h3 mul sub
position 1 get
velocity 1 get 
h3 mul sub
position 2 get
velocity 2 get 
h3 mul sub

lineto3d

position 0 get
position 1 get
position 2 get

lineto3d

} repeat
end % local dict
end % mkpath3d dict
} def

% -----------------------------------------------

% makes polygon from endpoints

/mkpolypath3d { load
/f exch def
/pars exch def
mkpath3dDict begin
1 dict begin
/N exch def
/t1 exch def
/t exch def

/h t1 t sub N div def
/h3 h 0.333333 mul def

pars t f aload pop
/velocity exch def
/position exch def

position aload pop
thereisacurrentpoint {
	lineto3d
} {
	moveto3d
} ifelse

N {				% x y = currentpoint
% currentpoint pixel pop

/t t h add def

pars t f aload pop
/velocity exch def
/position exch def

position 0 get
position 1 get
position 2 get
lineto3d

} repeat
end % local dict
end % mkpath3d dict
} def

% ---------------------------------------------

% length width

/plainarrow3d {
5 dict begin
/shaftwidth exch def
/arrowlength exch def
/headwidth shaftwidth 3 mul def
/headlength headwidth def
/shaftlength arrowlength shaftwidth 2.5 mul sub def
0 0 0 moveto3d
0 shaftwidth 0.5 mul 0 lineto3d
% shaftlength 0 0 rlineto3d
shaftlength shaftwidth 0.5 mul 0 lineto3d
arrowlength headlength sub headwidth 0.5 mul 0 lineto3d
arrowlength 0 0 lineto3d
arrowlength headlength sub headwidth -0.5 mul 0 lineto3d
shaftlength shaftwidth -0.5 mul 0 lineto3d
0 shaftwidth -0.5 mul 0 lineto3d
0 0 0 lineto3d
end
} def

% length width

/plainarrowtail3d {
5 dict begin
/shaftwidth exch def
/arrowlength exch def
0 0 0 moveto3d
0 shaftwidth 0.5 mul 0 lineto3d
arrowlength 0 0 rlineto3d
0 shaftwidth neg 0 rlineto3d
arrowlength neg 0 0 rlineto3d
0 0 0 lineto3d
end
} def

% --- shading ------------------------------------------------------------------

% all the shade input routines have as one argument a number between -1 and 1
% the result of a calculation of the dot-product of two unit vectors

% linear interpolation: s [a b] -> a + (b-a)*t

/lshade { % s [a b]
exch 1 add 2 div 	% t in [0 1]
% [a b] t
exch aload 0 get		% t a b a
4 1 roll 				% a t a b
sub mul sub			% a - t(a-b)
} def

%  # in [-1 1] & coefficient array [A B C D]: 
% A etc = control points, A = min, D = max
% 1 = facing towards, -1 = facing away from light
% x -> (x+1)/2 = 0.5(x+1) takes [-1, 1] -> [0, 1]
% evaluate by Horner's method

/shade {                             % t [array]
exch                                 % [array] t
1 add 0.5 mul 	                     % a t now in [0 1]
1 1 index sub                        % a t s=1-t
dup dup mul                          % a t s s^2
dup 2 index mul                      % a t s s^2 s^3
5 -1 roll aload pop                  % t s s^2 s^3 a0 a1 a2 a3=P0
7 index mul                          % t s s^2 s^3 a0 a1 a2 a3.t
exch                                 % t s s^2 s^3 a0 a1 a3.t a2
7 -1 roll                            % t s^2 s^3 a0 a1 a3.t a2 s
mul 3 mul add                        % t s^2 s^3 a0 a1 a3.t+3.a2.s=P1
5 index mul                          % t s^2 s^3 a0 a1 P1.t
exch                                 % t s^2 s^3 a0 P1.t a1
5 -1 roll                            % t s^3 a0 P1.t a1 s^2
mul 3 mul add                        % t s^3 a0 P1.t+3.a1.s^2=P2
4 -1 roll mul                        % s^3 a0 P2.t
3 1 roll mul add                     % P2.t + a0.s^3=P3
} def

% t y=[ y0 y1 ... yn ]
/bernstein { % t y 
  % constants y n t s=1-t
  % variables k C P
  dup length % t y n+1
  1 sub      % t y n
  3 -1 roll 1 % y n t 1
  1 index sub % y n t s
  % constants in place
  1           % y n t s k
  3 index 3 index mul % y n t s k C=nt
  5 index 0 get       % y n t s k C P=y0
  5 index {           % y n t s k C P
    % P -> s.P + C.y[k]
    % C -> C.t.(n-k)/(k+1) 
    % k -> k+1
    3 index mul       % y n t s k C P.s
    1 index           % y n t s k C P.s C
    7 index           % y n t s k C P.s C y 
    4 index get mul add  % y n t s k C P.s+C.y[k]=new P
    3 1 roll          % y n t s P* k C
    5 index           % y n t s P* k C n
    2 index sub mul   % y n t s P* k C.(n-k)
    1 index 1 add div % y n t s P* k C.(n-k)/(k+1)
    4 index mul       % y n t s P* k C*
    3 1 roll 1 add    % y n t s C* P* k*
    3 1 roll          % y n t s k* C* P*
  } repeat
  7 1 roll 6 { pop } repeat
} def

% shading: s in [-1 1] and y a Bernstein array B -> t -> B(t)
/bshade { exch 
1 add 2 div 
exch bernstein
} def

% ---------------------------------------------------------------------------------

% input: [pars] /fcn s0 s1 t0 t1 ns nt
% the fcn: [pars] s t -> f_{pars}(s, t)
% output: a polygonal surface of faces [ normal-fcn triangle ]

/mksurface {
16 dict begin
/nt exch def
/ns exch def
/t1 exch def
/t0 exch def
/s1 exch def
/s0 exch def
/ds s1 s0 sub ns div def
/dt t1 t0 sub nt div def
/f exch cvx def
/pars exch def
/P [
  /s s0 def
  ns 1 add {
    [
      /t t0 def
      nt 1 add {
        pars s t f
        /t t dt add def
      } repeat
    ]
    /s s ds add def
  } repeat
] def
% P[i][j] = f(s0 + i.ds, t0 + j.dt)
[
  0 1 ns 1 sub {
    /i exch def
    0 1 nt 1 sub {
      /j exch def
      % an array of triangles (i, j, 0) + (i, j, 1) 
      % dividing the rectangles in two
      /P00 P i get j get def
      /P10 P i 1 add get j get def
      /P01 P i get j 1 add get def
      /P11 P i 1 add get j 1 add get def
      % normal
      /Q P10 P00 vector-sub P01 P00 vector-sub cross-product def
      /r Q vector-length def
      r 0 ne {
        [
          [ Q aload pop Q P10 dot-product neg ]
          % array of pointers to three vertices
          [ P00 P10 P01 ]
        ] 
      } if
      /Q P01 P11 vector-sub P10 P11 vector-sub cross-product def
      /r Q vector-length def
      r 0 ne {
        [
          [ Q aload pop Q P01 dot-product neg ]
          % array of pointers to three vertices
          [ P10 P11 P01 ]
        ]
      } if
    } for
  } for
]
end
} def

% an array of vertices 
% traversed according to right hand rule
% output normalized

/normal-function {
2 dict begin
/a exch def
/n 
  a 1 get a 0 get vector-sub 
  a 2 get a 1 get vector-sub 
  cross-product 
def
/r n 0 get dup mul n 1 get dup mul add n 2 get dup mul add sqrt def
r 0 gt {
  /n [ n 0 get r div n 1 get r div n 2 get r div ] def
  [
    n aload pop
    a 0 get n dot-product neg
  ]
}{ [] } ifelse
end
} def

% --- light ------------------------------------------------

% should be part of the graphics environment

/set-light { /light-source exch def } def

/get-virtual-light {
  light-source cgfx3d 1 get transform3d
} def


 
%%EndProlog
gsave
%lanindL2 START  20000505
/lanind 1 def
/lantex [(G) (E) (S) (F) (I) (J) (M)] def
/showde {0 lanind eq {show} {pop} ifelse} bind def
/showen {1 lanind eq {show} {pop} ifelse} bind def
/showes {3 lanind eq {show} {pop} ifelse} bind def
/showfr {2 lanind eq {show} {pop} ifelse} bind def
/showit {4 lanind eq {show} {pop} ifelse} bind def
/showjp {5 lanind eq {show} {pop} ifelse} bind def
/showm  {6 lanind eq {show} {pop} ifelse} bind def
 
/lanindg where {pop /lanind1 lanindg def /lanind2 lanindg def}
               {/lanind1 1 def /lanind2 1 def} ifelse

/lanind lanind1 def
%lanind1 1 lanind2 {/lanind exch def %output showpage

%ps3d.inc

gsave

72 90 translate

250 -7 moveto
6 /Times-Roman FS
(DE421-7N) show

0 0 translate	
0 0 moveto
(XYZ) show 

0.01 MM 0.01 MM scale
15 setlinewidth
0 0  moveto 5400 0 rlineto 0 4000 rlineto -5400 0 rlineto
closepath stroke

grestore
gsave

showpage

72 90 translate

18 18 scale

0 0 translate
0 setlinewidth

0 setgray

newpath
2 2 moveto
1 0 rlineto
0 1 rlineto
-1 0 rlineto
closepath
fill

1 0 0 setrgbcolor

newpath
1 1 moveto
1 0 rlineto
0 1 rlineto
-1 0 rlineto
closepath
stroke


1 0 0 setrgbcolor

[0 0 5 1] set-eye

[0 1 0] 30 rotate3d

4 /Times-Roman FS

newpath
1 0 moveto
(ABC) true charpath

2d-path-convert
gsave
0.7 0 0.1 setrgbcolor
fill
grestore
stroke

%15 setlinewidth
0 1 0 setrgbcolor
0 0 0 moveto3d 10 0 0 rlineto3d 0 6 0 rlineto3d -10 0 0 rlineto3d
closepath stroke

newpath
0 0 1 setrgbcolor

1 1 0 moveto3d
1 0 0 rlineto3d
0 1 0 rlineto3d
-1 0 0 rlineto3d
closepath
stroke

/xd 0.6 def
/yd 0.6 def
/xf 0.5 def
/yf 0.5 def
/x0 xd 2 div def
/y0 yd 2 div def
0 1 8 {/j exch def %j=0,8
0 1 8 {/i exch def %i=0,8
       /ic i 0.1 mul def
       /jc j 0.1 mul def
       ic jc 0 setrgbcolor
       /x x0 i xd mul add def
       /y y0 j yd mul add def
       x y 0 moveto3d xf 0 0 rlineto3d 0 yf 0 rlineto3d
                  xf neg 0 0 rlineto3d closepath fill       
      } for %i=0,8
      } for %j=0,8

showpage

%%Trailer


%%EndDocument
EndEPSF grestore gsave

BeginEPSF
219 MM 020 MM translate 12 /Times-ISOL1 FS -9 MM -7 MM  moveto ( ) show
  10 /Times-ISOL1 FS  53 MM 1 MM moveto ( ) show 1 1 scale  -77 -91 translate
%%BeginDocument: Bild 28

%line 499
%!PS-Adobe-3.0 EPSF-3.0 DE421-8N
%%BoundingBox: 70 85 226 206

%START PDFDE011.EPS
/pdfmark18 where {pop} {userdict /pdfmark18 /cleartomark load put} ifelse
/languagelevel where {pop languagelevel} {1} ifelse
2 lt { userdict (<<) cvn ([) cvn load put
       userdict (>>) cvn (]) cvn load put} if
[ /Title (PostScript pictures: farbe.li.tu-berlin.de/DE42/DE42.HTM)
  /Author (compare K. Richter "Computergrafik ...": ISBN 3-8007-1775-1)
  /Subject (goto: http://farbe.li.tu-berlin.de http://130.149.60.45/~farbmetrik)
  /Keywords (image reproduction, colour devices)
  /Creator (klaus.richter@mac.com)
  /CreationDate (D:2018060112000)
  /ModDate (D:20180601112000)
/DOCINFO pdfmark18
[ /View [ /Fit ]
/DOCVIEW pdfmark18
%END  PDFDE011

/BeginEPSF {% def               % Prepare for EPS file
/b4_Inc_state save def          % Save state for cleanup
/dict_count countdictstack def
/op_count count 1 sub def       % Count objects on op stack
userdict begin                  % Make userdict current dict
/showpage {} def
0 setgray 0 setlinecap
1 setlinewidth 0 setlinejoin
10 setmiterlimit [] 0 setdash newpath
/languagelevel where            % If level not equal to 1 then
 {pop languagelevel where       % If level not equal to 1 then
 1 ne
 {false setstrokeadjust false setoverprint
 } if
} if
} bind def

/EndEPSF  {% def              % End for EPS file
 count op_count sub {pop} repeat
 countdictstack dict_count sub {end} repeat	% Clean up dict stack
 b4_Inc_state restore
} bind def


% !AUSTAUSCH Times-Roman -> Times-Roman-ISOLatin1=Times-I
 
/Times-Roman findfont dup length dict  begin
{1 index /FID ne {def} {pop pop} ifelse }forall
/Encoding ISOLatin1Encoding def
currentdict end
/Times-ISOL1 exch definefont pop
 
/Times-Italic findfont dup length dict  begin
{1 index /FID ne {def} {pop pop} ifelse }forall
/Encoding ISOLatin1Encoding def
currentdict end
/TimesI-ISOL1 exch definefont pop
 
/Times-Bold findfont dup length dict  begin
{1 index /FID ne {def} {pop pop} ifelse }forall
/Encoding ISOLatin1Encoding def
currentdict end
/TimesB-ISOL1 exch definefont pop
 
/Times-BoldItalic findfont dup length dict  begin
{1 index /FID ne {def} {pop pop} ifelse }forall
/Encoding ISOLatin1Encoding def
currentdict end
/TimesBI-ISOL1 exch definefont pop
 
/FS {findfont exch scalefont setfont} bind def
/MM {72 25.4 div mul} def /str {8 string } bind def
 
/TV {150 /Times-ISOL1 FS} bind def
/TS {200 /Times-ISOL1 FS} bind def 
/TK {250 /Times-ISOL1 FS} bind def
/TM {300 /Times-ISOL1 FS} bind def
/TG {350 /Times-ISOL1 FS} bind def

/TIV {150 /TimesI-ISOL1 FS} bind def
/TIS {200 /TimesI-ISOL1 FS} bind def 
/TIK {250 /TimesI-ISOL1 FS} bind def
/TIM {300 /TimesI-ISOL1 FS} bind def
/TIG {350 /TimesI-ISOL1 FS} bind def

/TBV {150 /TimesB-ISOL1 FS} bind def
/TBS {200 /TimesB-ISOL1 FS} bind def
/TBK {250 /TimesB-ISOL1 FS} bind def
/TBM {300 /TimesB-ISOL1 FS} bind def
/TBG {350 /TimesB-ISOL1 FS} bind def

/TBIV {150 /TimesBI-ISOL1 FS} bind def
/TBIS {200 /TimesBI-ISOL1 FS} bind def
/TBIK {250 /TimesBI-ISOL1 FS} bind def
/TBIM {300 /TimesBI-ISOL1 FS} bind def
/TBIG {350 /TimesBI-ISOL1 FS} bind def

/RV {150 /Times-Roman FS} bind def
/RS {200 /Times-Roman FS} bind def
/RK {250 /Times-Roman FS} bind def
/RM {300 /Times-Roman FS} bind def
/RG {350 /Times-Roman FS} bind def

/RIV {150 /Times-Italic FS} bind def
/RIS {200 /Times-Italic FS} bind def
/RIK {250 /Times-Italic FS} bind def
/RIM {300 /Times-Italic FS} bind def
/RIG {350 /Times-Italic FS} bind def

/RBV {150 /Times-Bold FS} bind def
/RBS {200 /Times-Bold FS} bind def
/RBK {250 /Times-Bold FS} bind def
/RBM {300 /Times-Bold FS} bind def
/RBG {350 /Times-Bold FS} bind def

/RBIV {150 /Times-BoldItalic FS} bind def
/RBIS {200 /Times-BoldItalic FS} bind def
/RBIK {250 /Times-BoldItalic FS} bind def
/RBIM {300 /Times-BoldItalic FS} bind def
/RBIG {350 /Times-BoldItalic FS} bind def

/SV {150 /Symbol FS} bind def
/SS {200 /Symbol FS} bind def
/SK {250 /Symbol FS} bind def
/SM {300 /Symbol FS} bind def
/SG {350 /Symbol FS} bind def

/rec %x, y width heigth
  {/heigth exch def /width exch def
   moveto width 0 rlineto 0 heigth rlineto width neg 0 rlineto
   closepath } bind def

/rec3d %x, y width heigth
  {/heigth exch def /width exch def
   0 moveto3d width 0 0 rlineto3d 0 heigth 0 rlineto3d width neg 0 0 rlineto3d
   closepath } bind def
 
/colrecfi %x y width heigth c m y k
  {setrgbcolor rec fill} bind def
 
/colrecst %x y width heigth c m y k
  {setrgbcolor rec stroke} bind def
 
/cvishow {0.5 add cvi 6 string cvs show} def
/cvsshow1  {10 mul cvi 0.1 mul 7 string cvs show} def
/cvsshow2  {100 mul cvi 0.01 mul 7 string cvs show} def
/cvsshow3  {1000 mul cvi 0.001 mul 7 string cvs show} def
/cvsshow4  {10000 mul cvi 0.0001 mul 8 string cvs show} def
 
%
% - %This is ps3d.inc ----------------------------------

% - Copyright Bill Casselman
% - Original version 1.0 November, 1998
% - Version 1.1 December, 1999
% -      Took out aliases for moveto etc.
% -      Made display-matrix a 3 x 4 homogeneous matrix, added it to the 3d gstack 
% -      Allowed arbitrary eye location, 3d -> 2d projects onto z = 0 plane
% -      Although fancy stuff not yet implemented
% -      Made ght a variable
% -      Version 1.1 is *not* backwards compatible!
% - Version 1.2 August, 2002
% -      Thorough interpretation of matrices as arrays of columns and point vectors as rows
% -      And some speed up
% -      Similar rewriting of matrix.inc
% -      Again, backwards incompatible!
% - Version 1.3 August, 2003
% -      Rewriting shade for efficiency
% - Thanks to Jim Blinn's book `A trip down the graphics pipeline'
% - for several suggestions that (I hope) made this code cleaner 
% - by suggesting how useful homogeneous coordinates were.
% November 10, 2003: added fancier shading
% December 17, 2003: changed arguments for mkpath procedures

% ------------------------------------------------


% - Inserting matrix.inc ----------------------

% - Vector calculations (usually good in any number of dimensions) ----------

% - matrices in this package are usually laid out in a single array by columns ---
% - i.e. [ column1 column 2 ... ]
% - but sometimes as a double array [ [ column1] [column2] ... ] 

% <double array>  /to-single-array
% <single-array> /to-double-array
% <n> /identity
% <u> <v> /dot-product
% <u> <c> /vector-scale
% <u> <v> /vector-add
% <u> <v> /vectorssub
% <u> /vector-length
% <u> <v> cross-product
% <axis> <angle> /rotation-matrix3d
% v [a b c] /euclidean-reflect
% [a b c] /reflection-matrix-3d
% <m> <n> /matrix-mul
% <m> <v> /matrix-vector
% <v> <m> /vector-matrix 
% <m> /transpose
% <m> 3x3-det
% <m> /3x3-inverse
% <u> <v> /angle-between
% <x> /acos
% <x> <a> <a^v> /skew-reflect
% <a> <a^v> /skew-reflection-matrix

% - matrices in this package are laid out in a single array by columns ---------

% a double array: cannot be empty - just lays out all items
/to-single-array {
% [ [. . . ][ . . . ] ] => [ . . . . . . ]
[
	exch { % successive rows
		aload pop
	} forall
]
} def

% ----------------------------------------------

% [ ... ] a square matrix made into an array of columns
/to-double-array { 4 dict begin
/A exch def
/N A length sqrt round cvi def
/i 0 def
[
N {
	[
	N {
		A i get
		/i i 1 add def
	} repeat
	]
} repeat
]
end } def

% ----------------------------------------

% returns the nxn identity matrix as single array
/identity { 1 dict begin
/n exch def
[
  n 1 sub {
    1 
    n {
      0
	} repeat 
  } repeat
  1
]
end } def

% --- vector algebra --------------------------------

% u v -> u.v
/dot-product { 1 dict begin
/v exch def
0 0	     		% u s i
3 2 roll { 		% s i u[i]
  v 			% s i u[i] v
  2 index get mul 	% s i u[i]*v[i]
  3 2 roll		% i u[i]*v[i] s
  add exch 1 add	% s i
} forall
pop
end } def

% v c -> c.v
/vector-scale { 1 dict begin
/c exch def
[ exch
{ 		% s i u[i]
  c mul			% s i u[i] v 
} forall
]
end } def

% u v -> u+v
/vector-add { 1 dict begin
/v exch def
[ exch
0 	     	% u i
exch { 		% i u[i]
  v 		% i u[i] v
  2 index get add 	% i u[i]+v[i]
  exch 1 add	% i
} forall
pop
]
end } def

% u v -> u-v
/vector-sub { 1 dict begin
/v exch def
[ exch
0 	     	% u i
exch { 		% i u[i]
  v 		% i u[i] v
  2 index get sub 	% i u[i]+v[i]
  exch 1 add	% i
} forall
pop
]
end } def

% [x y z ... ] -> r
% watch out for overflow

/vector-length { 1 dict begin
dup
% find maximum entry
/max 0 def
{ % max 
  abs dup max gt {
    % if abs gt max
    /max exch def
  } {
    pop
  } ifelse
} forall

max 0 ne {
  0 exch 
  {  % 0 v[i]
    max div dup mul add
  } forall
  sqrt
  max mul
} {
  pop 0
} ifelse
end } def

% v -> v/|v|
/normalized { 1 dict begin
dup 			% v v
vector-length /r exch def
[ exch
  {
    r div
  } forall
]
end } def

% u v
% u0 u1 u2
% v0 v1 v2
% -> u x v
/cross-product {
2 dict begin
/v exch def
/u exch def
[
  u 1 get v 2 get mul
  v 1 get u 2 get mul sub

  v 0 get u 2 get mul
  u 0 get v 2 get mul sub

  u 0 get v 1 get mul
  v 0 get u 1 get mul sub
]
end
} def

% --------------------------------------------------------------

% axis A -> a matrix
/rotation-matrix3d {
8 dict begin
dup 
cos /c exch def
sin /s exch def
/a exch def
/r a vector-length def
/a0 a 0 get r div def
/a1	a 1 get r div def
/a2 a 2 get r div def

[

% e = [1 0 0] etc.
% e0 = (e.a)a, e# = e - e0, e* = a x e = a x e0 + a x e# = a x e#
/x a0 def
/e0 [a0 x mul
     a1 x mul 
     a2 x mul] def
/e# [1 e0 0 get sub 
     e0 1 get neg 
     e0 2 get neg] def
% [a0 a1 a2]
% [ 1  0  0]
/e* [0 
     a2 
     a1 neg
    ] def
e# 0 get c mul e* 0 get s mul add e0 0 get add 
e# 1 get c mul e* 1 get s mul add e0 1 get add 
e# 2 get c mul e* 2 get s mul add e0 2 get add 

/x a1 def
/e0 [a0 x mul a1 x mul a2 x mul] def
/e# [e0 0 get neg 
     1 e0 1 get sub 
     e0 2 get neg] def
% [a0 a1 a2]
% [ 0  1  0]
/e* [a2 neg 
     0
     a0
    ] def
e# 0 get c mul e* 0 get s mul add e0 0 get add 
e# 1 get c mul e* 1 get s mul add e0 1 get add 
e# 2 get c mul e* 2 get s mul add e0 2 get add 

/x a2 def
/e0 [a0 x mul a1 x mul a2 x mul] def
/e# [e0 0 get neg
     e0 1 get neg
     1 e0 2 get sub] def
% [a0 a1 a2]
% [ 0  0  1]
/e* [a1 
     a0 neg
     0
    ] def
e# 0 get c mul e* 0 get s mul add e0 0 get add 
e# 1 get c mul e* 1 get s mul add e0 1 get add 
e# 2 get c mul e* 2 get s mul add e0 2 get add 

]
% [ r0 r1 r2 r3 r4 r5 r6 r7 r8 ] -> [r0 r3 r6 r1 r4 r7 r2 r5 r8 ]
/r exch def
[
	r 0 get 
	r 3 get
	r 6 get
	r 1 get
	r 4 get
	r 7 get
	r 2 get
	r 5 get
	r 8 get
] 
end
} def

% v a -> v - 2(a.v)/(a.a) a
/euclidean-reflect { 16 dict begin
/a exch def
/v exch def
/N a length def
/d a v dot-product a dup dot-product div 2 mul def
[
  0
  v {
    % i v[i]
    exch dup 1 add					% v[i] i i+1
	3 1 roll							  % i+1 v[i] i
    a exch get d mul 				% i+1 v[i] a[i]*d
	sub										% i+1 v[i]-d*a[i]
	exch									% rv[i] i+1
  } forall
  pop
]
end } def

% f = [A B C] => linear 3d transformation: f not necessarily normalized
% Rv = v - 2 <f', v> f'

/reflection-matrix3d {
3 dict begin
aload pop
/C exch def
/B exch def
/A exch def
/r [ A B C ] vector-length def
/A A r div def
/B B r div def
/C C r div def
[
  1 A A mul dup add sub   B A mul dup add neg   C A mul dup add neg
    A B mul dup add neg 1 B B mul dup add sub   C B mul dup add neg
    A C mul dup add neg   B C mul dup add neg 1 C C mul dup add sub
]
end
} def

/matrix-mul {
8 dict begin
/B exch def
/A exch def
/n A length sqrt round cvi def
%  0    1  ...
%  n  n+1 ...
% 2n 2n+1 ...
[
  0
  n {
    % i = initial index of the column on the stack = 0, n, 2n ... 
    % after all previous entries
    dup n add exch 0	
    n {
	  % i+n i j on stack
      % j = initial index of the row
	  2 copy 1 add % i+n i j i j+1
	  4 2 roll	% i+n i j+1 i j
	  /ell exch def
      /k exch def
	  % i+n i j+1 
      0
      n {
		% i+n i j+1 s
        A ell get B k get mul add
        /k k 1 add def
        /ell ell n add def
      } repeat
	  4 1 roll
	  % s i+n i j+1
   	} repeat
    pop pop	% s i+n
  } repeat
  pop
]
end
} def

% A v: A = [ column 1, column 2, ... , column n ]
/matrix-vector {
8 dict begin
/v exch def
/r v length def
/A exch def
/c A length r idiv def
[
  0 1 c 1 sub {
	/i exch def
    % i = initial index of the row
    0 0
    r {
		% s j on stack
		dup 1 add	% s j j+1
		3 1 roll		% j+1 s j
      	v exch get A i get mul add	% j+1 s
		exch
   	  	/i i r add def
    } repeat
	% s r
	pop
  } for
]
end
} def

% v A: A = [ column1 column2 ... ]
/vector-matrix {
8 dict begin
/A exch def
/v exch def
/c v length def
/r A length c idiv def
[
  /i 0 def 
  r {
    % i = initial index of the row
    /j 0 def
    0
    c {
      A i get v j get mul add
      /j j 1 add def
   	  /i i 1 add def
    } repeat
  } repeat
]
end
} def

% a square matrix m x m
% [i, j] = n*i + j

/transpose {
4 dict begin
/M exch def
/n M length sqrt round cvi def
[
/k 0 def
n {
  /i k def
  n { 
    M i get
    /i i n add def
  } repeat
  /k k 1 add def
} repeat
]

end
} def

/3x3-det {
1 dict begin
/m exch def

m 0 get 
m 4 get mul
m 8 get mul

m 1 get 
m 5 get mul
m 6 get mul
add

m 2 get 
m 3 get mul
m 7 get mul
add

m 2 get 
m 4 get mul
m 6 get mul
sub

m 1 get 
m 3 get mul
m 8 get mul
sub

m 0 get 
m 5 get mul
m 7 get mul
sub

end
} def

/3x3-inverse {
2 dict begin
/m exch def
/d m 3x3-det def
[
   m 4 get m 8 get mul 
   m 5 get m 7 get mul sub
   d div
   
   m 2 get m 7 get mul 
   m 1 get m 8 get mul sub
   d div
   
   m 1 get m 5 get mul 
   m 4 get m 2 get mul sub
   d div

   m 5 get m 6 get mul 
   m 3 get m 8 get mul sub
   d div
   
   m 0 get m 8 get mul 
   m 2 get m 6 get mul sub
   d div
   
   m 2 get m 3 get mul 
   m 0 get m 5 get mul sub
   d div

   m 3 get m 7 get mul 
   m 6 get m 4 get mul sub
   d div
   
   m 1 get m 6 get mul 
   m 0 get m 7 get mul sub
   d div
   
   m 0 get m 4 get mul 
   m 1 get m 3 get mul sub
   d div
]
end
} def

/acos {
dup dup % x x x
mul 1 sub neg % x 1-x^2
sqrt exch atan
} def

% u v

/angle-between {
dup vector-length
% u v |v|
3 1 roll
% |v| u v
1 index 
% |v| u v u
dot-product
% |v| u u.v
exch vector-length
% |v| u.v |u|
div exch div
acos
} def

% x a av -> x - <a, x> av

/skew-reflect { 4 dict begin
/av exch def
/a exch def
/x exch def
/d x a dot-product def
[
	0 1 x length 1 sub {
		/i exch def
		x i get av i get d mul sub
	} for
]
end } def

% a av -> matrix
/skew-reflection-matrix { 8 dict begin
/av exch def
/a exch def
/n a length def
[
	0 1 n 1 sub {
		/i exch def
		[ n {0} repeat ] dup i 1 put
		% e[i] 
		a av skew-reflect
	} for
]
to-single-array
transpose
end } def

% - closing matrix.inc ------------------------

% - Defining PostScript commands' equivalents ----------

% - Coordinates in three dimensions -------------------

% There are three steps to drawing something in 3D:
% 1.  Converting from user 3d coords to default 3d coords
% 2.  Projecting onto (x, y)-plane
% 3.  Drawing the image on that plane
% These are more or less independent.  
% The last step is completely controlled by the usual PS stuff.
% The first and second are handled by 3d stuff here.

% - Initialize and manipulate the 3d gstack -----------

/gmax 64 def
/ght 0 def

% gstack = [[t0 d0 dm0] [t1 d2 dm1] [t2 d2 dm2] ... [t(gmax-1) d(gmax-1) dm(gmax-1)] ]

% the ctm is t[ght]
% the dual ctm is at d[ght]
% they are 4 x 4
% display-matrix = 3 x 4

/gstack3d gmax array def

% start with orthogonal projection to positive z-axis
gstack3d 0 [
  [ 1 0 0 0 
    0 1 0 0
    0 0 1 0
    0 0 0 1] 
  [ 1 0 0 0 
    0 1 0 0
    0 0 1 0
    0 0 0 1]
  [ 1 0 0 0
    0 1 0 0
    0 0 0 1]
] put

/gsave3d {
  /ctm gstack3d ght get def
  /ght ght 1 add def 
  ght gmax eq {
    (3d graphics stack overflow!) ==
    quit
  } if
  gstack3d 
    ght
    [ ctm 0 get ctm 1 get ctm 2 get ] 
  put
} def

/grestore3d {
  /ght ght 1 sub def
  ght 0 lt {
     (3d graphics stack underflow!) ==
     quit
  } if
} def

% n - restores to depth n

/gpop3d {
/ght exch def
} def

% [T T* dm]: sets cgfx3d = [T T* dm]

/gset3d {
gstack3d  		% [T T* d] g 
ght			    % [T T* d] g ght
3 2 roll 		    % g ght [T T* d]
put 
} def

% => [T T* dm]

/cgfx3d {
  gstack3d ght get
} def

/ctm3d {
  gstack3d ght get 0 get
} def

/cim3d {
  gstack3d ght get 1 get
} def

/cdm3d {
  gstack3d ght get 2 get
} def

% cpt3d isthe last 3d point drawn to

/currentpoint3d {
cpt3d
cgfx3d 1 get transform3d
aload pop     % x y z w 
pop			
} def

% - Sets up projection into 2D -------------------
		
% O = [x y z w] 
% sets display-matrix perspective onto z = 0 plane

/display-matrix {
  cgfx3d 2 get
} def

% [z0 0 -x0 0
%  0 z0 -y0 0
%  0 0 -w0 z0]
% (transposed)
% gives perspective onto point in z=0 plane
% from [x0 y0 z0 w0]

/set-eye {
4 dict begin
aload pop
/w0 exch def
/z0 exch def
/y0 exch def
/x0 exch def
gstack3d ght get
2 
[ z0 0 x0 neg 0 
  0 z0 y0 neg 0
  0 0 w0 neg z0]
put
end
} def

/get-eye { 1 dict begin
/d display-matrix def
[d 2 get neg d 6 get neg d 0 get d 10 get neg]
end } def

/get-virtual-eye {
get-eye cgfx3d 1 get transform3d
} def

% - backwards compatibility -----------------------------

/origin { get-eye } def
/eye { get-eye } def
/set-display { set-eye } def

% - Manipulate the current transformation matrix -----

% x y z

/translate3d {
8 dict begin
/z exch def
/y exch def
/x exch def
/ctm cgfx3d def
/T ctm 0 get def
[
[
  T 0 get 
  T 1 get 
  T 2 get 
  T 0 get x  mul
  T 1 get y  mul
  add
  T 2 get z  mul
  add
  T 3 get 
  add
  
  T 4 get 
  T 5 get 
  T 6 get
  T 4 get x  mul
  T 5 get y  mul
  add
  T 6 get z  mul
  add
  T 7 get 
  add
   
  T 8 get 
  T 9 get 
  T 10 get
  T 8 get x  mul
  T 9 get y  mul
  add
  T 10 get z  mul
  add
  T 11 get 
  add
   
  T 12 get 
  T 13 get 
  T 14 get
  T 12 get x  mul
  T 13 get y  mul
  add
  T 14 get z  mul
  add
  T 15 get 
  add
]
/T ctm 1 get def
[
  T 0 get T 12 get x mul sub 
  T 1 get T 13 get x mul sub 
  T 2 get T 14 get x mul sub 
  T 3 get T 15 get x mul sub 

  T 4 get T 12 get y mul sub 
  T 5 get T 13 get y mul sub 
  T 6 get T 14 get y mul sub 
  T 7 get T 15 get y mul sub 

  T 8 get T 12 get z mul sub 
  T 9 get T 13 get z mul sub 
  T 10 get T 14 get z mul sub 
  T 11 get T 15 get z mul sub 

  T 12 get
  T 13 get
  T 14 get
  T 15 get
]
  ctm 2 get
]
end
gset3d
} def

% ------------------------------------------------------

% axis A

/rotate3d { 4 dict begin
rotation-matrix3d
/R exch def
/C cgfx3d def
/T C 0 get def
[
[
  % first row
  T 0 get R 0 get mul
  T 1 get R 3 get mul
  add
  T 2 get R 6 get mul
  add
  
  T 0 get R 1 get mul
  T 1 get R 4 get mul
  add
  T 2 get R 7 get mul
  add
  
  T 0 get R 2 get mul
  T 1 get R 5 get mul
  add
  T 2 get R 8 get mul
  add
  
  T 3 get
  
  % second row
  T 4 get R 0 get mul
  T 5 get R 3 get mul
  add
  T 6 get R 6 get mul
  add
  
  T 4 get R 1 get mul
  T 5 get R 4 get mul
  add
  T 6 get R 7 get mul
  add
  
  T 4 get R 2 get mul
  T 5 get R 5 get mul
  add
  T 6 get R 8 get mul
  add
  
  T 7 get
  
  % third row
  T 8 get R 0 get mul
  T 9 get R 3 get mul
  add
  T 10 get R 6 get mul
  add
  
  T 8 get R 1 get mul
  T 9 get R 4 get mul
  add
  T 10 get R 7 get mul
  add
  
  T 8 get R 2 get mul
  T 9 get R 5 get mul
  add
  T 10 get R 8 get mul
  add
  
  T 11 get
  
  % fourth row
  T 12 get R 0 get mul
  T 13 get R 3 get mul
  add
  T 14 get R 6 get mul
  add
  
  T 12 get R 1 get mul
  T 13 get R 4 get mul
  add
  T 14 get R 7 get mul
  add
  
  T 12 get R 2 get mul
  T 13 get R 5 get mul
  add
  T 14 get R 8 get mul
  add
  
  T 15 get
]
/T C 1 get def
% T = T^-1
% => R^-1 T^-1 
[
  R 0 get T 0 get mul
  R 3 get T 4 get mul add
  R 6 get T 8 get mul add
  
  R 0 get T 1 get mul
  R 3 get T 5 get mul add
  R 6 get T 9 get mul add
  
  R 0 get T 2 get mul
  R 3 get T 6 get mul add
  R 6 get T 10 get mul add
  
  R 0 get T 3 get mul
  R 3 get T 7 get mul add
  R 6 get T 11 get mul add
  
  % ------------------------
  
  R 1 get T 0 get mul
  R 4 get T 4 get mul add
  R 7 get T 8 get mul add
  
  R 1 get T 1 get mul
  R 4 get T 5 get mul add
  R 7 get T 9 get mul add
  
  R 1 get T 2 get mul
  R 4 get T 6 get mul add
  R 7 get T 10 get mul add
  
  R 1 get T 3 get mul
  R 4 get T 7 get mul add
  R 7 get T 11 get mul add
  
  % ------------------------
  
  R 2 get T 0 get mul
  R 5 get T 4 get mul add
  R 8 get T 8 get mul add
  
  R 2 get T 1 get mul
  R 5 get T 5 get mul add
  R 8 get T 9 get mul add
  
  R 2 get T 2 get mul
  R 5 get T 6 get mul add
  R 8 get T 10 get mul add
  
  R 2 get T 3 get mul
  R 5 get T 7 get mul add
  R 8 get T 11 get mul add

  T 12 get
  T 13 get
  T 14 get
  T 15 get  
]
  C 2 get
]
end
gset3d
} def


% f = [A B C D] P
% f = 0 is the *affine* reflection plane
% v = v* + v0 with v* on f = 0 and v0 in P-direction => v* - v0
% The map is Q => f(P)*Q - 2*f(Q)P
% It is of order two.
%
% f(P) I -
%
% 2A*P[0] 2B*P[0] 2C*P[0] 2D*P[0]
% 2A*P[1] 2B*P[1] 2C*P[1] 2D*P[1]
% 2A*P[2] 2B*P[2] 2C*P[2] 2D*P[2]
% 2A*P[3] 2B*P[3] 2C*P[3] 2D*P[3]
%
% Matrix = f(P) I - P f
% set s0 = (T row 0)*P
% T x this =
% f(P)T[0,0]-A*s -B*s -C*s -D*s

/affine-reflect3d { 4 dict begin
aload pop
/P3 exch def
/P2 exch def
/P1 exch def
/P0 exch def
aload pop
/D exch def
/C exch def
/B exch def
/A exch def

/fP 
  A P0 mul 
  B P1 mul add
  C P2 mul add
  D P3 mul add
def
/A A dup add def
/B B dup add def
/C C dup add def
/D D dup add def
[
/T cgfx3d 0 get def
[
  /s % = (T row 1)*P
  T 0 get P0 mul
  T 1 get P1 mul add
  T 2 get P2 mul add
  T 3 get P3 mul add
  def
  
  fP T 0 get mul
    A s mul sub
  fP T 1 get mul
    B s mul sub
  fP T 2 get mul
    C s mul sub
  fP T 3 get mul
    D s mul sub

  /s % = (T row 1)*P
  T 4 get P0 mul
  T 5 get P1 mul add
  T 6 get P2 mul add
  T 7 get P3 mul add
  def
  
  fP T 4 get mul
    A s mul sub
  fP T 5 get mul
    B s mul sub
  fP T 6 get mul
    C s mul sub
  fP T 7 get mul
    D s mul sub

  /s % = (T row 2)*P
  T 8 get P0 mul
  T 9 get P1 mul add
  T 10 get P2 mul add
  T 11 get P3 mul add
  def
  
  fP T 8 get mul
    A s mul sub
  fP T 9 get mul
    B s mul sub
  fP T 10 get mul
    C s mul sub
  fP T 11 get mul
    D s mul sub

  /s % = (T row 3)*P
  T 12 get P0 mul
  T 13 get P1 mul add
  T 14 get P2 mul add
  T 15 get P3 mul add
  def
  
  fP T 12 get mul
    A s mul sub
  fP T 13 get mul
    B s mul sub
  fP T 14 get mul
    C s mul sub
  fP T 15 get mul
    D s mul sub
]
/T cgfx3d 1 get def
/f0 		
  % f paired with columns of T
  T 0 get A mul
  T 4 get B mul add
  T 8 get C mul add
  T 12 get D mul add
def

/f1 		
  % f paired with columns of T
  T 1 get A mul
  T 5 get B mul add
  T 9 get C mul add
  T 13 get D mul add
def

/f2 		
  % f paired with columns of T
  T 2 get A mul
  T 6 get B mul add
  T 10 get C mul add
  T 14 get D mul add
def

/f3 		
  % f paired with columns of T
  T 3 get A mul
  T 7 get B mul add
  T 11 get C mul add
  T 15 get D mul add
def

[
  fP T 0 get mul
    f0 P0 get mul sub
  fP T 1 get mul
    f1 P0 get mul sub
  fP T 2 get mul
    f2 P0 get mul sub
  fP T 3 get mul
    f3 P0 get mul sub
  fP T 4 get mul
    f0 P1 get mul sub
  fP T 5 get mul
    f1 P1 get mul sub
  fP T 6 get mul
    f2 P1 get mul sub
  fP T 7 get mul
    f3 P1 get mul sub
  fP T 8 get mul
    f0 P2 get mul sub
  fP T 9 get mul
    f1 P2 get mul sub
  fP T 10 get mul
    f2 P2 get mul sub
  fP T 11 get mul
    f3 P2 get mul sub
  fP T 12 get mul
    f0 P3 get mul sub
  fP T 13 get mul
    f1 P3 get mul sub
  fP T 14 get mul
    f2 P3 get mul sub
  fP T 15 get mul
    f3 P3 get mul sub
]
  cgfx3d 2 get
] 
end
gset3d
} def

% 3x3 M 

/concat3d {
4 dict begin
/M exch def
[
/T cgfx3d 0 get def
  [
    T 0 get M 0 get mul
    T 1 get M 3 get mul add
    T 2 get M 6 get mul add

    T 0 get M 1 get mul
    T 1 get M 4 get mul add
    T 2 get M 7 get mul add
     
    T 0 get M 2 get mul
    T 1 get M 5 get mul add
    T 2 get M 8 get mul add
    
    T 3 get
     
    T 4 get M 0 get mul
    T 5 get M 3 get mul add
    T 6 get M 6 get mul add

    T 4 get M 1 get mul
    T 5 get M 4 get mul add
    T 6 get M 7 get mul add
     
    T 4 get M 2 get mul
    T 5 get M 5 get mul add
    T 6 get M 8 get mul add
    
    T 7 get
     
    T 8 get M 0 get mul
    T 9 get M 3 get mul add
    T 10 get M 6 get mul add

    T 8 get M 1 get mul
    T 9 get M 4 get mul add
    T 10 get M 7 get mul add
     
    T 8 get M 2 get mul
    T 9 get M 5 get mul add
    T 10 get M 8 get mul add
    
    T 11 get
     
    T 12 get M 0 get mul
    T 13 get M 3 get mul add
    T 14 get M 6 get mul add

    T 12 get M 1 get mul
    T 13 get M 4 get mul add
    T 14 get M 7 get mul add
     
    T 12 get M 2 get mul
    T 13 get M 5 get mul add
    T 14 get M 8 get mul add
    
    T 15 get
     
  ]
/T cgfx3d 1 get def
/M M 3x3-inverse def
  [
    M 0 get T 0 get mul
    M 1 get T 4 get mul add
    M 2 get T 8 get mul add
    
    M 0 get T 1 get mul
    M 1 get T 5 get mul add
    M 2 get T 9 get mul add
    
    M 0 get T 2 get mul
    M 1 get T 6 get mul add
    M 2 get T 10 get mul add
    
    M 0 get T 3 get mul
    M 1 get T 7 get mul add
    M 2 get T 11 get mul add
    
    % -----------------------------
    
    M 3 get T 0 get mul
    M 4 get T 4 get mul add
    M 5 get T 8 get mul add
    
    M 3 get T 1 get mul
    M 4 get T 5 get mul add
    M 5 get T 9 get mul add
    
    M 3 get T 2 get mul
    M 4 get T 6 get mul add
    M 5 get T 10 get mul add
    
    M 3 get T 3 get mul
    M 4 get T 7 get mul add
    M 5 get T 11 get mul add
    
    % -----------------------------
    
    M 6 get T 0 get mul
    M 7 get T 4 get mul add
    M 8 get T 8 get mul add
    
    M 6 get T 1 get mul
    M 7 get T 5 get mul add
    M 8 get T 9 get mul add
    
    M 6 get T 2 get mul
    M 7 get T 6 get mul add
    M 8 get T 10 get mul add
    
    M 6 get T 3 get mul
    M 7 get T 7 get mul add
    M 8 get T 11 get mul add
    
    % -----------------------------
    
    T 12 get
    T 13 get
    T 14 get
    T 15 get
  ]
  cgfx3d 2 get
]
end
gset3d
} def

%
% v => v - 2 <v, a> a
%
% Matrix = I - 2 a a
% a

/reflect3d { 4 dict begin
reflection-matrix3d 
concat3d
end } def

% [x y z w] [a00 a01 a02 a03 ... ]
% but the vector is a linear function
% so it is multiplying by transpose
% if T is the current ctm3d, the point P -> P T transform3d
% but the plane f=0 -> f T^{-1} dual-transform3d

/dual-transform3d { 4 dict begin
/v exch def
/T exch def
[
  v 0 get T 0 get mul
  v 1 get T 4 get mul add
  v 2 get T 8 get mul add
  v 3 get T 12 get mul add
  
  v 0 get T 1 get mul
  v 1 get T 5 get mul add
  v 2 get T 9 get mul add
  v 3 get T 13 get mul add
  
  v 0 get T 2 get mul
  v 1 get T 6 get mul add
  v 2 get T 10 get mul add
  v 3 get T 14 get mul add
  
  v 0 get T 3 get mul
  v 1 get T 7 get mul add
  v 2 get T 11 get mul add
  v 3 get T 15 get mul add
]
end } def

% 4d to 3d homogeneous
/project3d { 4 dict begin
/T exch def
/v exch def
[
  T 0 get v 0 get mul
  T 1 get v 1 get mul
  add 
  T 2 get v 2 get mul 
  add
  T 3 get v 3 get mul 
  add

  T 4 get v 0 get mul
  T 5 get v 1 get mul
  add 
  T 6 get v 2 get mul 
  add
  T 7 get v 3 get mul 
  add

  T 8 get v 0 get mul
  T 9 get v 1 get mul
  add 
  T 10 get v 2 get mul 
  add
  T 11 get v 3 get mul 
  add
] 
end } def

% [x y z w] [a00 a01 a02 a03 ... ]

/transform3d {
4 dict begin
/T exch def
/v exch def
[
T 0 get v 0 get mul
T 1 get v 1 get mul
add 
T 2 get v 2 get mul 
add
T 3 get v 3 get mul 
add

T 4 get v 0 get mul
T 5 get v 1 get mul
add 
T 6 get v 2 get mul 
add
T 7 get v 3 get mul 
add

T 8 get v 0 get mul
T 9 get v 1 get mul
add 
T 10 get v 2 get mul 
add
T 11 get v 3 get mul 
add

T 12 get v 0 get mul
T 13 get v 1 get mul
add 
T 14 get v 2 get mul 
add
T 15 get v 3 get mul 
add

] 
end
} def

% sx sy sz

/scale3d {
8 dict begin
/sz exch def
/sy exch def
/sx exch def
/T cgfx3d 0 get def
[
[
  T 0 get sx mul
  T 1 get sy mul
  T 2 get sz mul
  T 3 get 
  
  T 4 get sx mul
  T 5 get sy mul
  T 6 get sz mul
  T 7 get 
  
  T 8 get sx mul
  T 9 get sy mul
  T 10 get sz mul
  T 11 get 
 
  T 12 get sx mul
  T 13 get sy mul
  T 14 get sz mul
  T 15 get 
]
/T cgfx3d 1 get def
[
  T 0 get sx div
  T 1 get sx div
  T 2 get sx div
  T 3 get sx div
  
  T 4 get sy div
  T 5 get sy div
  T 6 get sy div
  T 7 get sy div
  
  T 8 get sz div
  T 9 get sz div
  T 10 get sz div
  T 11 get sz div
 
  T 12 get 
  T 13 get 
  T 14 get 
  T 15 get 
]
  cgfx3d 2 get
]
end
gset3d
} def

% [ <9> ] i

/row {
4 dict begin
/i exch def
/a exch def
a length 9 eq {
  /i i 3 mul def
  /n i 2 add def
} {
  /i i 4 mul def
  /n i 3 add def
} ifelse
[
  i 1 n {
    a exch get
  } for
]
end
} def

% projects from P onto f=Ax+By+Cz+D=0
% two parameters: f = [A B C D] and P
% The map is Q => f(P)*Q - f(Q)P
% It is idempotent.
%
% f(P) I -
%
% A*P[0] A*P[1] A*P[2] A*P[3]
% B*P[0] B*P[1] B*P[2] B*P[3]
% C*P[0] C*P[1] C*P[2] C*P[3]
% D*P[0] D*P[1] D*P[2] D*P[3]
%
% Matrix = f(P) I - P f
% set s0 = (T row 0)*P
% T x this =
% f(P)T[0,0]-A*s -B*s -C*s -D*s

/plane-project {
12 dict begin
aload pop
/P3 exch def
/P2 exch def
/P1 exch def
/P0 exch def
aload pop
/D exch def
/C exch def
/B exch def
/A exch def

/fP 
  A P0 mul 
  B P1 mul add
  C P2 mul add
  D P3 mul add
def
[
/T cgfx3d 0 get def
[
  /s % = (T row 0)*P
  	T 0 get P0 mul
  	T 1 get P1 mul add
  	T 2 get P2 mul add
  	T 3 get P3 mul add
  def
  
  fP T 0 get mul
    A s mul sub
  fP T 1 get mul
    B s mul sub
  fP T 2 get mul
    C s mul sub
  fP T 3 get mul
    D s mul sub


  /s % = (T row 1)*P
  T 4 get P0 mul
  T 5 get P1 mul add
  T 6 get P2 mul add
  T 7 get P3 mul add
  def
  
  fP T 4 get mul
    A s mul sub
  fP T 5 get mul
    B s mul sub
  fP T 6 get mul
    C s mul sub
  fP T 7 get mul
    D s mul sub


  /s % = (T row 2)*P
  T 8 get P0 mul
  T 9 get P1 mul add
  T 10 get P2 mul add
  T 11 get P3 mul add
  def
  
  fP T 8 get mul
    A s mul sub
  fP T 9 get mul
    B s mul sub
  fP T 10 get mul
    C s mul sub
  fP T 11 get mul
    D s mul sub

  /s % = (T row 3)*P
  T 12 get P0 mul
  T 13 get P1 mul add
  T 14 get P2 mul add
  T 15 get P3 mul add
  def
  
  fP T 12 get mul
    A s mul sub
  fP T 13 get mul
    B s mul sub
  fP T 14 get mul
    C s mul sub
  fP T 15 get mul
    D s mul sub
]
/T cgfx3d 1 get def
[
  /s T 0 get T 1 get add T 2 get add T 3 get add def
  s A mul
  s B mul
  s C mul
  s D mul
  /s T 4 get T 5 get add T 6 get add T 7 get add def
  s A mul
  s B mul
  s C mul
  s D mul
  /s T 8 get T 9 get add T 10 get add T 11 get add def
  s A mul
  s B mul
  s C mul
  s D mul
  /s T 12 get T 13 get add T 14 get add T 15 get add def
  s A mul
  s B mul
  s C mul
  s D mul
]
  cgfx3d 2 get
] 
end
gset3d
} def

% - Drawing commands in 3D --------------------------

% P displayed = [x y w z] => [X Y W] -> [X/W Y/W]

/render {
8 dict begin
aload pop
/v3 exch def
/v2 exch def
/v1 exch def
/v0 exch def
/T display-matrix def
/x
  T 0 get v0 mul 
  T 1 get v1 mul add
  T 2 get v2 mul add
  T 3 get v3 mul add
def
/y 
  T 4 get v0 mul 
  T 5 get v1 mul add
  T 6 get v2 mul add
  T 7 get v3 mul add
def
/w 
  T 8 get v0 mul 
  T 9 get v1 mul add
  T 10 get v2 mul add
  T 11 get v3 mul add
def
w 0 eq {
  (Perspective: division by zero!) ==
  quit
} if
x w div
y w div
end
} def

%  x y z -> x y
/transformto2d {
[ 4 1 roll 1 ] ctm3d transform3d render 
} def

/cpt3d 4 array def
/lm3d 4 array def

% cpt3d is a point in the "real" 3d world

% Should we build the current 3d path for reuse?

% x y z
/moveto3d {
1 [ 5 1 roll ] 
cgfx3d 0 get 
transform3d 
aload pop cpt3d astore 
render moveto
cpt3d aload pop lm3d astore pop
} def

% x y z

/lineto3d {
1 [ 5 1 roll ] 
cgfx3d 0 get 
transform3d 
aload pop cpt3d astore 
render lineto
} def

% x y z

/rmoveto3d {
0 [ 5 1 roll ] cgfx3d 0 get
transform3d 			% [dx dy dz 0]
dup 0 get cpt3d 0 get add	% [dx dy dz 0] x+dx
exch 
dup 1 get cpt3d 1 get add	% x+dx [dx dy dz dw] y+dy
exch
dup 2 get cpt3d 2 get add	% x+dx x+dy [dx dy dz dw] z+dz
exch				% x+dx y+dy z+dz [dx dy dz dw]
3 get cpt3d 3 get add		% x+dx x+dy z+dz w+dw
cpt3d astore
render moveto
cpt3d aload pop lm3d astore pop
} def

% x y z

/rlineto3d {
0 [ 5 1 roll ] cgfx3d 0 get
transform3d 		% [dx dy dz 0]
dup 0 get cpt3d 0 get add	% [dx dy dz 0] x+dx
exch 
dup 1 get cpt3d 1 get add	% x+dx [dx dy dz dw] y+dy
exch
dup 2 get cpt3d 2 get add	% x+dx x+dy [dx dy dz dw] z+dz
exch				% x+dx y+dy z+dz [dx dy dz dw]
3 get cpt3d 3 get add		% x+dx x+dy z+dz w+dw
cpt3d astore  
render lineto
} def

% x1 y1 z1 x2 y2 z2 x3 y3 z3 

/curveto3d { 16 dict begin
/z3 exch def
/y3 exch def
/x3 exch def
/z2 exch def
/y2 exch def
/x2 exch def
/z1 exch def
/y1 exch def
/x1 exch def
% F(t) 
/P0 cpt3d display-matrix project3d def
/P1 [x1 y1 z1 1] cgfx3d 0 get transform3d display-matrix project3d def
/w P0 2 get def
/c P1 2 get w div 1 sub def
/x0 P0 0 get w div def
/x1 P1 0 get w div def
/y0 P0 1 get w div def
/y1 P1 1 get w div def
x1 x0 c mul sub 
y1 y0 c mul sub 
[x3 y3 z3 1] cgfx3d 0 get transform3d aload pop cpt3d astore 
display-matrix project3d /P3 exch def
/P2 [x2 y2 z2 1] cgfx3d 0 get transform3d display-matrix project3d def
% We are assuming the display-matrix has images on { z = 0 }
/w P3 2 get def
/c P2 2 get w div 1 sub def
/x3 P3 0 get w div def
/x2 P2 0 get w div def
/y3 P3 1 get w div def
/y2 P2 1 get w div def
x2 x3 c mul sub 
y2 y3 c mul sub 
x3 y3
curveto
end } def

% - are the next two used? --------------------------------

% dP dQ Q

/dcurveto3d { 16 dict begin
/z3 exch def
/y3 exch def
/x3 exch def
/dz3 exch def
/dy3 exch def
/dx3 exch def
/dz0 exch def
/dy0 exch def
/dx0 exch def
/P0 cpt3d display-matrix project3d def
/dP0 [dx0 dy0 dz0 0] cgfx3d 0 get transform3d display-matrix project3d def
/w P0 3 get def 
% c = 1 - w'/w
/c 1 dP0 3 get w div sub def
  P0 0 get w div c mul dP0 0 get w div add
  P0 1 get w div c mul dP0 1 get w div add
[x3 y3 z3 1] cgfx3d 0 get transform3d aload pop cpt3d astore 
display-matrix project3d /P3 exch def
/dP3 [dx3 dy3 dz3 0] cgfx3d 0 get transform3d display-matrix project3d def
/w P3 3 get def
/c 1 dP3 3 get w div add def
  P3 0 get w div c mul dP3 0 get w div sub
  P3 1 get w div c mul dP3 1 get w div sub
  P3 0 get w div
  P3 1 get w div
curveto
end
} def

% dP dQ Q

/dcurveto { 8 dict begin
/y3 exch def
/x3 exch def
/dy3 exch def
/dx3 exch def
/dy0 exch def
/dx0 exch def
currentpoint dy0 add exch dx0 add exch
x3 dx3 sub y3 dy3 sub
x3 y3 
curveto
end } def

% - are the above two used? ----------------------------

/closepath3d {
closepath
lm3d aload pop cpt3d astore pop
} def

% - Conversion from 2d to 3D ---------------------------

/2d-path-convert {
[
  { % x y
    [ 3 1 roll 0 {moveto3d}]
  }
  { % x y
    [ 3 1 roll 0 {lineto3d}]
  }
  { % x1 y1 x2 y2 x3 y3
    [ 7 1 roll
    0 5 1 roll
    0 3 1 roll
    0 {curveto3d} ]
  }
  {
    [ {closepath3d} ]
  }
  pathforall
]
newpath
{
  aload pop exec
} forall
} def

% -----------------------------------------------

% For a simple currentpoint:

/mkpath3dDict 8 dict def

mkpath3dDict begin

/pathcount {
0 
{pop pop 
  pop 1 exit}
{pop pop 
  pop 1 exit}
{pop pop pop pop pop pop 
  pop 1 exit}
{ pop 1 exit}
pathforall
} def

/thereisacurrentpoint {
pathcount
0 gt
{true}
{false}
ifelse
} def

end

% ---------------------------------------------

% stack: t0 t1 N [parameters] /f 

/mkpath3d { load 
/f exch def
/pars exch def
12 dict begin
/N exch def
/t1 exch def
/t exch def

/h t1 t sub N div def
/h3 h 0.333333 mul def

pars t f aload pop
/velocity exch def
/position exch def
/p [ position aload pop 1 ] 
cgfx3d 0 get transform3d display-matrix project3d def
/v [ velocity aload pop 0 ] 
cgfx3d 0 get transform3d display-matrix project3d def

% p v = homogeneous position and velocity
% p/p[3] v/p[3] - (v[3]/p[3])(p/p[3]) = inhomogeneous ones
% = p/w v/w - c*p/w

/w p 3 get def
/c v 3 get w div def
thereisacurrentpoint {
  p 0 get w div p 1 get w div lineto
} {
  p 0 get w div p 1 get w div moveto
} ifelse

N {				% x y = currentpoint
  p 0 get 
    v 0 get 
    p 0 get c mul 
    sub 
    h3 mul 
  add 
  w div
  
  p 1 get 
    v 1 get 
    p 1 get c mul 
    sub 
    h3 mul 
  add
  w div

/t t h add def

pars t f aload pop
/velocity exch def
/position exch def
/p [ position aload pop 1 ] 
cgfx3d 0 get transform3d display-matrix project3d def
/v [ velocity aload pop 0 ] 
cgfx3d 0 get transform3d display-matrix project3d def
/w p 3 get def
/c v 3 get w div def

  p 0 get 
    v 0 get 
    p 0 get c mul 
    sub 
    h3 mul 
  sub 
  w div
  
  p 1 get 
    v 1 get 
    p 1 get c mul 
    sub 
    h3 mul 
  sub
  w div

p 0 get w div
p 1 get w div
curveto

} repeat
end % local dict
} def

% makes polygon out of control points

/mkcontrolpath3d { load
mkpath3dDict begin
1 dict begin
/f exch def
/pars exch def
/N exch def
/t1 exch def
/t exch def

/h t1 t sub N div def
/h3 h 0.333333 mul def

pars t f aload pop
/velocity exch def
/position exch def

position aload pop
thereisacurrentpoint {
	lineto3d
} {
	moveto3d
} ifelse

N {				% x y = currentpoint
% currentpoint pixel pop

position 0 get
velocity 0 get		% x dx/dt
h3 mul add
position 1 get
velocity 1 get		% y dy/dt
h3 mul add
position 2 get
velocity 2 get		% z dz/dt
h3 mul add

lineto3d

/t t h add def

pars t f aload pop
/velocity exch def
/position exch def

position 0 get
velocity 0 get 
h3 mul sub
position 1 get
velocity 1 get 
h3 mul sub
position 2 get
velocity 2 get 
h3 mul sub

lineto3d

position 0 get
position 1 get
position 2 get

lineto3d

} repeat
end % local dict
end % mkpath3d dict
} def

% -----------------------------------------------

% makes polygon from endpoints

/mkpolypath3d { load
/f exch def
/pars exch def
mkpath3dDict begin
1 dict begin
/N exch def
/t1 exch def
/t exch def

/h t1 t sub N div def
/h3 h 0.333333 mul def

pars t f aload pop
/velocity exch def
/position exch def

position aload pop
thereisacurrentpoint {
	lineto3d
} {
	moveto3d
} ifelse

N {				% x y = currentpoint
% currentpoint pixel pop

/t t h add def

pars t f aload pop
/velocity exch def
/position exch def

position 0 get
position 1 get
position 2 get
lineto3d

} repeat
end % local dict
end % mkpath3d dict
} def

% ---------------------------------------------

% length width

/plainarrow3d {
5 dict begin
/shaftwidth exch def
/arrowlength exch def
/headwidth shaftwidth 3 mul def
/headlength headwidth def
/shaftlength arrowlength shaftwidth 2.5 mul sub def
0 0 0 moveto3d
0 shaftwidth 0.5 mul 0 lineto3d
% shaftlength 0 0 rlineto3d
shaftlength shaftwidth 0.5 mul 0 lineto3d
arrowlength headlength sub headwidth 0.5 mul 0 lineto3d
arrowlength 0 0 lineto3d
arrowlength headlength sub headwidth -0.5 mul 0 lineto3d
shaftlength shaftwidth -0.5 mul 0 lineto3d
0 shaftwidth -0.5 mul 0 lineto3d
0 0 0 lineto3d
end
} def

% length width

/plainarrowtail3d {
5 dict begin
/shaftwidth exch def
/arrowlength exch def
0 0 0 moveto3d
0 shaftwidth 0.5 mul 0 lineto3d
arrowlength 0 0 rlineto3d
0 shaftwidth neg 0 rlineto3d
arrowlength neg 0 0 rlineto3d
0 0 0 lineto3d
end
} def

% --- shading ------------------------------------------------------------------

% all the shade input routines have as one argument a number between -1 and 1
% the result of a calculation of the dot-product of two unit vectors

% linear interpolation: s [a b] -> a + (b-a)*t

/lshade { % s [a b]
exch 1 add 2 div 	% t in [0 1]
% [a b] t
exch aload 0 get		% t a b a
4 1 roll 				% a t a b
sub mul sub			% a - t(a-b)
} def

%  # in [-1 1] & coefficient array [A B C D]: 
% A etc = control points, A = min, D = max
% 1 = facing towards, -1 = facing away from light
% x -> (x+1)/2 = 0.5(x+1) takes [-1, 1] -> [0, 1]
% evaluate by Horner's method

/shade {                             % t [array]
exch                                 % [array] t
1 add 0.5 mul 	                     % a t now in [0 1]
1 1 index sub                        % a t s=1-t
dup dup mul                          % a t s s^2
dup 2 index mul                      % a t s s^2 s^3
5 -1 roll aload pop                  % t s s^2 s^3 a0 a1 a2 a3=P0
7 index mul                          % t s s^2 s^3 a0 a1 a2 a3.t
exch                                 % t s s^2 s^3 a0 a1 a3.t a2
7 -1 roll                            % t s^2 s^3 a0 a1 a3.t a2 s
mul 3 mul add                        % t s^2 s^3 a0 a1 a3.t+3.a2.s=P1
5 index mul                          % t s^2 s^3 a0 a1 P1.t
exch                                 % t s^2 s^3 a0 P1.t a1
5 -1 roll                            % t s^3 a0 P1.t a1 s^2
mul 3 mul add                        % t s^3 a0 P1.t+3.a1.s^2=P2
4 -1 roll mul                        % s^3 a0 P2.t
3 1 roll mul add                     % P2.t + a0.s^3=P3
} def

% t y=[ y0 y1 ... yn ]
/bernstein { % t y 
  % constants y n t s=1-t
  % variables k C P
  dup length % t y n+1
  1 sub      % t y n
  3 -1 roll 1 % y n t 1
  1 index sub % y n t s
  % constants in place
  1           % y n t s k
  3 index 3 index mul % y n t s k C=nt
  5 index 0 get       % y n t s k C P=y0
  5 index {           % y n t s k C P
    % P -> s.P + C.y[k]
    % C -> C.t.(n-k)/(k+1) 
    % k -> k+1
    3 index mul       % y n t s k C P.s
    1 index           % y n t s k C P.s C
    7 index           % y n t s k C P.s C y 
    4 index get mul add  % y n t s k C P.s+C.y[k]=new P
    3 1 roll          % y n t s P* k C
    5 index           % y n t s P* k C n
    2 index sub mul   % y n t s P* k C.(n-k)
    1 index 1 add div % y n t s P* k C.(n-k)/(k+1)
    4 index mul       % y n t s P* k C*
    3 1 roll 1 add    % y n t s C* P* k*
    3 1 roll          % y n t s k* C* P*
  } repeat
  7 1 roll 6 { pop } repeat
} def

% shading: s in [-1 1] and y a Bernstein array B -> t -> B(t)
/bshade { exch 
1 add 2 div 
exch bernstein
} def

% ---------------------------------------------------------------------------------

% input: [pars] /fcn s0 s1 t0 t1 ns nt
% the fcn: [pars] s t -> f_{pars}(s, t)
% output: a polygonal surface of faces [ normal-fcn triangle ]

/mksurface {
16 dict begin
/nt exch def
/ns exch def
/t1 exch def
/t0 exch def
/s1 exch def
/s0 exch def
/ds s1 s0 sub ns div def
/dt t1 t0 sub nt div def
/f exch cvx def
/pars exch def
/P [
  /s s0 def
  ns 1 add {
    [
      /t t0 def
      nt 1 add {
        pars s t f
        /t t dt add def
      } repeat
    ]
    /s s ds add def
  } repeat
] def
% P[i][j] = f(s0 + i.ds, t0 + j.dt)
[
  0 1 ns 1 sub {
    /i exch def
    0 1 nt 1 sub {
      /j exch def
      % an array of triangles (i, j, 0) + (i, j, 1) 
      % dividing the rectangles in two
      /P00 P i get j get def
      /P10 P i 1 add get j get def
      /P01 P i get j 1 add get def
      /P11 P i 1 add get j 1 add get def
      % normal
      /Q P10 P00 vector-sub P01 P00 vector-sub cross-product def
      /r Q vector-length def
      r 0 ne {
        [
          [ Q aload pop Q P10 dot-product neg ]
          % array of pointers to three vertices
          [ P00 P10 P01 ]
        ] 
      } if
      /Q P01 P11 vector-sub P10 P11 vector-sub cross-product def
      /r Q vector-length def
      r 0 ne {
        [
          [ Q aload pop Q P01 dot-product neg ]
          % array of pointers to three vertices
          [ P10 P11 P01 ]
        ]
      } if
    } for
  } for
]
end
} def

% an array of vertices 
% traversed according to right hand rule
% output normalized

/normal-function {
2 dict begin
/a exch def
/n 
  a 1 get a 0 get vector-sub 
  a 2 get a 1 get vector-sub 
  cross-product 
def
/r n 0 get dup mul n 1 get dup mul add n 2 get dup mul add sqrt def
r 0 gt {
  /n [ n 0 get r div n 1 get r div n 2 get r div ] def
  [
    n aload pop
    a 0 get n dot-product neg
  ]
}{ [] } ifelse
end
} def

% --- light ------------------------------------------------

% should be part of the graphics environment

/set-light { /light-source exch def } def

/get-virtual-light {
  light-source cgfx3d 1 get transform3d
} def


 
%%EndProlog
gsave
%lanindL2 START  20000505
/lanind 1 def
/lantex [(G) (E) (S) (F) (I) (J) (M)] def
/showde {0 lanind eq {show} {pop} ifelse} bind def
/showen {1 lanind eq {show} {pop} ifelse} bind def
/showes {3 lanind eq {show} {pop} ifelse} bind def
/showfr {2 lanind eq {show} {pop} ifelse} bind def
/showit {4 lanind eq {show} {pop} ifelse} bind def
/showjp {5 lanind eq {show} {pop} ifelse} bind def
/showm  {6 lanind eq {show} {pop} ifelse} bind def
 
/lanindg where {pop /lanind1 lanindg def /lanind2 lanindg def}
               {/lanind1 1 def /lanind2 1 def} ifelse

/lanind lanind1 def
%lanind1 1 lanind2 {/lanind exch def %output showpage

%ps3d.inc

gsave

72 90 translate

250 -7 moveto
6 /Times-Roman FS
(DE421-8N) show

0 0 translate	
0 0 moveto
(XYZ) show 

0.01 MM 0.01 MM scale
15 setlinewidth
0 0  moveto 5400 0 rlineto 0 4000 rlineto -5400 0 rlineto
closepath stroke

grestore
gsave

72 90 translate

/fakt 2540 4 div def

%/MM {72 25.4 div mul} def
%0.01 MM dup scale

0.01 MM dup scale

1500 00 translate

/xs 300 def /ys xs def /d2 xs 2 div def /d8 xs 8 div def
/ymax 5000 def
/xmin 180 def
/xd 270 def
/yd 270 def
/xsd xs xd sub 0.5 mul def
/ysd xs xd sub 0.5 mul def

/fakt 1800 25.4 mul 72 div def

1 0 0 setrgbcolor

[0 0 5 fakt mul 1 ] set-eye

[0 1 0] 30 rotate3d

%15 setlinewidth
0 1 0 setrgbcolor
%0 0 0 moveto3d 10 fakt mul 0 0 rlineto3d 
%               0 06 fakt mul 0 rlineto3d
%              -10 fakt mul 0 0 rlineto3d
%closepath stroke

15 setlinewidth
1 0 0 setrgbcolor
0 0 0 moveto3d 5400 0 0 rlineto3d
               0 4000 0 rlineto3d
              -5400 0 0 rlineto3d
closepath stroke


0 setgray

20 setlinewidth

/xtr 825 def /ytr 250 def
%xtr ytr 0 translate3d

%3x rgbcmy
/id 1 8 div def
/rijn 81 array def %for intermediate storage
/gijn 81 array def /bijn 81 array def

%/kmax 0 def %left and right
/n -1 def
/k 0 def
%0 1 kmax {/k exch def %k=0,1 %size
       /xaddr k xs 7 mul mul 2000 sub def
       /yaddr 000 def
%       xaddr yaddr 0 translate3d
        1000 -2000 0 translate3d
%       [0 1 0] -45 rotate3d

/xchart 0 def
/lmin xchart 4 idiv def
/lmax lmin def
lmin 1 lmax {/l exch def %l=0,lmax
             /xadd 0 def
             /yadd 0 def
          
%for intermediate storage of l=0,lmax
0 1 01 {/jchart exch def %jchart=0,1
        /xchartj l jchart 3 mul add def
0 1 08 {/j exch def %j=0,7
        /im 8 j sub def
jchart 1 im {/i exch def %i=0,8
        /ia 1 id j mul sub def
        /argb ia def /brgb ia i id mul sub def
        xchartj 0 eq {/r argb def /g brgb def /b brgb def} if
        xchartj 1 eq {/r argb def /g argb def /b brgb def} if
        xchartj 2 eq {/r brgb def /g argb def /b brgb def} if
        xchartj 3 eq {/r brgb def /g argb def /b argb def} if
        xchartj 4 eq {/r brgb def /g brgb def /b argb def} if
        xchartj 5 eq {/r argb def /g brgb def /b argb def} if
        jchart 0 eq {/in i j add def /jn j def}
                    {/in j def /jn i j add def} ifelse
                     rijn in 9 mul jn add r put
                     gijn in 9 mul jn add g put
                     bijn in 9 mul jn add b put
        } for %i=0,7
        } for %j=0,8
        } for %jchart=0,1
        
%for output of l=0,lmax

%        0   1   2   3   4   5   6   7   8
/xchar [(A) (B) (C) (D) (E) (F) (G) (H) (I)] def

TS
/xa xmin xadd add def
/ya ymax yadd sub def
0.5 0.5 0.5 setrgbcolor
xa xsd sub ya xs add xsd sub 0 moveto3d
xs 9 mul 0 0 rlineto3d
0 xs 9 mul neg 0 rlineto3d
xs 9 mul neg 0 0 rlineto3d
closepath fill

0 1 08 {/j exch def %j=0,8
0 1 08 {/i exch def %i=0,8
        /r rijn i j 9 mul add get def
        /g gijn i j 9 mul add get def
        /b bijn i j 9 mul add get def
        
        /xa xmin xs j mul add xadd add def %k 0 eq {xsd add} if def
        /ya ymax xs i mul sub yadd sub def %k 0 eq {ysd add} if def
        
        r g b setrgbcolor
        xa ya xd dup rec3d fill %k 0 eq {xd} {xs} ifelse dup rec3d fill
        0 setgray 
        i 0 eq {xa xd 0.3 mul add ya yd 1.2 mul add 0 moveto3d xchar j get show} if
        j 0 eq {xa xd 0.8 mul sub ya yd 0.3 mul add 0 moveto3d i cvishow} if
        } for %i=0,8
        } for %j=0,8

        } for %l=0,lmax
        
%        [0 1 0] 45 rotate3d
%        xadd neg yadd neg 0 translate3d
       
%        } for %k=0,1
        
xtr neg ytr neg 0 translate3d
        
showpage

%%Trailer


%%EndDocument
EndEPSF grestore gsave

BeginEPSF
219 MM 080 MM add 008 MM translate %80 MM Breite von TestStreifen
  10 /Times-ISOL1 FS  53 MM 1 MM moveto () show 1 1 scale -77 21 MM sub -91 translate
%%BeginDocument: Bild 29 Teststreifen Ueberlaenge

%line 509

%%EndDocument
EndEPSF grestore gsave

BeginEPSF
-0.0 MM -0.0 MM translate %xy-Verschiebung Rechteckrahmen nach innen%

%%BeginDocument: Bild 30 %Rechteckrahmen

%line 519
%!PS-Adobe-3.0 EPSF-3.0 Frame arround with Internet text DG02 20070101
%%BoundingBox: 0 0 598 845

%%EndProlog
gsave

/lanind 1 def
/lantex [(G) (E) (S) (N) (I) (J) (M)] def
/showde {0 lanind eq {show} {pop} ifelse} bind def
/showen {1 lanind eq {show} {pop} ifelse} bind def
/showes {2 lanind eq {show} {pop} ifelse} bind def
/showfr {3 lanind eq {show} {pop} ifelse} bind def
/showit {4 lanind eq {show} {pop} ifelse} bind def
/showjp {5 lanind eq {show} {pop} ifelse} bind def
/showea {1 lanind le {show} {pop} ifelse} bind def

/lanind1 01 def /lanind2 01 def /lanindd 01 def
/colorm1 00 def /colorm2 00 def /colormd 01 def
/deintp1 00 def /deintp2 00 def /deintpd 01 def
/xcolor1 03 def /xcolor2 03 def /xcolord 01 def
/xchart1 00 def /xchart2 00 def /xchartd 01 def
/pchart1 00 def /pchart2 00 def /pchartd 01 def
/colsep1 00 def /colsep2 00 def /colsepd 01 def
/pmetam1 00 def /pmetam2 00 def /pmetamd 01 def

/lanindf where {pop /lanind1 lanindf def /lanind2 lanindf def
                    /lanindd laninddf def} if
/colormf where {pop /colorm1 colormf def /colorm2 colormf def
                    /colormd colormdf def} if
/deintpf where {pop /deintp1 deintpf def /deintp2 deintpf def
                    /deintpd deintpdf def} if
/xcolorf where {pop /xcolor1 xcolorf def /xcolor2 xcolorf def
                    /xcolord xcolordf def} if
/xchartf where {pop /xchart1 xchartf def /xchart2 xchartf def
                    /xchartd xchartdf def
                    /xchartm xchart2f xchart1f sub 1 add def}
               {/xchartm 1 def} ifelse
/xchart3f where {pop /xchart3 xchart3f def}
                {/xchart3 1 def} ifelse
/xchart4f where {pop /xchart4 xchart4f def}
                {/xchart4 0 def} ifelse
/pchartf where {pop /pchart1 pchartf def /pchart2 pchartf def
                    /pchartd pchartdf def} if
/colsepf where {pop /colsep1 colsepf def /colsep2 colsepf def
                    /colsepd colsepdf def} if
/pmetamf where {pop /pmetam1 pmetamf def /pmetam2 pmetamf def
                    /pmetamd pmetamdf def} if

/lanind lanind1 def %
/colorm colorm1 def %
/deintp deintp1 def %
/xcolor xcolor1 def %
/xchart xchart1 def %
/pchart pchart1 def %
/colsep colsep1 def %
/pmetam pmetam1 def %

/GSS$ where {pop /LSS$ GSS$ def}
            {/LSS$ (1) def} ifelse
/GSC$ where {pop /LSC$ GSC$ def}
            {/LSC$ (N) def} ifelse
/GSX$ where {pop /LSX$ GSX$ def}
            {/LSX$ (0) def} ifelse
/GSY$ where {pop /LSY$ GSY$ def}
            {/LSY$ (0) def} ifelse
/GEX$ where {pop /LEX$ GEX$ def}
            {/LEX$ (P.PS./PDF) def} ifelse
/GEY$ where {pop /LEY$ GEY$ def}
            {/LEY$ (P.DAT) def} ifelse
/IMES 0 def
/i*ptrsc 0 def

gsave

0 setgray

1.0 1.0  scale

0.0 MM 0.0 MM translate

0.15 MM setlinewidth

/x 20 array def
/y 20 array def
/d 20 array def

/x [000 296 296 000  002 294 294 002  005 291 291 005 %speziell
    006 290 290 006  008 288 288 008 ] def
/y [000 000 210 210  002 002 208 208  005 005 205 205 %speziell
    006 006 204 204  008 008 202 202 ] def
/d [060 017 -60 -17  058 015 -58 -15  056 013 -56 -13
    054 011 -54 -11  052 009 -52 -09 ] def

colorm 0 eq deintp 0 eq and {/Txx (d) def  /Fxx (d) def} if %colorm=0, deintp=0
colorm 0 eq deintp 1 eq and {/Txx (e) def  /Fxx (e) def} if %colorm=0, deintp=1
colorm 1 eq deintp 0 eq and {/Txx (dd) def /Fxx (d) def} if %colorm=1, deintp=0
colorm 1 eq deintp 1 eq and {/Txx (de) def /Fxx (e) def} if %colorm=1, deintp=1
xchart 0 eq {/Txx (-) def /Fxx (-) def} if

xchart 1 ge {%xchart>=1

/i0 12 def
/i1 i0 1 add def /i2 i0 2 add def /i3 i0 3 add def
2.5 MM /Times-ISOL1 FS
x i0 get MM 40 MM add y i0 get MM 1 MM sub moveto
lanind cvishow (-) show
colorm cvishow
deintp cvishow
xcolor cvishow
xchart cvishow
pchart cvishow
colsep cvishow (-F) show pmetam cvishow

} if %xchart>=1

/xt 1 def
xchart 1 eq {/xt 1 def} if

xt 0 eq {%xt=0,1 ifelse

/i0 12 def
/i1 i0 1 add def /i2 i0 2 add def /i3 i0 3 add def
2.5 MM /Times-ISOL1 FS
x i0 get MM 110 MM add y i0 get MM 1 MM sub moveto
(http://130.149.60.45/~farbmetrik/DE42/DE42) show
colorm cvishow deintp cvishow
colorm 0 eq {(N) show} {(F) show} ifelse (P.PDF  & ) show
(http://130.149.60.45/~farbmetrik/DE42/DE42) show
colorm cvishow deintp cvishow
colorm 0 eq {(N) show} {(F) show} ifelse (P.TXT  & ) show
(http://130.149.60.45/~farbmetrik/DE42/DE42.HTM) show

} %xt=0

{ %xt=1
/xlu 017 MM def /ylu 017 MM def
/xro 279 MM def /yro 193 MM def
/xlo 017 MM def /ylo 193 MM def
/xru 279 MM def /yru 017 MM def

xlu 8 MM sub ylu moveto  16 MM 0 rlineto stroke
xlu ylu 8 MM sub moveto 0  16 MM rlineto stroke
xro 8 MM add yro moveto -16 MM 0 rlineto stroke
xro yro 8 MM add moveto 0 -16 MM rlineto stroke

xru 8 MM sub yru moveto  16 MM 0 rlineto stroke
xru yru 8 MM sub moveto 0  16 MM rlineto stroke
xlo 8 MM add ylo moveto -16 MM 0 rlineto stroke
xlo ylo 8 MM add moveto 0 -16 MM rlineto stroke

1 2 7 {/i exch def %Zentrierkreise
xlu ylu i MM 0 360 arc stroke
xro yro i MM 0 360 arc stroke
xru yru i MM 0 360 arc stroke
xlo ylo i MM 0 360 arc stroke
      } for %i

12 4 16 {/i exch def /i0 i def %i=0,16
%0 4 16 {/i exch def /i0 i def %i=0,16
        /i1 i0 1 add def /i2 i0 2 add def /i3 i0 3 add def

i 16 eq {0.30 MM setlinewidth} {0.15 MM setlinewidth} ifelse

0 setgray
x i0 get MM y i0 get MM moveto x i1 get MM y i1 get MM lineto
x i2 get MM y i2 get MM lineto x i3 get MM y i3 get MM lineto
x i0 get MM y i0 get MM lineto stroke

i 16 eq {6 /Times-ISOL1 FS
         /x00 67 def /xdif 32 def /y0o 202.3 def /y0u 6.3 def
         /x0l 6.1 def /x0r 288 def /y00 22 def /ydif 32 def
         x00 xdif 0 mul add MM y0o MM moveto (V) show
         x00 xdif 0 mul add MM y0u MM moveto (C) show
         x00 xdif 1 mul add MM y0o MM moveto (L) show
         x00 xdif 1 mul add MM y0u MM moveto (M) show
         x00 xdif 2 mul add MM y0o MM moveto (O) show
         x00 xdif 2 mul add MM y0u MM moveto (Y) show
         x00 xdif 3 mul add MM y0o MM moveto (Y) show
         x00 xdif 3 mul add MM y0u MM moveto (O) show
         x00 xdif 4 mul add MM y0o MM moveto (M) show
         x00 xdif 4 mul add MM y0u MM moveto (L) show
         x00 xdif 5 mul add MM y0o MM moveto (C) show
         x00 xdif 5 mul add MM y0u MM moveto (V) show

         x0l MM y00 ydif 0 mul add MM moveto (V) show
         x0r MM y00 ydif 0 mul add MM moveto (C) show
         x0l MM y00 ydif 1 mul add MM moveto (L) show
         x0r MM y00 ydif 1 mul add MM moveto (M) show
         x0l MM y00 ydif 2 mul add MM moveto (O) show
         x0r MM y00 ydif 2 mul add MM moveto (Y) show
         x0l MM y00 ydif 3 mul add MM moveto (Y) show
         x0r MM y00 ydif 3 mul add MM moveto (O) show
         x0l MM y00 ydif 4 mul add MM moveto (M) show
         x0r MM y00 ydif 4 mul add MM moveto (L) show
         x0l MM y00 ydif 5 mul add MM moveto (C) show
         x0r MM y00 ydif 5 mul add MM moveto (V) show
        } if

       } for %i=0,16

0 1 10 {/j0 exch def /j1 j0 1 add def %j0

         j0 0 eq {tzccmy0* setcmykcolor} if
         j0 1 eq {0 setgray} if
         j0 2 eq {tzmcmy0* setcmykcolor} if
         j0 3 eq {0 setgray} if
         j0 4 eq {tzycmy0* setcmykcolor} if
         j0 5 eq {0 setgray} if
         j0 6 eq {tzocmy0* setcmykcolor} if
         j0 7 eq {0 setgray} if
         j0 8 eq {tzlcmy0* setcmykcolor} if
         j0 9 eq {0 setgray} if
         j0 10 eq {tzvcmy0* setcmykcolor} if

12 4 16 {/i exch def /i0 i def %i=0,16
%0 4 16 {/i exch def /i0 i def %i=0,16
        /i1 i0 1 add def /i2 i0 2 add def /i3 i0 3 add def

i 16 eq {0.30 MM setlinewidth} {0.15 MM setlinewidth} ifelse

x i0 get d i0 get add 16 j0 mul add MM y i0 get MM moveto
x i0 get d i0 get add 16 j1 mul add MM y i0 get MM lineto stroke

x i1 get MM y i1 get d i1 get add 16 j0 mul add MM moveto
x i1 get MM y i1 get d i1 get add 16 j1 mul add MM lineto stroke

x i2 get d i2 get add 16 j0 mul sub MM y i2 get MM moveto
x i2 get d i2 get add 16 j1 mul sub MM y i2 get MM lineto stroke

x i3 get MM y i3 get d i3 get add 16 j0 mul sub MM moveto
x i3 get MM y i3 get d i3 get add 16 j1 mul sub MM lineto stroke

       } for %i=0,16

       } for %j0

0.15 MM setlinewidth
/s 7 MM def /s1 8 MM def /s5 36 MM def
16 1 20 {/j exch def /j0 j 16 sub def %j=16,20
         /ix0 xlu  8 MM add j0 7 MM mul add def /iy0 ylu 8 MM sub def

0 1 3 {/ij exch def %ij=0,3

 ij 0 eq {/ix0 xlu  8 MM add j0 7 MM mul add def /iy0 ylu 8 MM sub def} if
 ij 1 eq {/ix0 xru 43 MM sub j0 7 MM mul add def /iy0 yru 8 MM sub def} if
 ij 2 eq {/ix0 xlo  8 MM add j0 7 MM mul add def /iy0 ylo 1 MM add def} if
 ij 3 eq {/ix0 xro 43 MM sub j0 7 MM mul add def /iy0 yro 1 MM add def} if

i*ptrsc 0 eq i*ptrsc 2 eq or {%i*ptrsc=0,2 cmy0* setcmykcolor
              j 16 eq {tzan j get dup dup 0 setcmykcolor
                       ix0 0.5 MM sub iy0 0.5 MM sub s5 s1 rec fill} if
              tzan j get dup dup 0 setcmykcolor
              ix0 iy0 s s  rec fill
             } if %i*ptrsc=0,2

i*ptrsc 1 eq i*ptrsc 3 eq or {%i*ptrsc=1,3 www* setrgbcolor
              j 16 eq {1 tzan j get 1 sub dup dup setrgbcolor %N
                       ix0 0.5 MM sub iy0 0.5 MM sub s5 s1 rec fill} if
              1 tzan j get sub dup dup setrgbcolor %N
              ix0 iy0 s s  rec fill
             } if %i*ptrsc=1,3

i*ptrsc 4 eq i*ptrsc 5 eq or {%i*ptrsc=4,5
  [/CIEBasedABC <<    %Farbraum und Grenzen fuer D65
  /RangeABC [0 100 -128 127 -128 127]
  /DecodeABC [{16 add 116 div} bind {500 div} bind {200 div} bind]
  /MatrixABC [1 1 1 1 0 0 0 0 -1]
  /DecodeLMN
    [{dup 6 29 div ge {dup dup mul mul}
     {4 29 div sub 108 841 div mul} ifelse 0.9505 mul} bind
     {dup 6 29 div ge {dup dup mul mul}
     {4 29 div sub 108 841 div mul} ifelse} bind
     {dup 6 29 div ge {dup dup mul mul}
     {4 29 div sub 108 841 div mul} ifelse 1.0890 mul} bind]
    /WhitePoint  [0.9505 1 1.089]                %CIEXYZ fuer D65
 >>] setcolorspace

 j 16 eq {tznLAB* 0 get tzwLAB* 0 get tznLAB* 0 get sub 0.25 j0 mul mul add
          tznLAB* 1 get tzwLAB* 1 get tznLAB* 1 get sub 0.25 j0 mul mul add
          tznLAB* 2 get tzwLAB* 2 get tznLAB* 2 get sub 0.25 j0 mul mul add
          setcolor %N
          ix0 0.5 MM sub iy0 0.5 MM sub s5 s1 rec fill} if
          tznLAB* 0 get tzwLAB* 0 get tznLAB* 0 get sub 0.25 j0 mul mul add
          tznLAB* 1 get tzwLAB* 1 get tznLAB* 1 get sub 0.25 j0 mul mul add
          tznLAB* 2 get tzwLAB* 2 get tznLAB* 2 get sub 0.25 j0 mul mul add
          setcolor %N
          ix0 iy0 s s  rec fill
             } if %i*ptrsc=4,5

i*ptrsc 6 eq {%i*ptrsc=6 000n* setcmykcolor
              j 16 eq {0 0 0 tzan j get setcmykcolor
                       ix0 0.5 MM sub iy0 0.5 MM sub s5 s1 rec fill} if
              0 0 0 tzan j get setcmykcolor
              ix0 iy0 s s  rec fill
             } if %i*ptrsc=6

i*ptrsc 7 eq {%i*ptrsc=7 w* setgray
              j 16 eq {1 tzan j get sub setgray
                       ix0 0.5 MM sub iy0 0.5 MM sub s5 s1 rec fill} if
              1 tzan j get sub setgray
              ix0 iy0 s s  rec fill
             } if %i*ptrsc=7

      } for %ij=0,3

        } for %j=16,20

0 setgray
018 MM 008.2 MM moveto 6 /Times-Roman FS (-8) show
018 MM 006.2 MM moveto 6 /Times-Roman FS (-6) show

276 MM 008.2 MM moveto 6 /Times-Roman FS (-8) show
276 MM 006.2 MM moveto 6 /Times-Roman FS (-6) show

018 MM 202.2 MM moveto 6 /Times-Roman FS (-8) show
018 MM 204.2 MM moveto 6 /Times-Roman FS (-6) show

276 MM 202.2 MM moveto 6 /Times-Roman FS (-8) show
276 MM 204.2 MM moveto 6 /Times-Roman FS (-6) show

/TELi0 8 array def
/TELi1 8 array def
/TELi  8 array def
/TELi0 [(P60) (P55) (P50) (P45) (P40) (P35) (P30) (P25)] def %7 illumin.
/TELi1 [(D65) (D50) (P40) (A00) (E00) (C00) (P00) (Q00)] def %7 illumin.

/xchart8 1 def %xchart8=0: Pxx, xchart8=1: Dxx
0 1 7 {/i exch def %i=0,7
xchart8 0 eq {%xchart8=0
              TELi i TELi0 i get put
             }%xchart8=0
             {%xchart8=1
              TELi i TELi1 i get put
             } ifelse %xchart8=1
       } for %i=0,7

0 setgray
12 /Times-ISOL1 FS
61 MM 13.5 MM  moveto
(TUB\255Pr\374fvorlage DE42; ) showde                           %0DE42X-Y 0000#
(TUB\255test chart DE42; ) showen                               %1DE42X-Y 0000#
(gr\341fico TUB\255DE42; ) showes                               %2DE42X-Y 0000#
(TUB\255test graphique DE42; ) showfr                           %3DE42X-Y 0000#
(grafico TUB\255DE42; ) showit                                  %4DE42X-Y 0000#
(TUB\255test chart DE42; ) showjp                               %5DE42X-Y 0000#

xchart4 0 eq {%xchart4=0
12 /Times-ISOL1 FS
( Komplement\344re ) showde
( complementary ) showea
12 /TimesI-ISOL1 FS
(RGB) show
12 /Times-ISOL1 FS
(\255Ger\344tefarben ) showde
( device colours) showea
} if %xchart4=0

61 MM 09.5 MM  moveto
xchart4 0 eq {%xchart4=0
12 /Times-ISOL1 FS
(Tests in Umfeldern Grau, Schwarz, Weiss, Cyan, Rot) showde
(tests in surrounds grey, black, white, cyan, red) showea
             } if %xchart4=0

xchart4 1 eq {
12 /Times-ISOL1 FS
(Chromatische Pr\374fvorlage) showde                            %0DE42X-Y 0300#
(chromatic test chart) showen                                   %1DE42X-Y 0300#
(test crom\341tico gr\341fico) showes                           %2DE42X-Y 0300#
(chromatic graphique de test) showfr                            %3DE42X-Y 0300#
(prova cromatica grafico) showit                                %4DE42X-Y 0300#
(chromatic test chart) showjp                                   %5DE42X-Y 0300#
12 /TimesI-ISOL1 FS
( RGB) show
             } if

xchart4 2 eq {
12 /Times-ISOL1 FS
(Chromatische Pr\374fvorlage) showde                            %0DE42X-Y 0400#
(chromatic test chart) showen                                   %1DE42X-Y 0400#
(test crom\341tico gr\341fico) showes                           %2DE42X-Y 0400#
(chromatic graphique de test) showfr                            %3DE42X-Y 0400#
(prova cromatica grafico) showit                                %4DE42X-Y 0400#
(chromatic test chart) showjp                                   %5DE42X-Y 0400#
12 /TimesI-ISOL1 FS
( CMY) show
             } if

xchart 1 ge {%xchart>=1
12 /Times-ISOL1 FS
(, 3D=) show colorm cvishow
(, de=) show deintp cvishow

12 /TimesI-ISOL1 FS
xchart5f 0 eq {(, sRGB) show} if
xchart5f 1 eq {(, cmyk) show} if
xchart5f 2 eq {(, cmy0)  show} if
xchart5f 3 eq {(, cmyk) show} if
colorm 1 eq {(*) show} if
} if %xchart>=1

12 /Times-ISOL1 FS
170 MM 13 MM moveto
(Eingabe: ) showde                                              %0DE42X-Y 0500#
(input: ) showen                                                %1DE42X-Y 0500#
(entrada: ) showes                                              %2DE42X-Y 0500#
(entr\351e: ) showfr                                            %3DE42X-Y 0500#
(immettere: ) showit                                            %4DE42X-Y 0500#
(input: ) showjp                                                %5DE42X-Y 0500#
12 /TimesI-ISOL1 FS
(w/rgb/cmyk -> ) show
xchart xchart3 lt {(w/rgb/cmyk) show
                  } if
xchart xchart3 ge {%xchart>=xchart3
                   (rgb) show
                  } if %xchart>=xchart3

10 /Times-ISOL1 FS
0 -2 rmoveto Txx show 0 2 rmoveto
12 /Times-ISOL1 FS

12 /Times-ISOL1 FS
170 MM 9 MM moveto
(Ausgabe: ) showde                                              %0DE42X-Y 0600#
(output: ) showen                                               %1DE42X-Y 0600#
(salida: ) showes                                               %2DE42X-Y 0600#
(sortie: ) showfr                                               %3DE42X-Y 0600#
(uscita: ) showit                                               %4DE42X-Y 0600#
(output: ) showjp                                               %5DE42X-Y 0600#

%colorm=0,1!
12 /Times-ISOL1 FS
xchart 0 eq {%xchart=0,#0
             12 /Times-ISOL1 FS
(keine \304nderung) showde                                      %0DE42X-Y 0700#
(no change) showen                                              %1DE42X-Y 0700#
(ning\372n cambio) showes                                       %2DE42X-Y 0700#
(aucun changement) showfr                                       %3DE42X-Y 0700#
(nessun cambiamento) showit                                     %4DE42X-Y 0700#
(no change compared) showjp                                     %5DE42X-Y 0700#
            }%xchart=0

            {%xchart#0
             12 /Times-ISOL1 FS
             colorm 0 eq {%colorm=0
(Transfer nach ) showde                                         %0DE42X-Y 0800#
(transfer to ) showen                                           %1DE42X-Y 0800#
(transfiera a ) showes                                          %2DE42X-Y 0800#
(transf\351rer \340 ) showfr                                    %3DE42X-Y 0800#
(trasferire a ) showit                                          %4DE42X-Y 0800#
(transfer to ) showjp                                           %5DE42X-Y 0800#
                         }%colorm=0
                         {%colorm=1
(3D\255Linearisierung ) showde                                  %0DE42X-Y 0900#
(3D\255linearization to ) showen                                %1DE42X-Y 0900#
(3D\255linealizaci\363n a ) showes                              %2DE42X-Y 0900#
(linearisation 3D selon ) showfr                                %3DE42X-Y 0900#
(3D\255linearizzazione a ) showit                               %4DE42X-Y 0900#
(3D\255linearization to ) showjp                                %5DE42X-Y 0900#
                         } ifelse %colorm=1
12 /TimesI-ISOL1 FS
xchart5f 0 eq {(rgb)  show} if
xchart5f 1 eq {(cmyk) show} if
xchart5f 2 eq {(cmy0) show} if
xchart5f 3 eq {(cmyk) show} if
colorm 1 eq {(*) show} if
10 /Times-ISOL1 FS
0 -2 rmoveto Txx show 0 2 rmoveto
12 /Times-ISOL1 FS
} ifelse %xchart=0,#0

%0 setgray %end white and unvisible

12 /Times-ISOL1 FS

 62 MM 198.5 MM  moveto
(http://130.149.60.45/~farbmetrik/DE42/DE42L) show
(0) show
LSC$ show LEX$ show

%1 setgray %start white and unvisible
(; ) show
xchart 0 eq {
(Start\255Ausgabe) showde                                       %0DE42X-Y 1000#
(start output) showen                                           %1DE42X-Y 1000#
(comience salida) showes                                        %2DE42X-Y 1000#
(sortie de production) showfr                                   %3DE42X-Y 1000#
(cominciare l'uscita) showit                                    %4DE42X-Y 1000#
(start output) showjp                                           %5DE42X-Y 1000#
           } if
LSC$ (C) eq {
(Start\255Ausgabe) showde                                       %0DE42X-Y 1100#
(start output) showen                                           %1DE42X-Y 1100#
(comience salida) showes                                        %2DE42X-Y 1100#
(sortie de production) showfr                                   %3DE42X-Y 1100#
(cominciare l'uscita) showit                                    %4DE42X-Y 1100#
(start output) showjp                                           %5DE42X-Y 1100#
           } if
xchart 1 ge {%xchart>=1
colorm 0 eq {%colorm=0,1
(Transfer Ausgabe) showde                                       %0DE42X-Y 1200#
(transfer output) showen                                        %1DE42X-Y 1200#
(salida de transferencia) showes                                %2DE42X-Y 1200#
(sortie de transfert) showfr                                    %3DE42X-Y 1200#
(uscita di trasferimento) showit                                %4DE42X-Y 1200#
(transfer output) showjp                                        %5DE42X-Y 1200#
            }%colorm=0
            {%colorm=1
(3D\255Linearisierung) showde                                   %0DE42X-Y 1300#
(3D\255linearization) showen                                    %1DE42X-Y 1300#
(3D\255linealizaci\363n) showes                                 %2DE42X-Y 1300#
(linearisation 3D) showfr                                       %3DE42X-Y 1300#
(3D\255linearizzzazione) showit                                 %4DE42X-Y 1300#
(3D\255linearization) showjp                                    %5DE42X-Y 1300#
            } ifelse %colorm=0,1
            } if %xchart>=1

 62 MM 194 MM  moveto
LSC$ (N) eq LSC$ (C) eq or {
(N: Keine 3D\255Linearisierung (OL) ) showde                    %0DE42X-Y 1400#
(N: no 3D\255linearization (OL) ) showen                        %1DE42X-Y 1400#
(N: ninguna 3D\255linealizaci\363n (OL) ) showes                %2DE42X-Y 1400#
(N: aucun linearisation 3D (OL) ) showfr                        %3DE42X-Y 1400#
(N: nessun 3D\255linearizzazione (OL) ) showit                  %4DE42X-Y 1400#
(N: no 3D\255linearization (OL) ) showjp                        %5DE42X-Y 1400#

(in Datei (F) oder PS\255Startup (S)) showde                    %0DE42X-Y 1500#
(in file (F) or PS\255startup (S)) showen                       %1DE42X-Y 1500#
(en archivo (F) o PS\255startup (S)) showes                     %2DE42X-Y 1500#
(dans fichier (F) ou PS\255startup (S)) showfr                  %3DE42X-Y 1500#
(nel file (F) o PS\255startup (S)) showit                       %4DE42X-Y 1500#
(in file (F) or PS\255startup (S)) showjp                       %5DE42X-Y 1500#
           }
           {LSC$ show (: ) show
(3D\255Linearisierung) showde                                   %0DE42X-Y 1600#
(3D\255linearization) showen                                    %1DE42X-Y 1600#
(3D\255linealizaci\363n) showes                                 %2DE42X-Y 1600#
(linearisation 3D) showfr                                       %3DE42X-Y 1600#
(3D\255linearizzzazione) showit                                 %4DE42X-Y 1600#
(3D\255linearization) showjp                                    %5DE42X-Y 1600#
( DE42/DE42L) show
LSS$ show LSX$ show (0) show
LSC$ show LEY$ show
          } ifelse
LSC$ (F) eq {
( in Datei (F)) showde                                          %0DE42X-Y 1700#
( in file (F)) showen                                           %1DE42X-Y 1700#
( en archivo (F)) showes                                        %2DE42X-Y 1700#
( dans fichier (F)) showfr                                      %3DE42X-Y 1700#
( nel file (F)) showit                                          %4DE42X-Y 1700#
( in file (F)) showjp                                           %5DE42X-Y 1700#
           } if
LSC$ (S) eq {
( im Distiller Startup (S) Directory) showde                    %0DE42X-Y 1800#
( in Distiller Startup (S) Directory) showen                    %1DE42X-Y 1800#
( en el Distiller Startup (S) Directory) showes                 %2DE42X-Y 1800#
( dans le Distiller Startup (S) Directory) showfr               %3DE42X-Y 1800#
( nel Distiller Startup (S) Directory) showit                   %4DE42X-Y 1800#
( in Distiller Startup (S) Directory) showjp                    %5DE42X-Y 1800#
           } if
LSC$ (D) eq {
( in PS\255Device (D)) showde                                   %0DE42X-Y 1900#
( in PS\255device (D)) showen                                   %1DE42X-Y 1900#
( en el PS\255device (D)) showes                                %2DE42X-Y 1900#
( dans l'appareil PS (D)) showfr                                %3DE42X-Y 1900#
( nel PS\255dispositivo (D)) showit                             %4DE42X-Y 1900#
( in PS\255Device (D)) showjp                                   %5DE42X-Y 1900#
           } if
LSC$ (T) eq {
( im Distiller Startup (S) Directory) showde                    %0DE42X-Y 2000#
( in Distiller Startup (S) Directory) showen                    %1DE42X-Y 2000#
( en el Distiller Startup (S) Directory) showes                 %2DE42X-Y 2000#
( dans le Distiller Startup (S) Directory) showfr               %3DE42X-Y 2000#
( nel Distiller Startup (S) Directory) showit                   %4DE42X-Y 2000#
( in Distiller Startup (S) Directory) showjp                    %5DE42X-Y 2000#
           } if
LSC$ (E) eq {
( in PS\255Device (D)) showde                                   %0DE42X-Y 2100#
( in PS\255device (D)) showen                                   %1DE42X-Y 2100#
( en el PS\255device (D)) showes                                %2DE42X-Y 2100#
( dans appareil PS (D)) showfr                                  %3DE42X-Y 2100#
( nel PS\255dispositivo (D)) showit                             %4DE42X-Y 2100#
( in PS\255Device (D)) showjp                                   %5DE42X-Y 2100#
           } if
%0 setgray %end white and unvisible

(, Seite ) showde                                               %0DE42X-Y 2200#
(, page ) showen                                                %1DE42X-Y 2200#
(, p\341gina ) showes                                           %2DE42X-Y 2200#
(, page ) showfr                                                %3DE42X-Y 2200#
(, pagina ) showit                                              %4DE42X-Y 2200#
(, page ) showjp                                                %5DE42X-Y 2200#
xchart 1 add cvishow (/) show
xchartm cvishow

 16 MM 185 MM moveto
-90 rotate
(Siehe \344hnliche Dateien: ) showde                            %0DE42X-Y 2300#
(see similar files: ) showen                                    %1DE42X-Y 2300#
(vea archivos semejantes: ) showes                              %2DE42X-Y 2300#
(voir des fichiers similaires: ) showfr                         %3DE42X-Y 2300#
(vedere dei file simili: ) showit                               %4DE42X-Y 2300#
(see similar files: ) showjp                                    %5DE42X-Y 2300#
(http://130.149.60.45/~farbmetrik/DE42/DE42.HTM) show
%(0) show
%LSC$ show LEX$ show
90 rotate

 12 MM 185 MM moveto
-90 rotate
(Technische Information: ) showde                               %0DE42X-Y 2400#
(technical information: ) showen                                %1DE42X-Y 2400#
(informaci\363n t\351cnica: ) showes                            %2DE42X-Y 2400#
(informations techniques: ) showfr                              %3DE42X-Y 2400#
(informazioni tecniche: ) showit                                %4DE42X-Y 2400#
(technical information: ) showjp                                %5DE42X-Y 2400#
(http://www.ps.bam.de) show
( oder ) showde                                                 %0DE42X-Y 2500#
( or ) showen                                                   %1DE42X-Y 2500#
( o ) showes                                                    %2DE42X-Y 2500#
( ou ) showfr                                                   %3DE42X-Y 2500#
( o ) showit                                                    %4DE42X-Y 2500#
( or ) showjp                                                   %5DE42X-Y 2500#
(http://130.149.60.45/~farbmetrik) show
 90 rotate

281 MM 185 MM moveto
-90 rotate
(TUB\255Registrierung: 20180501\255DE42/DE42L) showde           %0DE42X-Y 2600#
(TUB registration: 20180501\255DE42/DE42L) showen               %1DE42X-Y 2600#
(TUB matr\355cula: 20180501\255DE42/DE42L) showes               %2DE42X-Y 2600#
(TUB enregistrement: 20180501\255DE42/DE42L) showfr             %3DE42X-Y 2600#
(TUB iscrizione: 20180501\255DE42/DE42L) showit                 %4DE42X-Y 2600#
(TUB registration: 20180501\255DE42/DE42L) showjp               %5DE42X-Y 2600#
(0) show
LSC$ show LEX$ show
90 rotate

281 MM 74 MM moveto
-90 rotate
(TUB\255Material: Code=rha4ta) showde                           %0DE42X-Y 2700#
(TUB material: code=rha4ta) showen                              %1DE42X-Y 2700#
(TUB material: code=rha4ta) showes                              %2DE42X-Y 2700#
(TUB mat\351riel: code=rha4ta) showfr                           %3DE42X-Y 2700#
(TUB materiale: code=rha4ta) showit                             %4DE42X-Y 2700#
(TUB material: code=rha4ta) showjp                              %5DE42X-Y 2700#
90 rotate

277 MM 185 MM moveto
-90 rotate
/cvishow {cvi 6 string cvs show} def
/cvsshow1 {10 mul cvi 0.1 mul 7 string cvs show} def

( Anwendung f\374r Messung ) showde                             %0DE42X-Y 2800#
( application for measurement ) showen                          %1DE42X-Y 2800#
( aplicaci\363n para la medida ) showes                         %2DE42X-Y 2800#
( application pour la mesure ) showfr                           %3DE42X-Y 2800#
( la domanda per la misura ) showit                             %4DE42X-Y 2800#
( application for measurement ) showjp                          %5DE42X-Y 2800#

xchart5f 0 eq {%xchart5f=0
(von Display-Ausgabe) showde                                    %0DE42X-Y 2900#
(of display output) showen                                      %1DE42X-Y 2900#
(de display output) showes                                      %2DE42X-Y 2900#
(de sortie sur \350cran) showfr                                 %3DE42X-Y 2900#
(di stampa di display) showit                                   %4DE42X-Y 2900#
(of display output) showjp                                      %5DE42X-Y 2900#
} if %xchart5f=0

xchart5f 1 eq xchart5f 2 eq or {%xchart5f=1,2
(von Offsetdruck\255Ausgabe) showde                             %0DE42X-Y 3000#
(of offset print output) showen                                 %1DE42X-Y 3000#
(salida en la impressi\363n offset) showes                      %2DE42X-Y 3000#
(des sorties sur offset) showfr                                 %3DE42X-Y 3000#
(uscita nella stampa di offset) showit                          %4DE42X-Y 3000#
(of offset print output) showjp                                 %5DE42X-Y 3000#
} if %xchart5f=1,2

xchart5f 3 eq {%xchart5f=3
(von Laserdrucker\255Ausgabe) showde                            %0DE42X-Y 3100#
(of laser printer output) showen                                %1DE42X-Y 3100#
(salida de impresora l\341ser) showes                           %2DE42X-Y 3100#
(des sorties sur imprimante laser) showfr                       %3DE42X-Y 3100#
(di uscita della stampante laser) showit                        %4DE42X-Y 3100#
(of laser printer output) showjp                                %5DE42X-Y 3100#
} if %xchart5f=3

xchart 1 ge {%xchart>=1
xchart5f 0 eq {%xchart5f=0
(, keine Separation) showde                                     %0DE42X-Y 3200#
(, no separation) showen                                        %1DE42X-Y 3200#
(, ninguna separaci\363n) showes                                %2DE42X-Y 3200#
(, aucune s\351paration) showfr                                 %3DE42X-Y 3200#
(, nessuna separazione) showit                                  %4DE42X-Y 3200#
(, no separation) showjp                                        %5DE42X-Y 3200#
} if %chart5f=0

xchart5f 1 ge {%xchart5f>=1
(, Separation) showde                                           %0DE42X-Y 3300#
(, separation) showen                                           %1DE42X-Y 3300#
(, separaci\363n) showes                                        %2DE42X-Y 3300#
(, s\351paration) showfr                                        %3DE42X-Y 3300#
(, separazione) showit                                          %4DE42X-Y 3300#
(, separation) showjp                                           %5DE42X-Y 3300#
xchart5f 1 eq xchart5f 3 eq or {(cmyn6) show} if
xchart5f 2 eq                  {(cmy0)  show} if
colorm 1 eq {(*) show} if
colsep 0 eq {( (CMYK))}{( (CMY0))} ifelse show
} if %xchart5f>=1

            } if %xchart>=1

IMES 1 eq LSC$ (N) ne and { %IMES=1
             (, Yr=) show Yre cvsshow1 (, XYZ) show
          } if %IMES=1
90 rotate

/i0 8 def
/i1 i0 1 add def /i2 i0 2 add def /i3 i0 3 add def
0.30 MM setlinewidth
0 setgray
x i0 get MM y i0 get MM moveto x i1 get MM y i1 get MM lineto
x i2 get MM y i2 get MM lineto x i3 get MM y i3 get MM lineto
x i0 get MM y i0 get MM lineto stroke

%/xlu1 013 MM def /ylu1 010 MM def
%/xro1 283 MM def /yro1 200 MM def
%/xlo1 013 MM def /ylo1 200 MM def
%/xru1 283 MM def /yru1 010 MM def

%xlu1 4 MM sub ylu1 moveto  8 MM 0 rlineto stroke
%xlu1 ylu1 4 MM sub moveto 0  8 MM rlineto stroke
%xro1 4 MM add yro1 moveto -8 MM 0 rlineto stroke
%xro1 yro1 4 MM add moveto 0 -8 MM rlineto stroke

%xru1 4 MM sub yru1 moveto  8 MM 0 rlineto stroke
%xru1 yru1 4 MM sub moveto 0  8 MM rlineto stroke
%xlo1 4 MM add ylo1 moveto -8 MM 0 rlineto stroke
%xlo1 ylo1 4 MM add moveto 0 -8 MM rlineto stroke
} ifelse %xt=1

grestore
gsave

%**********************************************************

%%Trailer

%%EndDocument
EndEPSF grestore gsave

showpage
grestore

%} for %colsepf=0,1

%} for %pchartf=0,0

%} for %xchartf=0,0

} for %xcolorf=0,1

%} for %deintpf=0,1

%} for %colormf=0,1

%} for %lanindf=0,0

%%Trailer