% ecleepic.sty by Hideki Isozaki
% simulates some functions of eepic.sty without \special

\typeout{ecleepic.sty 1.0 --- May 11, 1992}

\let\path\drawline

\newif\iffast \fasttrue

\def\ellipse{\@ifstar{\@elfull}{\@elvoid}}

\newcount\ep@A \newcount\ep@B \newcount\ep@C
\newcount\ep@a \newcount\ep@b
\newcount\ep@S \newcount\ep@T
\newcount\ep@x \newcount\ep@y
\newcount\ep@t

\def\@elvoid#1#2{\leavevmode\hbox{%
  \let\ep@datai\empty \let\ep@dataii\empty 
  \let\ep@dataiii\empty \let\ep@dataiv\empty 
  \iffast
    \ep@useonedeg
    \def\ep@@adddata##1##2{%
      \leavevmode
      \raise##2 sp\hbox to \z@{\kern##1 sp\picsquare\hss}%
      \raise-##2 sp\hbox to \z@{\kern##1 sp\picsquare\hss}%
      \raise-##2 sp\hbox to \z@{\kern-##1sp\picsquare\hss}%
      \raise##2 sp\hbox to \z@{\kern-##1 sp\picsquare\hss}}%
  \else
    \ep@usethrdeg
    \def\ep@@adddata##1##2{%
      \edef\ep@datai{\ep@datai(\the##1,\the##2)}%
      \edef\ep@dataii{\ep@dataii(-\the##1,\the##2)}%
      \edef\ep@dataiii{\ep@dataiii(-\the##1,-\the##2)}%
      \edef\ep@dataiv{\ep@dataiv(\the##1,-\the##2)}}%
  \fi
  \@elshape{#1}{#2}%
  \iffast\else
    \unitlength=1sp
    \expandafter\drawline\ep@datai\relax
    \expandafter\drawline\ep@dataii\relax
    \expandafter\drawline\ep@dataiii\relax
    \expandafter\drawline\ep@dataiv\relax
  \fi}}

\def\@elfull#1#2{\leavevmode\hbox{%
  \ep@usethrdeg
  \def\ep@@adddata##1##2{%
    \makebox(0,0){%
      \@tempdima=##2sp \ep@t=\@tempdima
      \@tempdima=##1sp \ep@T=\@tempdima \advance\ep@T\ep@T
      \leavevmode\vrule \@depth \ep@t sp \@height \ep@t sp
         \@width \ep@T sp}}%
  \@elshape{#1}{#2}}}

%  original code of \@elshape:
%  David Salomon: DDA Methods in \TeX, TUGboat Vol.10, No.2, pp.207--216, 1989.

\def\@elshape#1#2{%
  \ep@A=\@M \ep@B=\z@
  \ifdim#1\p@>#2\p@
    \@tempdima=#1\unitlength \divide\@tempdima 20000 \ep@a\@tempdima
    \@tempdima=#2\unitlength \divide\@tempdima 20000 \ep@b\@tempdima
    \def\ep@adddata##1##2{\ep@@adddata{##1}{##2}}%
  \else
    \@tempdima=#2\unitlength \divide\@tempdima 20000 \ep@a\@tempdima
    \@tempdima=#1\unitlength \divide\@tempdima 20000 \ep@b\@tempdima
    \def\ep@adddata##1##2{\ep@@adddata{##2}{##1}}%
  \fi
% step=3deg sin(3deg)=0.05233.. cos(3deg)=0.99862..
  \ep@S=523 \ep@C=9986 
  \ep@x=\ep@a \multiply\ep@x\@M \ep@y=\z@
  \loop
    \ep@adddata{\ep@x}{\ep@y}%
    \ep@T=\ep@B \multiply\ep@T\ep@S
    \ep@t=\ep@A \multiply\ep@t\ep@C \advance\ep@t-\ep@T
    \ep@T=\ep@A \multiply\ep@T\ep@S
    \multiply\ep@B\ep@C \advance\ep@B\ep@T
    \divide\ep@B\@M
    \ep@A=\ep@t \divide\ep@A\@M
    \ep@x=\ep@a \multiply\ep@x\ep@A
    \ep@y=\ep@b \multiply\ep@y\ep@B
  \ifnum\ep@x>\z@ \repeat}



% Short \vectors and \lines

\let\long@vector\vector

\def\line(#1,#2)#3{{\emu@line(#1,#2){#3}}}

\def\emu@line(#1,#2)#3{%
  \ifnum#1=\z@
    \ifnum#2<\z@  
      \drawline(0,0)(0,-#3)\def\emu@to{(0,-#3)}%
    \else
      \drawline(0,0)(0,#3)\def\emu@to{(0,#3)}
    \fi
  \else
     \Div{#3}{#1}\line@unit
     \Mul{#2}\line@unit\line@y
     \ifnum#1<\z@
       \drawline(0,0)(-#3,-\line@y)\def\emu@to{(-#3,-\line@y)}%
     \else
       \drawline(0,0)(#3,\line@y)\def\emu@to{(#3,\line@y)}%
     \fi
  \fi}
  
\def\vector(#1,#2)#3{{\emu@line(#1,#2){#3}%
   \expandafter\put\emu@to{\long@vector(#1,#2){0}}}}


% \arcdeg for degree was added.
\def\arcdeg#1#2#3{%
  \let\ep@datai\empty \let\ep@dataii\empty 
  \let\ep@dataiii\empty \let\ep@dataiv\empty 
  \iffast
      \ep@useonedeg
      \def\ep@arcdata##1##2{%
        \leavevmode
        \raise-##2 sp\hbox to \z@{\kern##1 sp\picsquare\hss}}%
  \else
    \ifdim#1\unitlength>\ep@mediumarc
      \ep@useonedeg
      \def\ep@arcdata##1##2{%
        \edef\ep@datai{\ep@datai(\the##1,-\the##2)}}%
    \else
    \ifdim#1\unitlength>\ep@smallarc
      \ep@usetwodeg
      \def\ep@arcdata##1##2{%
        \edef\ep@datai{\ep@datai(\the##1,-\the##2)}}%
    \else
    \ep@usethrdeg
    \ifdim#1\unitlength>\ep@tinyarc
      \def\ep@arcdata##1##2{%
        \edef\ep@datai{\ep@datai(\the##1,-\the##2)}}%
    \else
      \def\ep@arcdata##1##2{%
        \leavevmode
        \raise-##2 sp\hbox to \z@{\kern##1 sp\picsquare\hss}}%
    \fi\fi\fi
  \fi
  \@arshape{#1}{#2}{#3}%
  \iffast\else
    \ifdim#1\unitlength>\ep@tinyarc
      \unitlength=1sp
      \expandafter\drawline\ep@datai\relax
    \fi
  \fi}

\def\ep@tinyarc{3cm}
\def\ep@smallarc{6cm}
\def\ep@mediumarc{9cm}

% step=1deg sin(1deg)=0.01745.. cos(1deg)=0.99984..
% step=2deg sin(2deg)=0.03489.. cos(2deg)=0.99939..
% step=3deg sin(3deg)=0.05233.. cos(3deg)=0.99862..
\def\ep@usethrdeg{\ep@S=523 \ep@C=9986 \def\ep@unitang{3}}
\def\ep@usetwodeg{\ep@S=349 \ep@C=9994 \def\ep@unitang{2}}
\def\ep@useonedeg{\ep@S=175 \ep@C=9999 \def\ep@unitang{1}}
%                                 **** gives better results than 9998

\def\@arshape#1#2#3{%
  \ep@A=\@M \ep@B=\z@
  \@tempdima=#1\unitlength \divide\@tempdima 20000 \ep@a\@tempdima
  \ep@x=\ep@a \multiply\ep@x\@M \ep@y=\z@
  \ep@b=\z@
  \loop
    \ifnum\ep@b<#2\else
      \ep@arcdata{\ep@x}{\ep@y}%
    \fi
    \ep@T=\ep@B \multiply\ep@T\ep@S
    \ep@t=\ep@A \multiply\ep@t\ep@C \advance\ep@t-\ep@T
    \ep@T=\ep@A \multiply\ep@T\ep@S
    \multiply\ep@B\ep@C \advance\ep@B\ep@T
    \divide\ep@B\@M
    \ep@A=\ep@t \divide\ep@A\@M
    \ep@x=\ep@a \multiply\ep@x\ep@A
    \ep@y=\ep@a \multiply\ep@y\ep@B
    \advance\ep@b\ep@unitang
  \ifnum\ep@b<#3 \repeat}

% \arc for radian
\def\arc#1#2#3{% pi*65536/180=1143.8189..
  \@tempdima=#2\p@ \divide\@tempdima 1144 \edef\ep@start{\number\@tempdima}%
  \@tempdima=#3\p@ \divide\@tempdima 1144 \edef\ep@end{\number\@tempdima}%
  \arcdeg{#1}{\ep@start}{\ep@end}}

  
% The following code was copied from
% eepicemu Version 1.0 < August 14, 1988 > written by Conrad Kwok

\def\circle{%
    \@ifstar
	{\@emudot}%
	{\@emucirc}%
}
\def\@emudot#1{%
    \@tempdimb #1\unitlength
    \ifdim \@tempdimb > 15pt
        \@elfull{#1}{#1}%
    \else
        \@dot{#1}%
    \fi
}
\def\@emucirc#1{%
     \@tempdimb #1\unitlength
     \ifdim \@tempdimb > 40pt
	\@elvoid{#1}{#1}%
     \else
	\@circle{#1}%
     \fi
}

\let\Thicklines\thicklines

\def\spline(#1,#2)(#3,#4){%
    \@ifnextchar ({\@iispline(#1,#2)(#3,#4)}%
	          {\@drawline[0](#1,#2)(#3,#4)\ignorespaces}}

\def\@iispline(#1,#2)(#3,#4)(#5,#6){%
    \@ifnextchar ({\Add{#3}{#5}\ep@@X \Mul{0.5}\ep@@X\ep@@X 
        \Add{#4}{#6}\ep@@Y \Mul{0.5}\ep@@Y\ep@@Y
        \edef\ep@datai{{#1}{#2}{#3}{#4}{\ep@@X}{\ep@@Y}}%
        \expandafter\@chaikin\ep@datai\relax
        \edef\ep@datai{(\ep@@X,\ep@@Y)(#5,#6)}%
        \expandafter\@iispline\ep@datai}%
%   else
       {\@chaikin{#1}{#2}{#3}{#4}{#5}{#6}}}

\def\@chaikin#1#2#3#4#5#6{%
    \Add{#1}{#3}\ep@@x \Add\ep@@x{#3}\ep@@x \Add\ep@@x{#5}\ep@@x
    \Mul{0.25}\ep@@x\ep@@x
    \Add{#2}{#4}\ep@@y \Add\ep@@y{#4}\ep@@y \Add\ep@@y{#6}\ep@@y
    \Mul{0.25}\ep@@y\ep@@y
    \@drawline[0](#1,#2)(\ep@@x,\ep@@y)\relax
    \@drawline[0](\ep@@x,\ep@@y)(#5,#6)\relax}

\def\allinethickness#1{\thicklines\linethickness{#1}}

\let\blacken=\relax
\let\whiten=\relax
\let\shade=\relax
\let\filltype=\@gobble


  
