%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%  v 1.6
%  DraTex                                               %
%  Copyright (C) 1992 by Eitan M. Gurari                %
%                                                       %
% This program can redistributed and/or modified under  %
% the terms of the LaTeX Project Public License         %
% Distributed from CTAN archives in directory           %
% macros/latex/base/lppl.txt; either version 1 of the   %
% License, or (at your option) any later version.       %
%                                                       %
% However, you are allowed to modify this program       %
% without changing its name, if you modify its          %
% signature. Changes to the signature can be introduced %
% with a directive of the form                          %
%            \message{signature}                        %
%                                                       %
%                            gurari@cse.ohio-state.edu  %
%                http://www.cse.ohio-state.edu/~gurari  %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\expandafter\edef\csname :RestoreCatcodes\endcsname{%
   \catcode`\noexpand\noexpand\noexpand \^=\the\catcode`\^%
}
\catcode`\^=7
\expandafter\edef\csname :RestoreCatcodes\endcsname{%
   \csname :RestoreCatcodes\endcsname
   \catcode`\noexpand \_=\the\catcode`\_%
   \catcode`\noexpand :=\the\catcode`:%
   \catcode`\noexpand @=\the\catcode`@%
   \catcode`\noexpand /=\the\catcode`/%
   \catcode`\noexpand &=\the\catcode`&%
   \catcode`\noexpand \^^M=\the\catcode`\^^M%
   \catcode`\noexpand \^^I=\the\catcode`\^^I%
   \let\expandafter\noexpand
       \csname:RestoreCatcodes\endcsname=\noexpand\undefined}
\catcode`\:11  \catcode`\@11
   \let\:wlog\wlog \def\wlog#1{}
   \def\:wrn#1#2{\immediate\write\sixt@@n{--DraTeX warning--
      \ifcase #1
    DraTex.sty already loaded              
\or \string\Draw\space within \string\Draw 
\or Changing definition of \string#2      
\or No intersection points: #2            
\or Improper rotation of axes: #2         
\or (#2) in \string\DSeg\space is a point 
\fi}}
\def\:err#1#2{\errmessage{--DraTeX error-- \ifcase #1
     \string#2\space meaningless in three dimensions 
\or  \string#2\space meaningless in two dimensions   
\or  No \string\MarkLoc(#2)            
\or  \string#2 in three dimensions     
\or  Too many parameters in definition 
\or  \string\MoveFToOval(#2)? 
\fi}}
   \ifx\:Xunits\:undefined \else \:wrn0{} \fi
   \catcode`\ 9  \catcode`\^^M9 \catcode`\^^I9
      \def\:UBorder{0}
\newdimen\:LBorder \newdimen\:RBorder\chardef\:eight=8
\mathchardef\:cccvx=360
\newdimen\:mp    \:mp   0.1\p@
\newdimen\:mmp   \:mmp  0.01\p@
\newdimen\:mmmp  \:mmmp 0.001\p@
\newdimen\:XC    \:XC   90\p@
\newdimen\:CVXXX \:CVXXX180\p@
\newdimen\:CCCVX \:CCCVX\:cccvx\p@ \newdimen\:TeXLoc
\newbox\:box\newif\if:IIID  \newdimen\:Z   \newdimen\:Zunits
\newdimen\:Ex   \newdimen\:Ey  \newdimen\:Ez

\def\:AbsVal#1{ \ifdim#1<\z@-\fi #1 }
\def\:abs#1{\ifdim #1<\z@ #1-#1 \fi}
\def\:AbsDif#1#2#3{  #1#2   \advance#1  -#3
   \ifdim #1<\z@ #1-#1 \fi}
\def\:diff#1#2#3{ #1#2  \advance#1 -#3 }
\def\:average#1#2#3{
   #1#2  \advance#1  #3   \divide#1 \tw@}\def\:Opt#1#2#3#4{
   \def\:temp{
      \ifx      \:next\ifnum \def\:next{#3#1#4#2}
      \else\ifx \:next#1     \def\:next{#3}
      \else                  \def\:next{#3#1#4#2}\fi\fi \:next}
   \futurelet\:next\:temp}\def\Define#1{\:multid#1
   \:Opt(){\:Define#1}0}

\def\:DraCatCodes{\catcode`\ 9   \catcode`\^^M9
   \expandafter\ifx  \csname ;catcode\endcsname\relax %
   \expandafter\edef  \csname ;catcode\endcsname{%
        \catcode`;\the\catcode`\;}%
\fi            %
\catcode`;12 %
%
   \catcode`\^^I9  \catcode`\&13  \catcode`\~13 }

\def\:Define#1(#2){\begingroup  \:DraCatCodes  \::Define#1(#2)}

\def\::Define#1(#2)#3{\endgroup
   \let\:NextDefine\NextDefine
   \let\NextDefine\relax
   \ifcase#2\relax
      \def#1{#3}\or
      \:TxtPar\def#1(##1){#3}\or
         \:TxtPar\def#1(##1,##2){#3}\or
   \:TxtPar\def#1(##1,##2,##3){#3}\or
   \:TxtPar\def#1(##1,##2,##3,##4){#3}\or
   \:TxtPar\def#1(##1,##2,##3,##4,##5){#3}\or
   \:TxtPar\def#1(##1,##2,##3,##4,##5,##6){#3}\or
   \:TxtPar\def#1(##1,##2,##3,##4,##5,##6,##7){#3}\or
   \:TxtPar\def#1(##1,##2,##3,##4,##5,##6,##7,##8){#3}\or 
      \:TxtPar\def#1(##1,##2,##3,##4,##5,##6,##7,##8,##9){#3}\or
      \:err4{}\fi      \let\:TxtPar\relax  \:NextDefine}

\let\NextDefine\relax\let\:TxtPar\relax
\def\WarningOn{\def\:multid##1{
   \ifx ##1\:undefined \else \:wrn2##1\fi}}
\def\:gobble#1{}
\def\WarningOff{\let\:multid\:gobble}     \WarningOff
\Define\Indirect{\futurelet\:next\:Indirect}

\Define\:Indirect{\:theDoReg
   \ifx \:next<
      \def\:temp{\let\DoReg\:DoReg}
      \def\:next<##1>{\expandafter\:temp\csname :<##1>\endcsname}
   \else
      \def\:next##1<##2>{
         \expandafter\ifx \csname :<##2> \endcsname \relax
               \def\:next{##1}     \fi
\:indrwrn\Define     \:indrwrn\Object
\:indrwrn\Table      \:indrwrn\IntVar     \:indrwrn\DecVar 
         \def\:temp{\let\DoReg\:DoReg##1}
         \expandafter\:temp \csname :<##2> \endcsname}
   \fi      \:next}  \def\:indrwrn#1{    \def\:temp{#1}
   \ifx \:next\:temp \def\:wrn##1##2{\let\:wrn\::wrn} \fi}
\let\::wrn\:wrn 
\Define\:Hline{
   \setbox\:box\hbox{\vrule height0.5\:thickness
                    depth 0.5\:thickness width\:x}
   {\:d\:X \advance\:d \wd\:box
 \advance\:X -\:TeXLoc   \global\:TeXLoc\:d
 \vrule width\:X depth\z@ height\z@
 \raise \:Y \box\:box} }\Define\:Vline{
   \setbox\:box\hbox{\vrule width\:thickness
                 \ifdim \:y>\z@ height\:y  depth\z@
                 \else          height\z@  depth-\:y \fi}
   \advance\:X  -0.5\:thickness
   {\:d\:X \advance\:d \wd\:box
 \advance\:X -\:TeXLoc   \global\:TeXLoc\:d
 \vrule width\:X depth\z@ height\z@
 \raise \:Y \box\:box} }\Define\:MvTo(2){\:X#1\:Xunits \:Y#2\:Yunits}
\Define\:Mv(2){\advance\:X  #1\:Xunits
               \advance\:Y  #2\:Yunits}
\def\:DLn(#1,#2,{\:MvTo(#1,#2) \:LnTo(}\Define\:LnTo(2){
   \:x#1\:Xunits \advance\:x  -\:X
   \:y#2\:Yunits \advance\:y  -\:Y
   \:Ln(\:x\du,\:y\du) }\Define\:Ln(2){
   \:x#1\:Xunits \:y#2\:Yunits
   { \ifdim \:x<\z@
        \advance\:X \:x   \:x-\:x
        \advance\:Y \:y   \:y-\:y
     \fi
     \:yy\:AbsVal\:y
     \:dd\:yy \advance\:dd \:x
     \ifdim \:dd>\:mmmp
        \ifdim \:x>\:yy
           { \ifdim\:X<\:LBorder \global\:LBorder\:X\fi
\advance \:X  \:x
\ifdim \:X>\:RBorder \global\:RBorder\:X\fi\advance \:Y  0.5\:thickness
\ifdim \:Y>\:UBorder \xdef\:UBorder{\the\:Y} \fi
\advance \:Y  \:y
\ifdim \:Y>\:UBorder \xdef\:UBorder{\the\:Y} \fi }
           \let\:Yunitsy\:x  \let\:Xunitsx\:y  \let\:temp\:Hline
           \:dd0.6\:yy    \:divide\:dd\:x  
        \else
           { \advance \:X  -0.5\:thickness
\ifdim \:X<\:LBorder \global\:LBorder\:X \fi
\advance \:X  \:thickness
\advance \:X  \:x
\ifdim \:X>\:RBorder \global\:RBorder\:X\fi
\ifdim \:Y>\:UBorder \xdef\:UBorder{\the\:Y} \fi
\advance \:Y  \:y
\ifdim \:Y>\:UBorder \xdef\:UBorder{\the\:Y} \fi }
           \let\:Yunitsy\:y  \let\:Xunitsx\:x  \let\:temp\:Vline
           \:dd0.6\:x
\ifdim \:x>\:mmp    \:divide\:dd\:yy   \fi
        \fi
        \advance\:dd  0.4\p@
\:ragged\:Cons\:dd\:ragged
        \:HVLn
      \fi }
   \advance\:X  \:x   \advance\:Y  \:y}\Define\:HVLn{
   \:xx\:AbsVal\:Xunitsx  \:divide\:xx\:ragged
   \advance\:xx  0.99\p@   \:K\:InCons\:xx \relax
   \ifnum \:K>\z@
      \divide\:Xunitsx \:K  \advance\:K \@ne
      \divide\:Yunitsy \:K
   \else \:K\@ne  \fi  \:NextLn}


\Define\:NextLn{
   \ifnum\:K=\z@  \let\:NextLn\relax
   \else  { \:temp }  \advance\:K  \m@ne
      \advance\:X  \:x   \advance\:Y  \:y
   \fi   \:NextLn}\newdimen\:ragged

\Define\Ragged(1){    \:ragged#1\p@  \:ragged0.1\:ragged }
\Ragged(7.5)
\Define\PaintUnderCurve(4){{
   \:Z\:Y   \def\:next{\Curve(#1,#2,#3,#4)}
   \MoveToLoc(#1)  \:d\:X   \MoveToLoc(#4)
   \advance\:d -\:X
   \ifdim \:AbsVal\:d<\:mmp  \def\:next{}
   \else
      \def\:CrvLnTo(##1,##2){
         \:x \:X   \:y  \:Y    \:X\:DJ  \:Y\:yyyy
         \:xx\:X   \:dddd \:Y  \:X\:x  \:Y\:y
         { \advance\:Y  \:dddd   \divide\:Y \tw@
           \advance\:Z -\:Y
           \advance\:Y   0.5\:Z
           \:dddd  \:AbsVal \:Z  \:d\z@
           \def\:CrvLnTo{\:LnTo}
           \:yy\:Y  \:dd\:dddd  \:ddd\:dddd
           \::paint  }}
    \fi \:next       }}
\Define\DoCurve(1){ \let\:StopCurve\:SlowCurve
  \def\:CMv(##1){  \:x\:X \:y\:Y   \:MvTo(##1)
      \advance\:x -\:X   \advance\:y -\:Y
      \:xxx \:x    \:yyy\:y}
   \:DoCurve{\Curve(#1)}
   \let\:StopCurve\:FastCurve}

\def\:DoCurve#1(#2)#3{{\XSaveUnits
   \def\:next{#1}    \:MvTo(#2,#2)
   \:x\:AbsVal\:X  \:y\:Y  \:ddd\z@  \:length
   \:Z\:d   \:divide\:Z{1.41421\p@}
   \edef\:tempa{\the\:DoDist}   \global\:DoDist\z@
   \def\:CrvLnTo(##1){ \MarkLoc(1^)    \:CMv(##1)
      { \MarkLoc(2^)   \:ddd\z@    \:length
\:dd  \:DoDist  \global\advance\:DoDist  \:d
\:ddd \:DoDist  \:divide\:ddd\:Z
\DoReg\:InCons\:ddd  \:Z\DoReg\:Z

      \ifdim \:Z>\:dd
         \advance\:Z -\:DoDist
\advance\:dd -\:DoDist
\:divide\:Z\:dd
\advance\:X \:Cons\:Z\:xxx
\advance\:Y \:Cons\:Z\:yyy   \:DoRot 
         \def\:CrvLnTo{\:LnTo}
         \def\:OvalLn{\:Ln}  \XRecallUnits    #3 \fi}}
   \:next    \xdef\:DoDim{\:Cons\:DoDist}
   \global\:DoDist\:tempa     }
   \let\DoDim\:DoDim}

\newdimen\:DoDist\def\:DoRot{ \DSeg\RotateTo(1^,2^) }
\def\DoLine(#1,#2)(#3)#4{
   \MarkLoc($1)  \Move(#1,#2)
   \def\:next{   { \MarkLoc($2)
     \DSeg\RotateTo($1,$2)   \let\:DoRot\relax
     \edef\:RecallRagged{\the\:ragged} \MoveTo(#3,#3)
     \:x\:AbsVal\:X  \:y\:Y  \:ddd\z@  \:length
     \:ragged\:d   \divide\:ragged \tw@
     \DoCurve($1,$1,$2,$2)(#3)
        {\:ragged\:RecallRagged #4}  }
   \let\DoDim\:DoDim}  \:next }
\def\Table#1{\begingroup  \:DraCatCodes   \:multid#1
   \:DefineData#1}


\def\:DefineData#1#2{\endgroup
   \let\:temp~  \def~{\noexpand~}
   \edef#1{\noexpand\:DoPoly\expandafter\noexpand\csname
              :\string#1\endcsname}
   \expandafter\edef  \csname :\string#1\endcsname
       ##1{\noexpand\ifcase##1(#2)\noexpand\fi}
   \let~\:temp   \:DoNextPoly   \:DoNextPoly}

\def\:OR{\let\:or\or}  \:OR \catcode`\&13  \def&{)\noexpand\:or(}

\def\TableData{\begingroup  \:DraCatCodes  \:TableData}

\def\:TableData#1#2#3{\endgroup   \Table\:temp{#3}
   \:K\z@   \:J\z@    \def\:tempa(##1){\advance\:J \@ne }
   \:temp(0,999){\:tempa}    \let\:tempa&      \def\:temp{\def#1}
   \def&##1&{
      \ifnum  \:K<\:J
         \advance\:K \@ne
         \ifnum  \:K=\@ne   \def#1{#2(##1)}
         \else
            \:IIIexpandafter\:temp\expandafter{
               #1 & #2(##1) }
         \fi
      \else  \let\:next\relax \fi
      \:next}
   \let\:next&     &#3&&   \let&\:tempa }

\catcode`\&4  \def\:DoPoly#1(#2,#3)#4{
   \expandafter\let \csname :Back\the\:level\endcsname\:or
\expandafter\edef\csname :DoVars\the\:level\endcsname{
   \:DoB\the\:DoB}
\advance\:level  \@ne
   \:DoB#3  \advance\:DoB -#2
   \def\:PolyOr(##1){
      \ifnum  \:DoB=\z@  \:OR
      \else   #4(##1)   \advance\:DoB \m@ne    \fi}
   \:OR
   \def\:temp{\let\:or\:PolyOr #4}
   \:IIIexpandafter\:temp#1{#2}
   \advance\:level  \m@ne
\csname :DoVars\the\:level\endcsname
\def\:temp{\let\:or}
\expandafter\:temp\csname :Back\the\:level\endcsname }
\Define\PaintRect(2){\def\:next{{   \MarkLoc(^)
   \MoveToLoc(^) \Move( #1,0) \MarkLoc(^1) \Move(0,#2)
   \MarkLoc(^2)  \Move(-#1,0) \MarkLoc(^3)
   \PaintQuad(^,^1,^2,^3)        }}\:next}
\Define\PaintRectAt(4){\def\:next{{   \MoveTo(#1,#2)
   \:Ex#3\p@ \advance\:Ex -#1\p@
   \:Ey#4\p@ \advance\:Ey -#2\p@
   \PaintRect(\:Cons\:Ex,\:Cons\:Ey)}}
   \:next}\def\::paint{
   \ifdim \:d<\:ragged      \advance\:xx -\:X
      \:yyy\:Y \:xxx\:dddd
      \advance\:Y \:yy  \divide\:Y \tw@
      \:average\:dddd\:dd\:ddd
      \def\:next{\:brush(\:xx,\z@)\:Y\:yyy\:dddd\:xxx}
   \else  \divide\:d \tw@
      \:average\:x\:X\:xx
      \:average\:y\:Y\:yy
      \:average\:dddd\:dd\:ddd
   \fi   \:next}\Define\:paint{{   \:AbsDif\:d\:xx\:x
   \ifdim \:d<\:mmp  \let\::paint\relax
   \else
      \ifdim  \:y >\:yyy   \:dd\:y   \:y \:yyy   \:yyy \:dd  \fi
      \ifdim  \:yy>\:yyyy  \:dd\:yy  \:yy\:yyyy  \:yyyy\:dd  \fi
      \:AbsDif\:dd\:yyyy\:yyy      \:AbsDif\:ddd\:yy\:y
      \ifdim \:dd<\:ddd  \:dd\:ddd  \fi
      \ifdim \:d >\:dd   \:d\:dd  \fi
      \advance\:d \:d      \:diff\:dd\:y\:yyy
      \:diff\:ddd\:yy\:yyyy
      \advance\:y    -0.5\:dd    \:abs\:dd
      \advance\:yy   -0.5\:ddd   \:abs\:ddd
      \:X\:x  \:Y\:y
      \:average\:dddd\:dd\:ddd
      \def\:next{ \:lpaint \:rpaint }
   \fi
   \::paint }}

\Define\:lpaint{ { \:xx\:x  \:yy \:y  \:ddd\:dddd  \::paint} }
\Define\:rpaint{ { \:X \:x  \:Y  \:y  \:dd \:dddd  \::paint} }
\Define\PaintQuad(4){\def\:next{{\Units(1pt,1pt)
   \MoveToLoc(#1)  \:x  \:X  \:y  \:Y
   \MoveToLoc(#2)  \:xx \:X  \:yy \:Y
   \MoveToLoc(#3)  \:xxx\:X  \:yyy\:Y
   \MoveToLoc(#4)  \:xxxx  \:X  \:yyyy \:Y
   
   \:paintQuad  }}\:next}

\def\:paintQuad{{
   \:SetVal\:a\:x\:y\:xx\:yy\:xxxx\:yyyy
\:SetVal\:b\:xx\:yy\:xxx\:yyy\:x\:y
\:SetVal\:c\:xxx\:yyy\:xx\:yy\:xxxx\:yyyy
\:SetVal\:cc\:xxxx\:yyyy\:xxx\:yyy\:x\:y
\def\:A{\:a} \def\:B{\:b} \def\:C{\:c} \def\:D{\:cc}
\:sort\:B\:A
\:sort\:C\:B  \:sort\:B\:A
\:sort\:D\:C  \:sort\:C\:B  \:sort\:B\:A
\let\:temp\relax
\:IsTriang\:A\:B
\:IsTriang\:B\:C
\:IsTriang\:C\:D
\:temp  
   \:Quad\:A\:temp>   \:xxxx\:xx \:yyyy\:yy \:Z\:d
\:Quad\:D\:next<   
   \:PrePaint(\:xx,\:yy,\:d,\:xxxx,\:yyyy,\:Z)
   \:temp  \:next }}
\Define\:PrePaint(6){
   \:x#1 \:y#2 \:yyy#3 \:xx#4 \:yy#5 \:yyyy#6
   \:paint }\def\:Quad#1#2#3{
         \:GetVal#1\:x\:y0
   \:GetVal#1\:xx\:yy1
   \:GetVal#1\:xxx\:yyy2
   \ifdim \:xx#3\:xxx
      \:ddd\:xx   \:xx\:xxx   \:xxx\:ddd
      \:ddd\:yy   \:yy\:yyy   \:yyy\:ddd
   \fi
          \def#2{}
   \:diff\:dd\:xxx\:xx
   \ifdim \ifdim\:AbsVal\:dd<\:mp  \:yy=\:yyy   \else  \z@>\z@  \fi
      
      \:d\:yy
   \else
      \ifdim \:AbsVal\:dd>\:mp
         \:diff\:dd\:xxx\:x   \:diff\:ddd\:yyy\:y
         \:divide\:ddd\:dd    \:diff\:dd\:xx\:xxx
         \:ddd\:Cons\:ddd\:dd   \advance\:ddd \:yyy
         \:d\:ddd
      \else \:d\:yyy \fi
      \edef#2{  \noexpand\:PrePaint
         (\the\:x ,\the\:y ,\the\:y,
         \the\:xx,\the\:yy,\the\:d)    }
   \fi}\def\:SetVal#1#2#3#4#5#6#7{
   \edef#1{(\the#2,\the#3,\the#4,\the#5,\the#6,\the#7)}}

\def\:sort#1#2{
   \ifdim \:IIIexpandafter\:field#1 <
          \:IIIexpandafter\:field#2
      \let\:temp#1  \let#1#2  \let#2\:temp
   \fi  }

\Define\:field(6){#1}

\def\:GetVal#1#2#3{
   \:IIIexpandafter\::GetVal #1#2#3}

\def\::GetVal(#1,#2,#3,#4,#5,#6)#7#8#9{
      \ifcase #9 #7#1   #8#2\or #7#3   #8#4\or #7#5   #8#6 \fi}
\def\:IsTriang#1#2{
   \ifdim \:IIIexpandafter\:field#1 =
          \:IIIexpandafter\:field#2
      \ifdim \:IIIexpandafter\:fieldB#1 =
             \:IIIexpandafter\:fieldB#2
         \def\:temp{ \:FixTria }
   \fi \fi      }


\def\:FixTria{
   \edef\:temp{\:IIIexpandafter\:FrsII\:B}
   \ifdim \:IIIexpandafter\:field\:A =
          \:IIIexpandafter\:field\:B
      \ifdim \:IIIexpandafter\:fieldB\:A =
             \:IIIexpandafter\:fieldB\:B
          \edef\:temp{\:IIIexpandafter\:FrsII\:C}
   \fi\fi
   \edef\:A{\:IIIexpandafter\:FrsII\:A}
   \edef\:D{\:IIIexpandafter\:FrsII\:D}
   \edef\:temp{
      \def\noexpand\:a{(\:A,\:temp,\:D)}
      \def\noexpand\:b{(\:temp,\:A,\:D)}
      \def\noexpand\:c{\noexpand\:b}
      \def\noexpand\:cc{(\:D,\:A,\:temp)}}
   \:temp
   \def\:A{\:a}  \def\:B{\:b}  \def\:C{\:c}  \def\:D{\:cc}  }

\Define\:fieldB(6){#2}
\Define\:FrsII(6){#1,#2}
\def\:IIIexpandafter{\expandafter\expandafter\expandafter}

\Define\DrawRect(2){ \Line( #1,0) \Line(0, #2)
                     \Line(-#1,0) \Line(0,-#2)}

\Define\DrawRectAt(4){{
   \MoveTo(#1,#2) \LineTo(#3,#2) \LineTo(#3,#4)
   \LineTo(#1,#4) \LineTo(#1,#2)}}
\def\du#1{ \ifx#1\:Xunits   \else\ifx#1\:Yunits
      \else\ifx#1\:Zunits   \else #1
      \fi \fi \fi}
\let\:svdu=\du
\Define\XSaveUnits{
   \expandafter\edef\csname XRecallUnits\the\:level\endcsname{
      \:StoreUnits}
    \advance\:level  \@ne}

\Define\XRecallUnits{
   \advance\:level \m@ne
   \csname XRecallUnits\the\:level \endcsname}

\Define\SaveUnits{
   \edef\RecallUnits{ \:StoreUnits }  }

\Define\:StoreUnits{       \:Xunits \the\:Xunits
   \:Yunits \the\:Yunits \:Zunits \the\:Zunits
   \:Xunitsx\the\:Xunitsx \:Xunitsy\the\:Xunitsy
\:Yunitsx\the\:Yunitsx \:Yunitsy\the\:Yunitsy }
\Define\:SearchDir{
   \ifdim \:x<\z@  \:x-\:x  \:y-\:y
   \edef\:tempA{\advance\:ddd  \ifdim \:y<\z@ - \fi\:CVXXX}
\else         \def\:tempA{} \fi
\ifdim \:y<\z@
   \edef\:tempA{\:ddd-\:ddd \advance\:ddd  \:CCCVX \:tempA}
   \:y-\:y
\fi
\ifdim \:y>\:x
   \:ddd\:y \:y\:x \:x\:ddd
   \edef\:tempA{\advance\:ddd  -\:XC \:ddd-\:ddd \:tempA}
\fi
   \:divide\:y\:x  \:d57.29578\:y
   \:ddd\:d       \:sqr\:y  \:K  \@ne
   \Do(1,30){\advance\:K \tw@
      \:d-\:Cons\:y\:d  \:dd\:d  \divide\:dd \:K
      \advance\:ddd \:dd  }
   \advance\:ddd -0.49182\:dd
   \:tempA }\Define\Curve(4){\def\:next{{  \XSaveUnits \Units(1pt,1pt)
   \MoveToLoc(#1) \:DI \:X  \:DK \:Y
   \MoveToLoc(#2) \:ddd \:X  \:Ez \:Y
   \MoveToLoc(#3) \:dd\:X  \:Ey\:Y
   \MoveToLoc(#4) \:DJ\:X  \:yyyy\:Y   \:Curve    }}\:next}
\Define\:FastCurve{   \:AbsDif\:d\:DI\:ddd  \:AbsDif\:dddd\:DK\:Ez
   \advance\:d \:dddd
   \ifnum \:d<\:ragged
      \:AbsDif\:d\:DJ\:dd \:AbsDif\:dddd\:yyyy\:Ey
      \advance\:d \:dddd                     \fi}
\let\:StopCurve\:FastCurve
\Define\:SlowCurve{
   \:AbsDif\:d\:DI\:DJ  \:AbsDif\:dddd\:DK\:yyyy
   \advance\:d \:dddd                     }
\Define\:Curve{   \:StopCurve
   \ifnum \:d<\:ragged   \:X\:DI \:Y\:DK
                    \:CrvLnTo(\:Cons\:DJ,\:Cons\:yyyy)
   \def\:SubCurves{}  \fi
   \:SubCurves}

\def\:CrvLnTo{\:LnTo}\Define\:SubCurves{
   \:average\:yy\:DI\:ddd     \:average\:Ex\:DK\:Ez
   \:average\:ddd\:ddd\:dd    \:average\:Ez\:Ez\:Ey
   \:average\:dd\:dd\:DJ  \:average\:Ey\:Ey\:yyyy
   \:average\:Zunits\:yy\:ddd    \:average\:Vdirection\:Ex\:Ez
   \:average\:ddd\:ddd\:dd    \:average\:Ez\:Ez\:Ey
   \:average\:DL\:Zunits\:ddd  \:average\:xxxx\:Vdirection\:Ez
   { \:ddd \:yy  \:Ez \:Ex   \:dd\:Zunits
     \:Ey\:Vdirection \:DJ\:DL \:yyyy\:xxxx \:Curve }
   \:DI \:DL \:DK \:xxxx               \:Curve   }
\def\MoveToCurve[#1]{
   \Define\:BiSect(3){\MoveToLoc(##1)
      \CSeg[#1]\Move(##1,##2)
   \MarkLoc(##3) }\:MvToCrv}

\Define\:MvToCrv(4){  \:BiSect(#1,#2,:a) \:BiSect(#2,#3,:b)
   \:BiSect(#3,#4,:c) \:BiSect(:a,:b,:A) \:BiSect(:b,:c,:B)
   \:BiSect(:A,:B,:Q)}
\Define\:OvalDir(3){   \:CosSin{#3\p@}
   \:Zunits\p@   \:d#2\:Zunits   \:x\:Cons\:d\:x
   \:Zunits\p@   \:d#1\:Zunits   \:y\:Cons\:d\:y
   \:SearchDir   }\Define\DrawOval   (2){ \DrawOvalArc(#1,#2)(0,\:cccvx) }
\Define\PaintOval  (2){ \PaintOvalArc(#1,#2)(0,\:cccvx) }
\Define\DrawCircle (1){ \DrawOval(#1,#1) }
\Define\PaintCircle(1){ \PaintOval(#1,#1) }
\def\DrawOvalArc(#1,#2)(#3,#4){{
       \:xxxx#4\p@  \advance\:xxxx -#3\p@
       \ifdim \:xxxx=\z@ \else
   \let\:SinOne\:SinB  \:OvalDir(#1,#2,#3)  \:DJ\:ddd
\:OvalDir(#1,#2,#4)  \:diff\:DI\:ddd\:DJ
\ifdim\:DI<\z@ \advance\:DI  \:CCCVX \fi
\ifdim \:xxxx<\:CCCVX \else \:DI\:CCCVX \fi
\:InitOval(#1,#2)  \:CosSin\:DJ 
   \:xxxx\:x  \:yyyy\:y   \:xx\:X  \:yy\:Y
   \advance\:X \:Xx\:x  \advance\:X \:Yx\:y
   \advance\:Y \:Xy\:x  \advance\:Y \:Yy\:y
   \let\:Xunits\empty  \let\:Yunits\empty
   \Do(1,\:InCons\:DI){
      \:dd\:X  \:ddd\:Y  \:X\:xx  \:Y\:yy
      \:AdvOv\:xxx\:yyy\:xxxx\:yyyy
      \:X\:dd  \:Y\:ddd
      \advance\:xxx -\:X   \advance\:yyy -\:Y
      \:d\:AbsVal\:xxx
      \advance\:d  \:AbsVal\:yyy
      \ifdim \:d>\:ragged
         \:OvalLn(\:xxx,\:yyy)  \fi  }
   \:OvalDir(#1,#2,#4)    \:CosSin\:ddd
   \advance\:xx \:Xx\:x  \advance\:xx \:Yx\:y
   \advance\:yy \:Xy\:x  \advance\:yy \:Yy\:y
   \advance\:xx -\:X     \advance\:yy -\:Y
   \:OvalLn(\:xx,\:yy) \fi }}

\def\:OvalLn{\:Ln}\def\DoOvalArc(#1)(#2){   \:xx\:X  \:yy\:Y
   \def\:CMv(##1){  \:Mv(\:xxx,\:yyy)
      \:x\:xxx  \:y\:yyy}
   \:DoCurve{             \:X\:xx  \:Y\:yy
       \def\:DoRot{  \let\:Xunits\:XunitsReg
                     \let\:Yunits\:YunitsReg
                     \DSeg\RotateTo(1^,2^)     }
       \let\::OvalLn\:CrvLnTo
\Define\:OvalLn(2){ \:dd\:AbsVal####1
   \advance\:dd \:AbsVal####2 \:divide\:dd\:ragged
   \:J\:InCons\:dd  \advance\:J  \@ne
   \divide####1  \:J  \divide####2  \:J
   \Do(1,\:J){\::OvalLn(####1,####2)}}
       \DrawOvalArc(#1)(#2)}}
\def\NextTable{\begingroup  \:DraCatCodes \:NextTable}

\def\:NextTable#1{\endgroup
  \def\:DoNextPoly{#1\NextTable{}}}
\NextTable{}\def\:AdvOv#1#2#3#4{
   \:d\:CosOne#3 \advance\:d -\:SinOne#4
   #4\:CosOne#4    \advance#4     \:SinOne#3   #3\:d
   \divide#3 \:eight  \divide#4 \:eight
   #1\:X   #2\:Y
   \:d\:Xx#3  \advance\:d \:Yx#4  \advance#1  \:d
   \:d\:Xy#3  \advance\:d \:Yy#4  \advance#2  \:d  }

\def\:CosOne{7.99878}   \def\:SinB{0.13962}
\def\PaintOvalArc(#1,#2)(#3,#4){{ \ifdim #3\p@=#4\p@
                      \let\:next\relax  \else
   \:d\:AbsVal{#1\:Xunits} \advance\:d \:AbsVal{#2\:Yunits}
   \ifdim \:d<3\:ragged   \divide \:d \tw@   \PenSize(\:d)
\:Mv(-0.5\:d\du,0)  \:Ln(\:d\du,0)
   \else    \:InitOval(#1,#2)
      \MarkLoc(o$)   \RotateTo(#3) \MoveFToOval(#1,#2)
      \:Ex\:X  \:Ey\:Y   \edef\:FirstOvDir{\:Cons\:ddd\p@}
      \MoveToLoc(o$) \RotateTo(#4) \MoveFToOval(#1,#2)
      \:Ez \:X  \:Vdirection \:Y   \edef\:LastOvDir{\:Cons\:ddd\p@}
      \MoveToLoc(o$)
      \if:rotated
      \:Zunits\p@     \:Zunits#1\:Zunits
      \:xx\:Cons\:Zunits\:Xunitsx
      \:Zunits\p@     \:Zunits#2\:Zunits
      \:yy\:Cons\:Zunits\:Yunitsx
      \:x\:xx  \:y\:yy  \:ddd\z@  \:length
      \:ddd\:d  \:divide\:xx\:ddd   \:divide\:yy\:ddd
\else \:xx\p@  \:yy\z@   \fi
      \:AbsDif\:d{#3\p@}{#4\p@}
      \ifdim \:d>359\p@ \:Ez-\:Xx\:xx  \advance\:Ez -\:Yx\:yy
\:Vdirection-\:Xy\:xx  \advance\:Vdirection -\:Yy\:yy
\advance\:Ez \:X  \advance\:Vdirection \:Y
\:setpaint\:PaintOvOv<> 
      \else
         \:x\:xx \:y\:yy \:SearchDir
\:xxx\:FirstOvDir  \advance\:xxx -\:ddd
\ifdim \:xxx<\z@    \advance\:xxx \:CCCVX  \fi
\:yyy\:LastOvDir   \advance\:yyy -\:ddd
\ifdim \:yyy<\z@    \advance\:yyy \:CCCVX  \fi
\:J\z@
\ifdim \:xxx<\:yyy  \ifdim        \:yyy<\:CVXXX
            \:Pntovln\:FirstOvDir\:FirstOvDir\:LastOvDir
\else \ifdim  \:xxx>\:CVXXX
            \:Pntovln\:FirstOvDir\:FirstOvDir\:LastOvDir
\else \:yyy-\:yyy  \advance\:yyy \:CCCVX
      \ifdim  \:xxx<\:yyy
            \:setpaint\:PntLeftOvOv><  \:PntMovln\:FirstOvDir\:xx
      \else \:FxLx  \:setpaint\:PntLeftOvOv><  \:Pntmovln\:LastOvDir
\fi  \fi  \fi
\else               \ifdim        \:xxx<\:CVXXX
            { \:setpaint\:PaintOvOv<> }  \:FxLx  \:setpaint\:PntLeftOvOv><
\:Usrch  \:PaintMidOvLn\:LastOvDir\:FirstOvDir
\else \ifdim  \:yyy>\:CVXXX
            { \:FxLx \:setpaint\:PaintOvOv<>  } \:setpaint\:PntLeftOvOv><
 \:Dsrch  \:PaintMidOvLn\:LastOvDir\:FirstOvDir
\else \:xxx-\:xxx  \advance\:xxx \:CCCVX
      \ifdim  \:yyy<\:xxx
            \:setpaint\:PaintOvOv<>    \:PntMovln\:FirstOvDir\:xx
      \else
            \:FxLx  \:setpaint\:PaintOvOv<>   \:Pntmovln\:LastOvDir
\fi  \fi  \fi  \fi
   \fi \fi \fi}}\def\:setpaint#1#2#3{{\aftergroup#1
\:d\:Xx\:xx   \advance\:d \:Yx\:yy
\ifdim \:d<\z@  \aftergroup#3
\else           \aftergroup#2  \fi}}
\def\:FxLx{\:d\:Ex  \:Ex\:Ez  \:Ez\:d}

\def\:Pntovln#1{
   \let\:SinOne\:SinB     \:CosSin#1
   \:xxxx\:Ex  \:yyyy\:Ey  \:Z\z@
   \:PaintOvLn}

\def\:PntMovln{
   \:Dsrch  \:FxLx   \:xx\:ddd  \:PaintOvLn}

\def\:Pntmovln{
   \:Usrch  \:FxLx  \:xx\:ddd   \:PaintOvLn\:xx}
\def\:PaintMidOvLn#1#2{
   \:FxLx   \:xx\:ddd  \:PaintOvLn#1#2
   \:xxx\:Ez  \:yyy\:Vdirection
   \:ddd\:Xy\:x  \advance\:ddd \:Yy\:y  \advance\:ddd \:Y
   \:PaintSlice}

\def\:PntLeftOvOv{
   \:xx-\:xx  \:yy-\:yy  \:PaintOvOv}

\def\:Dsrch{      \def\:SinOne{-\:SinB}
   \:xx\:x  \:yy\:y   \:SearchDir
   \:x\:xx  \:y\:yy
   \:d\:Ey  \:Ey\:Vdirection  \:Vdirection\:d }

\def\:Usrch{
   \let\:SinOne\:SinB
   \:x\:xx  \:y\:yy   \:SearchDir
   \:x\:xx  \:y\:yy}\def\:PaintOvLn#1#2{
   \:diff\:dd\:Ey\:Vdirection  \:diff\:ddd\:Ex\:Ez
   \ifdim \:AbsVal\:ddd>\:mp
      \:divide\:dd\:ddd      \:d#2
      \advance\:d -#1
      \ifnum \:d<\z@  \advance\:d \:CCCVX  \fi
      \:DoB\:InCons\:d  \let\:next\:PntDo  \:next
   \fi}

\def\:PntDo{
   \ifnum\:DoB=\z@ \let\:next\relax
   \else
      \::AdvOv\:x\:y
      \ifdim \:d>\:ragged
         \:ddd\:xxx  \advance\:ddd -\:Ez
         \:ddd\:Cons\:dd\:ddd
         \advance\:ddd \:Vdirection  \:PaintSlice
      \fi
      \advance\:DoB \m@ne
   \fi  \:next}\Define\:PaintSlice{   \:AbsDif\:dddd\:yyy\:ddd
   \advance\:yyy \:ddd  \divide\:yyy \tw@
   { \advance\:dddd \:Z  \divide\:dddd \tw@
      \:X\:xxxx  \:Y\:yyy
      \:xx\:xxx  \advance\:xxx -\:xxxx
      \:d\z@
      \:yy\:Y  \:dd\:dddd  \:ddd\:dddd
      \::paint     }
   \:xxxx\:xxx  \:yyyy\:yyy  \:Z\:dddd    \:J\z@}
\def\::AdvOv#1#2{  \:AdvOv\:xxx\:yyy#1#2
   \:AbsDif\:d\:xxxx\:xxx       \advance\:J \@ne
   \ifnum \:J=\sixt@@n   \multiply\:d \@cclvi
   \fi }\def\:PaintOvOv#1{   \def\:hdir{#1}
   \:xxx\:Xx\:xx  \advance\:xxx \:Yx\:yy
   \:yyy\:Xy\:xx  \advance\:yyy \:Yy\:yy
   \advance\:xxx \:X   \advance\:yyy \:Y
   \:Z\z@  \:xxxx\:xxx  \:yyyy\:yyy
   \:x\:xx   \:y\:yy   \:DoB\z@   \:J\z@
   \let\:next\:scanOvOv  \:next }
\Define\:scanOvOv{  \advance\:DoB \@ne
   \advance\:J \@ne
   \:AbsDif\:d\:xxx\:Ez
   \ifdim \ifdim      \:xxx\:hdir\:Ez    -
          \else\ifdim \thr@@\:d<\:ragged -
          \else\ifnum \:DoB>358            -
          \fi \fi \fi                     \p@<\z@
      \:ddd\:yyyy  \advance\:ddd -0.5\:dddd
      \:yyy\:yyyy   \advance\:yyy   0.5\:dddd
      \:xxx\:Ez \:PaintSlice
      \let\:next\relax
   \else
     \:d\:xx \advance\:d -\:x
     \:xxx\:yy \advance\:xxx -\:y
     \ifdim -\:Xx\:d\:hdir\:Yx\:xxx
        \let\:SinOne\:SinB
        \::AdvOv\:xx\:yy
        \ifdim  \ifdim       \:d >\:ragged -
                \else \ifnum \:J>\sixt@@n -
                \fi\fi                      \p@<\z@
           \:J\z@  \def\:SinOne{-\:SinB}
           \:AdvOv\:dd\:ddd\:x\:y  \:PaintSlice  \fi
     \else
        \def\:SinOne{-\:SinB}
        \::AdvOv\:x\:y
        \ifdim  \ifdim       \:d >\:ragged -
                \else \ifnum \:J>\sixt@@n -
                \fi\fi                      \p@<\z@
           \:J\z@   \let\:SinOne\:SinB
           \:AdvOv\:dd\:ddd\:xx\:yy  \:PaintSlice  \fi
   \fi \fi
   \:next}\Define\SetBrush{\:Opt[]\:SetBrush{}}

\def\:SetBrush[#1](#2,#3)#4{    \def\:temp{#4}
   \ifx \:temp\empty
      \def\:brush{   \let\:Xunits\empty \let\:Yunits\empty
                     \:thickness\:dddd  \:Ln  }
   \else       \def\:BruShape{#4}
      \:dd#2\:Xunits      \:ddd#3\:Yunits
      \edef\:Grd{ \:dd\the\:dd  \:ddd\the\:ddd }
      \MarkLoc($$)  \def\:temp{#1}
\ifx \:temp\empty  \:X\z@  \:Y\z@
\else  \MoveTo(#1) \fi
\edef\:BrOrg{ \:x\the\:X  \:y\the\:Y }
\MoveToLoc($$)
      \def\:brush(##1,##2){ \::brush }  \fi  }

\SetBrush(,){}\def\::brush{{  \SetBrush(,){}
\let\:Xunits\:XunitsReg   \let\:Yunits\:YunitsReg
\advance\:Y -0.5\:dddd   \:yy\:Y
\advance\:yy \:dddd
\:BrOrg  \:Grd  \advance\:xx  \:X
\ifdim \:xx<\:X  \:d\:X \:X\:xx \:xx\:d  \fi
   \:GridPt\:X\:x\:dd
   \:GridPt\:Y\:y\:ddd            \:x\:X
   \:DoBrush       }}\Define\:DoBrush{
   \ifdim       \:Y>\:yy  \let\:DoBrush\relax
   \else \ifdim \:X>\:xx \advance\:Y \:ddd     \:X\:x
   \else { \:BruShape }  \advance\:X \:dd
   \fi  \fi  \:DoBrush  }\def\:GridPt#1#2#3{   \:xxxx#1
   \advance#1 -#2  \:divide#1#3
   #1\:InCons#1#3  \advance#1 #2
   \ifdim #1=\:xxxx
   \else  \ifdim \:xxxx>#2 \advance#1 #3 \fi \fi  }
\newcount\:IntId    \edef\:IntCount{0\space}
\newcount\:DecId    \edef\:DecCount{0\space}

\Define\:NewCount{\alloc@ 0\count \countdef \insc@unt }
\Define\:NewDimen{\alloc@ 1\dimen \dimendef \insc@unt }

\def\:NewVar#1#2#3#4#5{ \:multid#1
   \def\:temp{    \csname \string#4\the#4\endcsname\z@
      \edef#1{\noexpand#3  \csname \string#4\the#4\endcsname}}
   \def\:next{  \xdef#5{\the#4\space}   #2#1 \def\:next{\global\let}
     \expandafter\:next \csname \string#4\the#4\endcsname#1  \:temp }
   \advance#4  \@ne
   \ifnum #4 > #5 \expandafter\:next \else \expandafter\:temp \fi }

\def\IntVar#1{\:NewVar#1\:NewCount\:IntOp\:IntId\:IntCount}
\def\DecVar#1{\:NewVar#1\:NewDimen\:DecOp\:DecId\:DecCount}


\DecVar\Q  \DecVar\R   \DecVar\T
\IntVar\I  \IntVar\J   \IntVar\K
\def\WriteVal#1{\immediate\write\sixt@@n{...\string#1=#1;}}

\newdimen\:X   \newdimen\:Y
\newdimen\:x   \newdimen\:y   \newdimen\:d
\newdimen\:xx  \newdimen\:yy  \newdimen\:dd
\newdimen\:xxx \newdimen\:yyy \newdimen\:ddd
\newdimen\:xxxx\newdimen\:yyyy\newdimen\:dddd
\newcount\:J  \newcount\:K
\newdimen\:DI   \newdimen\:DJ
\newdimen\:DK   \newdimen\:DL   \newtoks\:t
\def\:IntFromPt#1#2{
   \:d#2\relax
   \advance\:d  \ifdim\:d<-0.5\p@-\fi  0.5\p@
   #1\:d    \divide#1  65536\relax}
\def\:temp{\catcode`\p12  \catcode`\t12}
\def\:Cons{\catcode`\p11  \catcode`\t11}
\:temp  \def\:Frac#1pt{#1}
        \def\:rnd#1.#2pt{#1}  \:Cons

\def\:Cons#1{\expandafter\:Frac\the#1}
\def\:sqr#1{#1\expandafter\:Frac\the#1#1}
\def\:InCons#1{\expandafter\:rnd\the#1}\def\:Val#1{#1;}
\let\Val\:Val\def\:IntOp#1#2{\csname :Op#2\endcsname#1}
\let\:SvIntOp\:IntOp
\def\:PreIntOp{\let\:IntOp\empty
   \let\Val\empty}
\def\:PostIntOp{\let\:IntOp\:SvIntOp
   \let\Val\:Val}

\expandafter\def\csname :Op;\endcsname#1{ \the#1}
\expandafter\def\csname :Op=\endcsname#1#2;{
   \:PreIntOp#1#2\:PostIntOp}
\expandafter\def\csname :Op+\endcsname#1#2;{
   \:PreIntOp\advance #1  #2\:PostIntOp}
\expandafter\def\csname :Op-\endcsname#1#2;{
   \:PreIntOp\advance #1  -#2\:PostIntOp}
\expandafter\def\csname :Op/\endcsname#1#2;{
   \:PreIntOp\divide#1   #2\:PostIntOp}
\expandafter\def\csname :Op*\endcsname#1#2;{
   \:PreIntOp\multiply#1   #2\:PostIntOp}
\def\:DecOp#1#2{ \csname :xOp#2\endcsname#1}
\let\:SvDecOp\:DecOp
\def\:PreDecOp{\let\:IntOp\the \def\:DecOp{\:Cons}
   \let\Val\empty   \let\:du\empty}
\def\:PostDecOp{\let\:IntOp\:SvIntOp \let\Val\:Val
   \let\:DecOp\:SvDecOp  \let\:du\::du  }

\def\::du#1{\p@
   \ifx#1\p@ \let\:temp\relax
   \else     \def\:temp{\du{#1}}
   \fi\:temp}                    \:PostDecOp

\expandafter\def\csname :xOp;\endcsname#1{ \:Cons#1}
\expandafter\def\csname :Op[\endcsname#1#2];{
   \:PreDecOp \:dd#2\p@  \:IntFromPt#1\:dd
                                 \:PostDecOp  }
\expandafter\def\csname :xOp=\endcsname#1#2;{
   \:PreDecOp#1#2\p@\:PostDecOp               }
\expandafter\def\csname :xOp(\endcsname#1#2){
   \:PreDecOp#1#2\p@\:PostDecOp               }
\expandafter\def\csname :xOp+\endcsname#1#2;{
   \:PreDecOp\advance #1  #2\p@\:PostDecOp  }
\expandafter\def\csname :xOp-\endcsname#1#2;{
   \:PreDecOp\advance #1  -#2\p@\:PostDecOp }
\expandafter\def\csname :xOp*\endcsname#1#2;{
   \:PreDecOp#1 #2#1\:PostDecOp              }
\expandafter\def\csname :xOp/\endcsname#1#2;{
   \:PreDecOp  \:divide#1{#2\p@}  \:PostDecOp }
\let\IF\ifnum    \let\THEN\relax
\let\ELSE\else   \let\FI\fi

\def\EqText(#1,#2){
   \z@=\z@ \fi  \def\:temp{#1}
                \def\:next{#2}    \ifx \:temp\:next }

\def\:IfInt#1(#2,#3){ \z@=\z@ \fi
   \:IntOp\:K=#2;  \:IntOp\:J=#3; \ifnum  \:K#1\:J }

\def\:IfDim#1(#2,#3){ \z@=\z@ \fi
   \:DecOp\:d=#2;  \:DecOp\:dd=#3; \ifdim  \:d#1\:dd }

\def\EqInt{ \:IfInt= }  \def\LtInt{ \:IfInt< }
\def\GtInt{ \:IfInt> }

\def\EqDec{ \:IfDim= }  \def\LtDec{ \:IfDim< }
\def\GtDec{ \:IfDim> } \def\Do(#1,#2)#3{
   \expandafter\let
   \csname :Back\the\:level\endcsname\:Do
\expandafter\edef\csname :DoVars\the\:level\endcsname{
   \DoReg\the\DoReg \:DoB\the\:DoB}
\advance\:level  \@ne
   \DoReg#1  \:DoB#2  \relax
   \ifnum \DoReg<\:DoB
      \def\:Do{\ifnum \DoReg>\:DoB
                  \let\:Do\relax
               \else  #3\advance\DoReg  \@ne \fi
               \:Do}
   \else
      \def\:Do{\ifnum \DoReg<\:DoB
                  \let\:Do\relax
               \else  #3\advance\DoReg \m@ne  \fi
               \:Do}
   \fi  \def\:nextdo{ \:Do \advance\:level  \m@ne
\csname :DoVars\the\:level\endcsname
\def\:temp{\let\:Do}
\expandafter\:temp\csname
   :Back\the\:level\endcsname  } \:nextdo}

\let\:Do\relax

\newcount\DoReg   \let\:DoReg\DoReg       \newcount\:DoB
 \newcount\:level\def\::divide#1{   \:DI\:DK   \:dddd\:DL
   \advance\:DI -\:Cons\:dddd#1
   \:IntFromPt\:J\:dddd  \advance\:dddd -\:J\p@
   \multiply\:J  \@M   \:IntFromPt\:K{\@M\:dddd}
   \advance\:J \:K     \:dddd\@M\p@
   \divide\:dddd \:J   \advance#1 \:Cons\:DI\:dddd  }

\def\:divide#1#2{   \:DK#1   \:DL#2   #1\z@
   \::divide#1  \::divide#1  \::divide#1
   \::divide#1  \::divide#1  }
\def\:Sqrt#1{ \ifdim #1<\:mmp   #1\z@  \else
   \:dd#1   \divide\:dd \tw@
   \def\::Sqrt{  \:ddd#1
      \:divide\:ddd\:dd      \:AbsDif\:d\:dd\:ddd
      \advance\:dd \:ddd   \divide\:dd \tw@
      \ifdim  \:d < \:mmmp
         \let\::Sqrt\relax  \fi
      \::Sqrt}
   \::Sqrt   #1\:dd   \fi }\Define\:length{
   \:dd \:AbsVal \:ddd
   \:abs\:x  \:abs\:y
   \ifdim \:dd<\:x \:dd\:x \fi
   \ifdim \:dd<\:y \:dd\:y \fi
   \ifdim \:dd>\:mp
      \:divide\:x\:dd     \:sqr\:x
      \:divide\:y\:dd     \:sqr\:y
      \:divide\:ddd\:dd   \:sqr\:ddd
      \advance\:x  \:y  \advance\:x \:ddd
      \:y\:dd  \:Sqrt\:x  \:d\:Cons\:x\:y
   \else \:d\:dd \fi}\Define\:distance(2){\MarkLoc(@^)
   \MoveToLoc(#1)  \:x \:X  \:y \:Y  \:ddd\:Z
   \MoveToLoc(#2)
   \advance\:x  -\:X   \advance\:y  -\:Y
   \advance\:ddd  -\if:IIID \:Z \else \:ddd \fi
   \:length  \MoveToLoc(@^)}\def\:NormalizeDeg#1{
   \:DL#1   \:K\:InCons\:DL
   \divide\:K  \:cccvx   \multiply\:K  \:cccvx
   \advance #1 -\:K\p@
   \ifdim #1<\z@ \advance #1  \:CCCVX \fi
   \ifdim #1=\z@
      \ifdim\:DL=\z@ \else
         \advance #1  \:CCCVX \fi \fi }\def\:CosSin#1{ \:DK#1
   \:NormalizeDeg\:DK \def\:tempA{}
\ifdim \:CVXXX<\:DK
   \def\:tempA{\:y-\:y}
   \advance\:DK -\:CCCVX  \:DK-\:DK   \fi
\ifdim \:XC<\:DK
   \edef\:tempA{\:x-\:x \:tempA}
   \advance\:DK -\:CVXXX  \:DK-\:DK   \fi
\ifdim 45\p@<\:DK
   \edef\:tempA{\:d\:x \:x\:y \:y\:d \:tempA}
   \advance\:DK -\:XC   \:DK-\:DK   \fi
   \:x\p@   \:y0.01745\:DK   \:d\:y   \:K\@ne
   \edef\:next{\advance\:K \@ne
      \:sqr\:d  \divide\:d \:K  \advance}
   \:next \:x -\:d   \:next \:y -\:d
   \:next \:x  \:d   \:next \:y  \:d
   \:next \:x -\:d   \:next \:y -\:d
   \:next \:x  \:d   \:next \:y  \:d
   \:tempA   }   \Define\:rInitOval(2){
   \XSaveUnits   \let\du=\:rdu
   \:Zunits\p@   \:dd#1\:Zunits
   \:d\:Cons\:dd\:Xunitsx   \edef\:Xx{\:Cons\:d}
   \:d\:Cons\:dd\:Xunitsy   \edef\:Xy{\:Cons\:d}
   \:dd#2\:Zunits
   \:d\:Cons\:dd\:Yunitsx   \edef\:Yx{\:Cons\:d}
   \:d\:Cons\:dd\:Yunitsy   \edef\:Yy{\:Cons\:d}
   \XRecallUnits  \let\du=\:svdu
}
\Define\:xyInitOval(2){
   \:d#1\:Xunits   \edef\:Xx{\:Cons\:d} \def\:Xy{0}
   \:d#2\:Yunits   \edef\:Yy{\:Cons\:d} \def\:Yx{0} }
 \def\:FigSize#1#2#3{
   \:x\:LBorder   \:y\:RBorder   \:d\:TeXLoc
   {\Object\:temp{#3}
    \setbox\:box\hbox{ \:temp
       \multiply\:x by \tw@  \multiply\:y by \tw@
       \xdef\:FSize{ \noexpand#1=\:Cons\:x;
                       \noexpand#2=\:Cons\:y;}}}
   \global\:LBorder\:x   \global\:RBorder\:y
   \global\:TeXLoc \:d
   \:FSize}
\expandafter\let \csname 0:Ln \endcsname\:Ln
\expandafter\def\csname 1:Ln \endcsname{
      \advance\:x -\:X  \advance\:y -\:Y
      \csname 0:Ln \endcsname(\:x,\:y)  }

\newcount\:ClipLevel   \:ClipLevel\@ne

\Define\Clip{\futurelet\:next\:Clip}

\Define\:Clip{
   \ifx \:next[  \expandafter\:DefClipOut
        \else    \expandafter\:DefClip     \fi }

\def\:DefClipOut[#1]{ \:DefClip(#1) }
\Define\:DefClip(1){  \def\:temp{#1}
   \ifx \:temp\empty
      \:ClipLevel\@ne     \def\:next{\let\:Ln}
      \expandafter\:next\csname 0:Ln \endcsname
   \else  \def\:temp{\::DefClip(#1)}  \fi  \:temp }
\Define\::DefClip(1){  \MarkLoc(^)
   \:x\:X  \:y \:Y  \Move(#1)
   \ifdim\:x>\:X  \:dd\:X  \:X\:x  \:x\:dd  \fi
   \ifdim\:y>\:Y  \:dd\:Y  \:Y\:y  \:y\:dd  \fi
   \advance\:ClipLevel  \@ne
   \expandafter\edef\csname \the
      \:ClipLevel :Ln \endcsname{
          \:xxx \the\:x   \:yyy \the\:y
          \:xxxx\the\:X  \:yyyy\the\:Y
          \ifx \:next[   \noexpand\:ClipOut
          \else          \noexpand\:ClipIn     \fi }
   \let\:Ln\:ClipLn   \MoveToLoc(^)  }\def\:ClipLn(#1,#2){
   \:x#1\:Xunits \:y#2\:Yunits
   {  \let\:Xunits\empty  \let\:Yunits\empty
   \advance\:x \:X   \advance\:y \:Y
   \ifdim \:x<\:X  \:dd\:X \:X\:x \:x\:dd
                   \:dd\:Y \:Y\:y \:y\:dd  \fi
   \:diff\:dd\:X\:x   \:diff\:ddd\:Y\:y
\:Z \:AbsVal \:dd
\advance\:Z  \:AbsVal\:ddd
\ifdim \:Z>\sixt@@n\p@
   \divide\:dd   128
   \divide\:ddd  128  \fi
\:Z\:Cons\:y\:dd
\advance\:Z -\:Cons\:x\:ddd
\ifdim \:dd<\z@
  \:dd-\:dd  \:ddd-\:ddd  \:Z-\:Z
\fi
   \csname \the \:ClipLevel :Ln \endcsname      } 
   \advance\:X \:x   \advance\:Y \:y  }\Define\:ClipIn{
   \def\:next{\let\:next}
   \expandafter\:next\csname \the
      \:ClipLevel :Ln \endcsname
   \advance\:ClipLevel \m@ne
   { \:ClipLeft\:xxxx \:ClipDown\:yyy \:ClipUp\:yyyy \:next }
   { \:ClipRight\:xxx \:ClipDown\:yyy \:ClipUp\:yyyy \:next  }
   { \:ClipDown\:yyyy \:next }
     \:ClipUp\:yyy    \:next }

\Define\:ClipOut{
   \:ClipLeft\:xxx      \:ClipRight\:xxxx
   \:ClipUp  \:yyyy     \:ClipDown \:yyy
   \def\:next{\let\:next}
   \expandafter\:next
      \csname \the\:ClipLevel :Ln \endcsname
   \advance\:ClipLevel \m@ne      \:next  }\def\:ClipLeft#1{
   \ifdim       \:x<#1  \:KilledLine
   \else \ifdim \:X<#1  \:X#1
      \ifdim \:dd>\:mmmp
         \:Y\:Cons\:ddd\:X  \advance\:Y \:Z
         \:divide\:Y\:dd
   \fi \fi \fi     \:CondKilLn  }

\def\:ClipRight#1{
   \ifdim       \:X>#1  \:KilledLine
   \else \ifdim \:x>#1  \:x#1
      \ifdim \:dd>\:mmmp
         \:y\:Cons\:ddd\:x  \advance\:y \:Z
         \:divide\:y\:dd
   \fi \fi \fi    \:CondKilLn }

\Define\:CondKilLn{
   \:d\:x  \advance\:d -\:X
   \ifdim \:d<\z@  \:d-\:d \fi
   \ifdim \:y<\:Y  \advance\:d \:Y \advance\:d -\:y
   \else           \advance\:d \:y \advance\:d -\:Y  \fi
   \ifdim  \:d<\:mmp   \:KilledLine \fi
   \ifdim  \:thickness=\z@ \:KilledLine \fi}

\Define\:KilledLine{
   \let\:ClipLeft\:gobble  \let\:ClipRight\:gobble
   \let\:ClipUp  \:gobble  \let\:ClipDown \:gobble
   \let\:next\relax
   \expandafter\def\csname 1:Ln \endcsname{}}\def\:ClipUp#1{
   \:AbsDif\:d\:y\:Y
   \ifdim  \:d<\:ragged
      \advance\:y  0.5\:thickness
\advance\:Y -0.5\:thickness
\ifdim       \:Y>#1  \:KilledLine
\else \ifdim \:y>#1
   \:thickness#1 \advance\:thickness -\:Y
   \advance\:Y  0.5\:thickness  \:y\:Y
\else
   \advance\:Y  0.5\:thickness
   \advance\:y -0.5\:thickness
\fi  \fi
\:dd\p@   \:ddd\z@
\def\:temp{  \:Z\:Y }  \:temp
   \else \let\:temp\relax
          \ifdim \ifdim\:Y<\:y\:Y\else\:y\fi >#1  \:KilledLine
   \else  \ifdim  \::ClipUp#1\:X\:Y
   \else  \ifdim  \::ClipUp#1\:x\:y
   \fi \fi \fi \fi   \:CondKilLn  }

\def\::ClipUp#1#2#3{
#3>#1   #3#1
\ifdim \:AbsVal\:ddd>\:mmmp
   #2\:Cons\:dd#3  \advance#2 -\:Z
   \:divide#2\:ddd
\fi  }\def\:ClipDown#1{   \:Ex2#1
   \:Flip\:y  \:Flip\:Y  \:ClipUp#1
   \:Flip\:y  \:Flip\:Y  \:temp }

\def\:Flip#1{   #1-#1  \advance#1 \:Ex  }
\Define\:SetDrawWidth{
   \hsize\:RBorder      \advance\hsize -\:LBorder
   \leftskip -\:LBorder \rightskip\z@}
\newdimen\:thickness   \:thickness0.75\p@

\Define\PenSize(1){\:thickness#1\relax}
\Define\:Draw{   \ifvmode \noindent\hfil\fi
   \global\:TeXLoc\z@
   \vbox\bgroup
           \begingroup
   \def\EndDraw{
           \endgroup   \:SetDrawWidth
         \egroup}
   \:DraCatCodes      \parindent\z@    \everypar{}
\leftskip\z@     \rightskip\z@    \boxmaxdepth\maxdimen
\linepenalty10   \let\FigSize\:FigSize
\def\Draw{\:wrn1{}} \:CommonIID   \:InDraw }
\Define\:CommonIID{\def\RotateTo{\:RotateTo}
\def\Rotate{\:Rotate}
\def\MoveF{\:MvF}\def\LineToLoc{\:LnToLoc}}\newdimen\:Xunits   \:Xunits\p@
\newdimen\:Yunits   \:Yunits\p@
\Define\:InDraw{\:Opt()\::InDraw{\:Xunits,\:Yunits}}
\Define\::InDraw(2){   \:X\z@   \:Y\z@
   \:Xunits#1 \relax  \:Yunits#2  \:AdjRunits
   \global\:LBorder\z@    \global\:RBorder\z@   \gdef\:UBorder{0pt}
   \:loadIID   \leavevmode }

\Define\:Resize(2){
   \:Xunits#1\:Xunits  \relax
   \:Yunits#2\:Yunits  \:AdjRunits  }
\Define\:Units(2){
   \:Xunits#1 \relax   \:Yunits#2    \:AdjRunits   }
\Define\:loadIID{
   \def\LineAt{\:DLn}
   \def\LineTo{\:LnTo}
   \def\MoveTo{\:MvTo}
   \def\Line{\:Ln}
   \def\Move{\:Mv}
   \def\MoveF{\:MvF}
   \:rotatedfalse\def\:InitOval{\:xyInitOval}
   \def\Scale{\:Resize}
   \def\Units{\:Units}}\let\SaveAll\begingroup
\let\RecallAll\endgroup
\def\DrawOn{\def\Draw{\:Draw}}                      \DrawOn
\def\DrawOff{\def\Draw{\begingroup \:J\@cclv
                       \:NoDrawSpecials \:NoDraw}}
\catcode`\/0 \catcode`\\11
/def/:NoDraw#1\EndDraw{/endgroup}
/catcode`/\0 /catcode`//12

\def\:NoDrawSpecials{\catcode\:J11
  \ifnum \:J=\z@
     \let \:NoDrawSpecials\relax \fi
  \advance\:J  \m@ne \:NoDrawSpecials}
\let\:XunitsReg\:Xunits   \let\:YunitsReg\:Yunits  \Define\EntryExit(4){
   \edef\:InOut##1{
      \noexpand\ifcase ##1\space
         #1\noexpand\or #2\noexpand\or
         #3\noexpand\or #4\noexpand\fi}}

\EntryExit(0,0,0,0)\Define\:DrawBox{   \:x0.5\wd\:box
   \:y\ht\:box \advance\:y  \dp\:box
   \divide\:y \tw@
   \advance \:X -\:InOut0\:x
   \advance \:Y -\:InOut1\:y
   { \advance \:X -\:x
     {  \advance \:Y \:y
\ifdim\:Y>\:UBorder \xdef\:UBorder{\the\:Y}\fi
\ifdim\:X<\:LBorder \global\:LBorder\:X\fi
\advance\:X \wd\:box
\ifdim\:X>\:RBorder \global\:RBorder\:X\fi }
      \advance \:Y -\:y  \advance \:Y  \dp\:box
     {\:d\:X \advance\:d \wd\:box
 \advance\:X -\:TeXLoc   \global\:TeXLoc\:d
 \vrule width\:X depth\z@ height\z@
 \raise \:Y \box\:box} }
   \edef\MoveToExit(##1,##2){
   \:X\the\:X   \:Y\the\:Y
   \:x\the\:x   \:y\the\:y
   \advance\:X  ##1\:x
   \advance\:Y  ##2\:y}
   \advance \:X  \:InOut2\:x
   \advance \:Y  \:InOut3\:y }
 \Define\ThreeDim{\:Opt[]\:ThreeDim{\p@}}

\def\:ThreeDim[#1](#2){\::ThreeDim[#1](#2,,)}

\def\::ThreeDim[#1](#2,#3,#4,#5){ \bgroup\begingroup
   \def\EndThreeDim{          \endgroup\egroup}
   \:IIIDtrue   \:Zunits#1  \:Z\z@
   \def\:temp{#4}
   \ifx \:temp\empty   \:CosSin{#3\p@}  \:divide\:x\:y       \:Ey\:x
\:CosSin{#2\p@}  \:Ex\:Cons\:Ey\:x  \:Ey\:Cons\:Ey\:y
\let\:project\:projectPar

   \else               \:Ex#2\:Xunits \:Ey#3\:Yunits \:Ez#4\:Zunits
\let\:project\:projectPer
 \fi
   \def\LineAt{\:tDLn}
\def\LineTo{\:tLnTo}
\def\MoveTo{\:tMvTo}
\def\Line{\:tLn}
\def\Move{\:tMv}
\def\Scale{\:tResize}
\def\Units{\:tUnits}\def\RotateTo{\:tRotateTo}
\def\Rotate{\:tRotate}
\def\MoveF{\:tMvF}
\:Vdirection\z@ \def\LineToLoc{\:tLnToLoc} }  \Define\:projectPer{
   \:diff\:x\:X\:Ex   \:diff\:y\:Y\:Ey
   \:diff\:xxxx\:Z\:Ez
   \:divide\:x\:xxxx      \:divide\:y\:xxxx
   \:x-\:Cons\:Ez\:x     \:y-\:Cons\:Ez\:y
   \advance\:x  \:Ex    \advance\:y \:Ey}
\Define\:projectPar{
   \:x\:Cons\:Ex\:Z  \advance\:x \:X
   \:y\:Cons\:Ey\:Z  \advance\:y \:Y}
\def\:tDLn(#1,#2,#3,{\:tMvTo(#1,#2,#3)
                     \:tLnTo(}
\Define\:tMvTo(3){   \:X#1\:Xunits
   \:Y#2\:Yunits    \:Z#3\:Zunits}
\Define\:tMv(3){     \advance\:X  #1\:Xunits
   \advance\:Y  #2\:Yunits
   \advance\:Z  #3\:Zunits}
\Define\:tResize(3){   \:Xunits#1\:Xunits
   \:Yunits#2\:Yunits \:Zunits#3\:Zunits
   \:AdjRunits}
\Define\:tUnits(3){    \:Xunits#1  \relax
   \:Yunits#2  \relax       \:Zunits#3
   \:AdjRunits}\Define\:tLnTo(3){
   \:project   \edef\:temp{\:x\the\:x \:y\the\:y}
   \:X#1\:Xunits  \:Y#2\:Yunits  \:Z#3\:Zunits
   \:DLN}

\Define\:tLn(3){
   \:project   \edef\:temp{\:x\the\:x \:y\the\:y}
   \advance\:X  #1\:Xunits
   \advance\:Y  #2\:Yunits
   \advance\:Z  #3\:Zunits   \:DLN}

\Define\:DLN{
   \TwoDim      \:temp        \LineTo(\:x\du,\:y\du)
   \EndTwoDim }\Define\TwoDim{\bgroup\begingroup
   \def\EndTwoDim{\endgroup\egroup}
   \:loadIID
   \if:IIID  \:IIIDfalse \:project \:X\:x \:Y\:y
             \:CommonIID \fi
   \Units(\:Xunits,\:Yunits)}  
\newif\if:rotated
\Define\RotatedAxes(2){\begingroup
   \def\EndRotatedAxes{\endgroup}
   \if:IIID  \:IIIDfalse
             \:project \:X\:x \:Y\:y
             \:CommonIID    \fi
   \:DK#2\p@ \advance\:DK -#1\p@
\advance\:DK -\:CVXXX   \:NormalizeDeg\:DK
\ifdim \:DK<\:mmp \:wrn4{(#1,#2)}
\else
  \:DK#1\p@ \:NormalizeDeg\:DK    \:CosSin\:DK
  \:Xunitsx\:x  \:Xunitsy\:y
  \:DK#2\p@ \advance\:DK -\:XC \:NormalizeDeg\:DK \:CosSin\:DK
  \edef\Units(##1,##2){\noexpand\:Units(##1,##2)
    \:Xunitsx \:Cons\:Xunitsx\:Xunits
    \:Xunitsy \:Cons\:Xunitsy\:Xunits
    \:Yunitsx-\:Cons\:y\:Yunits
    \:Yunitsy \:Cons\:x\:Yunits  } \fi
\def\Scale{\:rResize} \def\MoveTo{\:rMvTo}
\def\Move{\:rMv}
\def\LineTo{\:rLnTo}
\def\Line{\:rLn}
\def\LineAt{\:rDLn}
\def\MoveF{\:rMvF}\def\:InitOval{\:rInitOval}

   \MarkLoc(:org) \Units(\:Xunits,\:Yunits)  \:rotatedtrue }
\newdimen\:Xunitsx  \newdimen\:Xunitsy
\newdimen\:Yunitsx  \newdimen\:Yunitsy
\Define\:rResize(2){
   \:Xunits #1\:Xunits    \:Yunits #2\:Yunits
   \:Xunitsx#1\:Xunitsx   \:Xunitsy#1\:Xunitsy
   \:Yunitsx#2\:Yunitsx   \:Yunitsy#2\:Yunitsy  }
\def\:rdu#1{%
   \ifx #1\:Xunits \units:i\else
   \ifx #1\:Yunits \units:i\else
   \ifx #1\:Zunits \units:i\else #1\fi \fi \fi }
\def\units:i{\Units(\p@,\p@)}
\Define\:rMvTo{\MoveToLoc(:org) \:rMv}
\Define\:rMv(1){ \:rxy(#1)
   \advance\:X  \:x \advance\:Y  \:y}
\Define\:rLnTo(1){ \MarkLoc(:a) \:rMvTo(#1) {\LineToLoc(:a)} }
\Define\:rLn(1){ \:rxy(#1) \:Ln(\:x\du,\:y\du) }
\def\:rDLn(#1,#2,{\:rMvTo(#1,#2)\:rLnTo(}
\Define\:rxy(2){                           \XSaveUnits   \let\du=\:rdu
   \:Zunits\p@   \:Zunits#1\:Zunits
   \:x\:Cons\:Zunits\:Xunitsx
   \:y\:Cons\:Zunits\:Xunitsy            \XRecallUnits  \XSaveUnits
   \:Zunits\p@   \:Zunits#2\:Zunits
   \advance\:x  \:Cons\:Zunits\:Yunitsx
   \advance\:y  \:Cons\:Zunits\:Yunitsy \XRecallUnits  \let\du=\:svdu}
\Define\:rMvF(1){  \:CosSin\:direction   \XSaveUnits   \let\du=\:rdu
   \:Zunits\p@            \:Zunits#1\:Zunits
   \:x\:Cons\:Zunits\:x   \:y\:Cons\:Zunits\:y
   \edef\:temp{(\:Cons\:x,\:Cons\:y)}   \expandafter\Move\:temp
   \XRecallUnits  \let\du=\:svdu}
\Define\:AdjRunits{
   \:Xunitsx\:Xunits   \:Xunitsy\z@
   \:Yunitsx\z@        \:Yunitsy\:Yunits}
\Define\Text{  \setbox\:box
   \vtop\bgroup    \edef\DoReg{\the\DoReg}
      \hyphenpenalty\@M  \exhyphenpenalty\@M
      \catcode`\ 10 \catcode`\^^M13 \catcode`\^^I10
      \catcode`\&4  \let~\space  \csname ;catcode\endcsname %
%
      \:Text}                       \catcode`\^^M13 %
\def\:Text(--#1--){%
      \:SetLines#1\hbox{}^^M--)^^M %
   \egroup                  %
   \if:IIID \TwoDim  \:DrawBox  \EndTwoDim %
   \else             \:DrawBox  \fi}       %
\def\:SetLines#1^^M{        %
   \def\:TextLine{#1}       %
   \ifx \:TextLine\:LastLine   \let\:temp\relax      %
   \else  \def\:temp{                                 %
             \:IndirectLines#1\relax~~--)~~\:SetLines}%
   \fi  \:temp }                      \catcode`\^^M9
\def\:IndirectLines#1~~{    \def\:TextLine{#1}
  \ifx \:TextLine\:LastLine   \let\:temp\relax
  \else  \def\:temp{\:AddLine{#1}\:IndirectLines}
  \fi  \:temp }

\Define\:LastLine{--)}

\def\:AddLine#1{
   \ifvmode \noindent    \hsize\z@ \else
      \hfil \penalty-500 \hbox{}    \fi
   \hfil#1
   \setbox\:box\hbox{#1}
   \ifdim \wd\:box>\hsize \hsize\wd\:box \fi}\def\TextPar#1#2{
   \def\:TxtPar##1(##2){##1(--##2--)}
   \edef\:temp{\expandafter\noexpand\csname :\string#2\endcsname}
   \edef#2{\noexpand\:TextPar\expandafter\noexpand\:temp}
   \expandafter\let\:temp\:undefined
   \expandafter#1\:temp}
                                   \catcode`\^^M13
\def\:TextPar#1{\begingroup     \catcode`\&4         %
   \csname ;catcode\endcsname %
%
   \catcode`\ 10 \catcode`\^^M13 \catcode`\^^I10 %
   \:TPar{#1}}                     \catcode`\^^M9  %

\def\:TPar#1(--#2--){\endgroup
   #1(--#2--)  }
 \newdimen\:direction  \newdimen\:Vdirection
\Define\:Rotate(1){   \advance \:direction   #1\p@
                      \:NormalizeDeg\:direction  }
\Define\:RotateTo(1){ \:direction  #1\p@
                      \:NormalizeDeg\:direction  }

\Define\:tRotate(2){
   \advance\:Vdirection  #2\p@
   \:NormalizeDeg\:Vdirection  \:Rotate(#1)}
\Define\:tRotateTo(2){
   \:Vdirection #2\p@
   \:NormalizeDeg\:Vdirection  \:RotateTo(#1)}
\Define\LineF(1){\MarkLoc(,)\MoveF(#1) {\LineToLoc(,)}}
\Define\:MvF(1){    \:CosSin\:direction
   \:d#1\:Xunits   \advance\:X  \:Cons\:d\:x
   \:d#1\:Yunits   \advance\:Y  \:Cons\:d\:y   }
\Define\MoveFToOval(2){
   \:NormalizeDeg\:direction \:CosSin\:direction  \:Zunits\p@
   \:d#2\:Zunits    \:x\:Cons\:d\:x
   \ifdim \:d=\z@  \:err5{...,\:Cons\:d} \fi
   \:d#1\:Zunits    \:y\:Cons\:d\:y
   \ifdim \:d=\z@  \:err5{\:Cons\:d,...} \fi     \:SearchDir
   \XSaveUnits
      \if:rotated
        \:Zunits\p@     \:Zunits#1\:Zunits
        \:x\:Cons\:Zunits\:Xunits
        \:Zunits\p@     \:Zunits#2\:Zunits
        \:y\:Cons\:Zunits\:Yunits
      \else
        \:x#1\:Xunits  \:y#2\:Yunits  \fi     \relax
      \Units(\:x,\:y)
      \:Vdirection\:direction  \:direction\:ddd
      \MoveF(\@ne)  \:direction\:Vdirection  \XRecallUnits  }
\Define\:tMvF(1){    \:CosSin\:Vdirection
   \:d #1\:Zunits   \advance\:Z  \:Cons\:y\:d
   \:xx#1\:Xunits     \:yy#1\:Yunits
   \:xx\:Cons\:x\:xx    \:yy\:Cons\:x\:yy
   \:CosSin\:direction
   \:x\:Cons\:xx\:x    \:y\:Cons\:yy\:y
   \advance\:X  \:x   \advance\:Y  \:y } \Define\CSeg{\:Opt[]\:CSeg1}
\def\:CSeg[#1]#2(#3,#4){   \MarkLoc($^)
   \MoveToLoc(#4) \:x\:X \:y\:Y
   \if:IIID  \:d\:Z  \fi   \MoveToLoc(#3)
   \advance\:x -\:X  \:x#1\:x
   \advance\:y -\:Y  \:y#1\:y
   \if:IIID   \advance\:d -\:Z  \:d#1\:d \fi
   \:t{#2}
   \edef\:temp{\the\:t(
      \expandafter\:Frac\the\:x\noexpand\:du,
      \expandafter\:Frac\the\:y\noexpand\:du \if:IIID ,
      \expandafter\:Frac\the\:d\noexpand\:du \fi)}
   \MoveToLoc($^)     \:temp}\Define\LSeg{\:Opt[]\:LSeg1}
\def\:LSeg[#1]#2(#3,#4){   \:distance(#3,#4)
   \:d#1\:d  \:t{#2}
   \edef\:temp{\the\:t(\expandafter\:Frac\the\:d\noexpand\:du)}
   \:temp}\Define\DSeg{\:Opt[]\:DSeg1}

\def\:DSeg[#1]#2(#3,#4){   \MarkLoc(^)
   \MoveToLoc(#4)  \:xxx\:X   \:yyy\:Y \:xxxx\:Z
   \MoveToLoc(#3)
   \advance\:xxx -\:X   \advance\:yyy -\:Y
   \ifdim \:AbsVal\:xxx<\:mmmp
      \ifdim \:AbsVal\:yyy<\:mmmp \:wrn5{#3,#4}
   \fi\fi
   \if:IIID
      \advance \:xxxx  -\:Z
      \:divide\:xxx\:Xunitsx
      \:divide\:yyy\:Yunitsy
      \:divide\:xxxx\:Zunits
      \:x\:xxx  \:y\:yyy   \:ddd\z@  \:length
      \:x\:d    \:y\:xxxx  \:SearchDir
      \:yyyy\:ddd
      \:x\:xxx  \:y\:yyy
   \else
      \:x  \:AbsVal\:Yunitsy
\:y  \:AbsVal\:Xunitsy  \ifdim \:y>\:x  \:x\:y  \fi
\:y  \:AbsVal\:Yunitsx  \ifdim \:y>\:x  \:x\:y  \fi
\:y  \:AbsVal\:Xunitsx  \ifdim \:y>\:x  \:x\:y  \fi
\:K  \:InCons\:x  \relax
      \ifnum \:K<\thr@@     \:K\@ne
\else \ifnum \:K<\sixt@@n   \:K4
\else \ifnum \:K<\:XC       \:K\sixt@@n
\else \ifnum \:K<\@m        \:K\@cclvi
\fi \fi \fi \fi
\divide\:xxx \:K
\divide\:yyy \:K  
      \:x \:Cons\:Yunitsy\:xxx
\advance\:x -\:Cons\:Yunitsx\:yyy
      \:y-\:Cons\:Xunitsy\:xxx
\advance\:y \:Cons\:Xunitsx\:yyy     
   \fi
   \:SearchDir   \:ddd#1\:ddd   \:t{#2}
   \edef\:temp{\the\:t(
      \:Cons\:ddd \if:IIID ,\:Cons\:yyyy \fi)}
   \MoveToLoc(^) \:temp}   \def\:theDoReg{\def\DoReg{\the\:DoReg}}

\Define\MarkLoc{  \:theDoReg
   \expandafter\edef \csname \:MarkLoc}

\Define\MarkGLoc{  \:theDoReg
   \expandafter\xdef \csname \:MarkLoc}

\Define\:MarkLoc(1){ Loc\space#1:\endcsname{
   \:X\the\:X  \:Y\the\:Y
   \if:IIID \:Z\the\:Z \fi  }       \let\DoReg\:DoReg }

\Define\MoveToLoc(1){   \:theDoReg   \expandafter\ifx
   \csname Loc\space#1:\endcsname\relax \:err2{#1}\fi
   \csname Loc\space#1:\endcsname     \let\DoReg\:DoReg  }

\Define\MarkPLoc(1){  \:theDoReg
   \if:IIID   \:project
      \expandafter\edef \csname Loc\space#1:\endcsname{
         \:X\the\:x  \:Y\the\:y  \:Z\z@}
   \else \:err1\MarkPLoc  \fi   \let\DoReg\:DoReg}

\Define\WriteLoc(1){{ \:theDoReg \edef\:temp{#1}
   \ifx \:temp\empty \else \MoveToLoc(#1) \fi
   \immediate\write\sixt@@n{...
      \:temp=(\the\:X,\the\:Y\if:IIID,\the\:Z\fi)}}}

\Define\:LnToLoc(1){
   \:x\:X \:y\:Y   \MoveToLoc(#1)
   { \:LnTo(\:x\du,\:y\du) }}

\Define\:tLnToLoc(1){
   \:xx\:X \:yy\:Y \:dd\:Z     \MoveToLoc(#1)
   { \:tLnTo(\:xx\du,\:yy\du,\:dd\du) }}\def\:GetLine#1#2#3#4#5{
   \MoveToLoc(#1)   \divide\:X \:eight  \divide\:Y \:eight
   #3\:X  #4\:Y
   \MoveToLoc(#2)   \divide\:X \:eight  \divide\:Y \:eight
   \advance #3 -\:X  \advance #4 -\:Y
   #5\:Cons#3\:Y      \advance #5 -\:Cons#4\:X
   \divide #3 \:eight     \divide  #4 \:eight \relax      }
\def\MoveToLL(#1,#2)(#3,#4){
   \:GetLine{#1}{#2}\:x \:y \:xxx
   \:GetLine{#3}{#4}\:xx\:yy\:xxxx
   \:ddd \:Cons\:x \:yy     \advance\:ddd -\:Cons\:xx\:y
   \ifdim  \:AbsVal\:ddd < \:mmmp
      \:X\@cclv\p@  \:Y\:X
      \:wrn3{(\string#1,\string#2)(\string#3,\string#4)}
   \else
      \:divide\:xxx\:ddd    \:divide\:xxxx\:ddd
      \:X\:Cons\:xxx\:xx   \advance\:X -\:Cons\:xxxx\:x
      \:Y\:Cons\:xxx\:yy   \advance\:Y -\:Cons\:xxxx\:y
   \fi   }\Define\MoveToCC{\:Opt[]\:MoveToCC{}}

\def\:MoveToCC[#1](#2,#3)(#4,#5){
  \:UserUnits(#2,#3)(#4,#5)
  \:distance($#2,$#4)
\ifnum \:d<\:mp \MoveToLoc(#3)
   \:wrn3{(#1,#2)(#3,#4)}
\else                 \:xx \:d
   \:distance($#2,$#3)  \:xxx\:d
   \:distance($#5,$#4) 
     \:yy \:xxx  \advance\:yy -\:d
\:yyy\:xxx  \advance\:yyy \:d
\:divide\:yy\:xx     \:yy\:Cons\:yy\:yyy
\advance\:yy \:xx  \divide\:yy \tw@
     \:yyy \ifdim \:AbsVal\:xxx>\:AbsVal\:yy \:xxx \else \:yy \fi
\ifdim \:AbsVal\:yyy<\:mp \:yyy\z@ \else
   \:divide\:xxx\:yyy  \:sqr\:xxx
   \:yyyy\:yy  \:divide\:yyyy\:yyy  \:sqr\:yyyy
   \advance\:xxx -\:yyyy   \:Sqrt\:xxx
   \:yyy\:Cons\:yyy\:xxx
\fi 
     \MoveToLoc($#4)  \:x\:X  \:y\:Y  \:divide\:yy\:xx
\MoveToLoc($#2)
\advance\:x -\:X     \advance\:y -\:Y
\advance\:X \:Cons\:yy\:x
\advance\:Y \:Cons\:yy\:y
     \:divide\:yyy\:xx
\advance\:X  #1\:Cons\:yyy\:y
\advance\:Y -#1\:Cons\:yyy\:x

  \fi  \:SysUnits  }\def\:UserUnits(#1,#2)(#3,#4){
   \:xx\:Xunitsx  \:xxx\:Xunitsy
   \:yy\:Yunitsx  \:yyy\:Yunitsy
   \:xxxx\:Cons\:yy\:xxx  \advance\:xxxx \:Cons\:yyy\:xx
   \ifdim \:AbsVal\:xxxx>\:mmmp
      \:divide\:xx\:xxxx   \:divide\:xxx{-\:xxxx}
      \:divide\:yy{\:xxxx} \:divide\:yyy\:xxxx
   \fi
   \:UnLoc(#1)  \:UnLoc(#2)
   \:UnLoc(#3)  \:UnLoc(#4)}\Define\:SysUnits{
   \MoveTo(\:Cons\:X,\:Cons\:Y)}\Define\:UnLoc(1){
   \MoveToLoc(#1)  \:d\:Cons\:yyy\:X
   \advance\:d \:Cons\:yy\:Y
   \:Y\:Cons\:xx\:Y
   \advance\:Y  \:Cons\:xxx\:X   \:X\:d
   \MarkLoc($#1)}\def\MoveToLC{\:Opt[]\:MoveToLC{}}

\def\:MoveToLC[#1](#2,#3)(#4,#5){
   \:UserUnits(#2,#3)(#4,#5)
   \MoveToLoc($#2)  \:x\:X  \:y\:Y
\MoveToLoc($#3)  \advance\:x -\:X
                \advance\:y -\:Y
   \edef\:temp{ \:xxx\the\:x  \:yyy\the\:y }
\MoveToLoc($#4)
\advance\:X \:y  \advance\:Y -\:x
\MarkLoc(^$) \MoveToLL($#4,^$)($#2,$#3)
\MarkLoc(^$)  
   \:distance($#4,$#5)  \:xx\:d  \:distance($#4,^$)
\ifdim      \:d>\:xx        \:wrn3{(#2,#3)(#4,#5)}
\else \ifdim \:d<\:mmp     \:yy\:xx   \else   \:yy\:d
      \:divide\:yy\:xx  \:sqr\:yy
      \:yy-\:yy   \advance\:yy \p@
      \:Sqrt\:yy  \:yy\:Cons\:xx\:yy
\fi \fi
   \:temp   \:x\:xxx  \:y\:yyy  \:length  \:xx\:d
\:divide\:xxx\:xx
\:divide\:yyy\:xx
\advance\:X  #1\:Cons\:yy\:xxx
\advance\:Y  #1\:Cons\:yy\:yyy
   \:SysUnits }  \def\Object#1{\:Opt(){\:DefineSD#1}0}

\def\:DefineSD#1(#2){\begingroup  \:multid#1
   \:DraCatCodes   \:DefSD#1(#2)}

\def\:DefSD#1(#2)#3{
   \expandafter\::Define\csname\string#1.\endcsname(#2){
      \:t{\:SubD{#3}}
      \if:IIID \edef\:temp{\noexpand\TwoDim \the\:t
                           \noexpand\EndTwoDim}
      \else    \def\:temp{\the\:t}   \fi         \:temp}
   \def#1{\def\:SDname{\csname\string#1.\endcsname}
          \:Opt[]\:CallSD{}}}

\def\:CallSD[#1]{ \edef\:Entry{#1} \:SDname }\def\:SubD#1{
   \let\::RecallXLoc\:AddXLoc   \gdef\:AddXLoc{}
   \edef\:RecallBor{ \global\:LBorder  \the\:LBorder
                  \global\:RBorder  \the\:RBorder
                  \xdef\noexpand\:UBorder{\:UBorder}
                  \global\:TeXLoc\the\:TeXLoc }
\global\:TeXLoc\z@
\setbox\:box\vbox{\EntryExit(0,0,0,0)
\begingroup
   \def\MarkXLoc{\:MarkXLoc}
   \:InDraw  #1
\endgroup
\:SetDrawWidth                    \let\:XLoc\relax
\xdef\:AddXLoc{\:dd\the\:LBorder  \:AddXLoc}}
\:RecallBor
   \:ddd\dp\:box
   \ifx \:Entry\empty
   \:DrawBox
\else
   \let\:RecallIn\:InOut
   \:x\:X    \:y\:Y
   \def\:XLoc(##1,##2,##3){
      \def\:temp{##1}
      \ifx \:temp\:Entry \:X\:x  \advance\:X -##2
                         \:Y\:y  \advance\:Y -##3
      \fi}
   \:AddXLoc
   \advance\:X  \:dd      \advance\:Y -\:ddd
   \EntryExit(-1,-1,\:InOut2,\:InOut3)  \:DrawBox
   \let\:InOut\:RecallIn
\fi
   \MarkLoc(^)
      \MoveToExit(-1,-1)
   \:xxx\:X   \:yyy\:Y   \advance\:yyy  \:ddd
   \def\:XLoc(##1,##2,##3){
      \:X\:xxx  \advance\:X  ##2     \advance\:X -\:dd
      \:Y\:yyy  \advance\:Y  ##3
      \MarkLoc(##1)}
   \:AddXLoc
   \MoveToLoc(^)
   \ifx \:Entry\empty \else     \MoveToLoc(\:Entry) \fi
   \global\let\:AddXLoc\::RecallXLoc }
\Define\:MarkXLoc(1){  \:theDoReg
   \let\:XLoc\relax
   \xdef\:AddXLoc{\:AddXLoc \:XLoc(#1,\the\:X,\the\:Y)}
   \let\DoReg\:DoReg} 
   \catcode`\ 10 \catcode`\^^M5 \catcode`\^^I10
   \let\wlog\:wlog  \let\:wlog\:undefined
\:RestoreCatcodes     \tracingstats1   \endinput
