%%
%% This is file `bez123.sty',
%% generated with the docstrip utility.
%%
%% The original source files were:
%%
%% bez123.dtx  (with options: `bez')
%% 
%% -----------------------------------------------------------------
%%   Author: Peter Wilson, Herries Press
%%   Maintainer: Will Robertson (will dot robertson at latex-project dot org)
%%   Copyright 1998--2004 Peter R. Wilson
%% 
%%   This work may be distributed and/or modified under the
%%   conditions of the LaTeX Project Public License, either
%%   version 1.3c of this license or (at your option) any
%%   later version: <http://www.latex-project.org/lppl.txt>
%% 
%%   This work has the LPPL maintenance status "maintained".
%%   The Current Maintainer of this work is Will Robertson.
%% 
%%   This work consists of the files listed in the README file.
%% -----------------------------------------------------------------
%% 
\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{bez123}[2009/09/02 v1.1b Bezier curves]
\RequirePackage{multiply}[2009/09/02]
\newcommand{\lbezier}[2][0]{\@lbez{#1}#2}
\gdef\@lbez#1(#2,#3)(#4,#5){%
%%%%\def\lbezier#1(#2,#3)(#4,#5){%
  \ifnum #1<\@ne
    \@ovxx = #4\unitlength
      \advance\@ovxx by -#2\unitlength
      \ifdim \@ovxx < \z@
        \@ovxx = -\@ovxx
      \fi
    \@ovyy = #5\unitlength
      \advance\@ovyy by -#3\unitlength
      \ifdim \@ovyy < \z@
        \@ovyy = -\@ovyy
      \fi
    \ifdim \@ovxx > \@ovyy
      \@multicnt = \@ovxx
    \else
      \@multicnt = \@ovyy
    \fi
    \@ovxx = 0.5\@halfwidth
    \divide\@multicnt by \@ovxx
    \ifnum \qbeziermax < \@multicnt
      \@multicnt = \qbeziermax\relax
    \fi
  \else
    \@multicnt = #1\relax
  \fi
  \@tempcnta = \@multicnt
  \advance\@tempcnta by \@ne
  \@ovdx = #4\unitlength
    \advance\@ovdx by -#2\unitlength
    \divide\@ovdx by \@multicnt
  \@ovdy = #5\unitlength
    \advance\@ovdy by -#3\unitlength
    \divide\@ovdy by \@multicnt
  \setbox\@tempboxa\hbox{\vrule \@height\@halfwidth
                                \@depth \@halfwidth
                                \@width \@wholewidth}%
  \put(#2,#3){%
    \count@ = \z@
    \@whilenum{\count@ < \@tempcnta}\do
      {\@xdim = \count@\@ovdx
       \@ydim = \count@\@ovdy
       \raise \@ydim
         \hb@xt@\z@{\kern\@xdim
                    \unhcopy\@tempboxa\hss}%
       \advance\count@\@ne}}%
}
\newlength{\@wxc}
\newlength{\@wyc}
\newcommand{\cbezier}[2][0]{\@cbez{#1}#2}
\gdef\@cbez#1(#2,#3)(#4,#5)(#6,#7)(#8,#9){%
  \ifnum #1<\@ne
    \@ovxx = #2\unitlength
    \@ovdx = \@ovxx
    \@ovdy = #4\unitlength
    \ifdim \@ovdy > \@ovxx
      \@ovxx = \@ovdy
    \fi
    \ifdim \@ovdy < \@ovdx
      \@ovdx = \@ovdy
    \fi
    \@ovdy = #6\unitlength
    \ifdim \@ovdy > \@ovxx
      \@ovxx = \@ovdy
    \fi
    \ifdim \@ovdy < \@ovdx
      \@ovdx = \@ovdy
    \fi
    \@ovdy = #8\unitlength
    \ifdim \@ovdy > \@ovxx
      \@ovxx = \@ovdy
    \fi
    \ifdim \@ovdy < \@ovdx
      \@ovdx = \@ovdy
    \fi
    \advance\@ovxx by -\@ovdx
    \@ovyy = #3\unitlength
    \@ovdy = \@ovyy
    \@ovdx = #5\unitlength
    \ifdim \@ovdx > \@ovyy
      \@ovyy = \@ovdx
    \fi
    \ifdim \@ovdx < \@ovdy
      \@ovdy = \@ovdx
    \fi
    \@ovdx = #7\unitlength
    \ifdim \@ovdx > \@ovyy
      \@ovyy = \@ovdx
    \fi
    \ifdim \@ovdx < \@ovdy
      \@ovdy = \@ovdx
    \fi
    \@ovdx = #9\unitlength
    \ifdim \@ovdx > \@ovyy
      \@ovyy = \@ovdx
    \fi
    \ifdim \@ovdx < \@ovdy
      \@ovdy = \@ovdx
    \fi
    \advance\@ovyy by -\@ovdy
    \ifdim \@ovxx > \@ovyy
      \@multicnt = \@ovxx
    \else
      \@multicnt = \@ovyy
    \fi
    \@ovxx = 0.5\@halfwidth
    \divide\@multicnt by \@ovxx
    \ifnum \qbeziermax < \@multicnt
      \@multicnt = \qbeziermax\relax
    \fi
  \else
    \@multicnt = #1\relax
  \fi
  \@tempcnta = \@multicnt
  \advance\@tempcnta by \@ne
  \@ovdx = #4\unitlength  \advance\@ovdx by -#2\unitlength
  \@ovxx = #6\unitlength  \advance\@ovxx by -\@ovdx
  \multiply\@ovdx by \thr@@
  \advance\@ovxx by -#4\unitlength  \multiply\@ovxx by \thr@@
  \@wxc = #4\unitlength  \advance\@wxc by -#6\unitlength
  \multiply\@wxc by \thr@@  \advance\@wxc by #8\unitlength
  \advance\@wxc by -#2\unitlength \divide\@wxc by \@multicnt
  \@ovdy = #5\unitlength  \advance\@ovdy by -#3\unitlength
  \@ovyy = #7\unitlength  \advance\@ovyy by -\@ovdy
  \multiply\@ovdy by \thr@@
  \advance\@ovyy by -#5\unitlength  \multiply\@ovyy by \thr@@
  \@wyc = #5\unitlength  \advance\@wyc by -#7\unitlength
  \multiply\@wyc by \thr@@  \advance\@wyc by #9\unitlength
  \advance\@wyc by -#3\unitlength \divide\@wyc by \@multicnt
  \setbox\@tempboxa\hbox{\vrule \@height\@halfwidth
                                \@depth \@halfwidth
                                \@width \@wholewidth}%
  \put(#2,#3){%
    \count@ = \z@
    \@whilenum{\count@ < \@tempcnta}\do
      {\@xdim = \count@\@wxc
         \advance\@xdim by \@ovxx
         \divide\@xdim by \@multicnt
         \multiply\@xdim by \count@
         \advance\@xdim by \@ovdx
         \divide\@xdim by \@multicnt
         \multiply\@xdim by \count@
       \@ydim = \count@\@wyc
         \advance\@ydim by \@ovyy
         \divide\@ydim by \@multicnt
         \multiply\@ydim by \count@
         \advance\@ydim by \@ovdy
         \divide\@ydim by \@multicnt
         \multiply\@ydim by \count@
       \raise \@ydim
         \hb@xt@\z@{\kern\@xdim
                    \unhcopy\@tempboxa\hss}%
       \advance\count@\@ne}}%
}
\newlength{\@ww}
\newlength{\@wwa}
\newlength{\@wwb}
\newlength{\@wwo}
\newlength{\@wwi}
\newcounter{@pntscale}
\newcounter{weightscale}
\newlength{\botscale}
\newcommand{\setweightscale}[1]{\setcounter{weightscale}{#1}}
\newcommand{\resetweightscale}{\setcounter{weightscale}{10000}}
\resetweightscale
\newcommand{\rqbezier}[2][0]{\@rqbez{#1}#2}
\gdef\@rqbez#1(#2,#3)(#4,#5)(#6,#7)(#8){%
  \@ovxx = #8\unitlength
  \ifdim\@ovxx = \unitlength
    \PackageWarning{bez123}{Rational quadratic denerates to quadratic}
    \qbezier[#1](#2,#3)(#4,#5)(#6,#7)
  \else
    \ifdim\@ovxx = \z@
      \PackageWarning{bez123}{Rational quadratic degenerates to linear}
      \lbezier[#1](#2,#3)(#6,#7)
    \else
    \@ovxx = #4\unitlength
      \advance\@ovxx by -#2\unitlength
      \ifdim \@ovxx < \z@
        \@ovxx = -\@ovxx
      \fi
    \@ovdx = #6\unitlength
      \advance\@ovdx by -#4\unitlength
      \ifdim \@ovdx < \z@
        \@ovdx = -\@ovdx
      \fi
    \ifdim \@ovxx < \@ovdx
      \@ovxx = \@ovdx
    \fi
    \@ovyy = #5\unitlength
      \advance\@ovyy by -#3\unitlength
      \ifdim \@ovyy < \z@
        \@ovyy = -\@ovyy
      \fi
    \@ovdy = #7\unitlength
      \advance\@ovdy by -#5\unitlength
      \ifdim \@ovdy < \z@
        \@ovdy = -\@ovdy
      \fi
    \ifdim \@ovyy < \@ovdy
      \@ovyy = \@ovdy
    \fi
    \ifdim \@ovxx > \@ovyy
      \@multicnt = \@ovxx
    \else
      \@multicnt = \@ovyy
    \fi
    \@wwi = \@multicnt sp
  \ifnum #1<\@ne
    \@ovxx = 0.5\@halfwidth
    \divide\@multicnt by \@ovxx
    \ifnum\qbeziermax < \@multicnt
      \@multicnt = \qbeziermax\relax
    \fi
  \else
    \@multicnt = #1\relax
  \fi
  \@tempcnta = \@multicnt
  \advance\@tempcnta by \@ne
  \divide\@tempcnta by \tw@
  \advance\@tempcnta by \@ne
  \@wwo = \maxdimen
    \advance\@wwo by -\@wwi
    \divide\@wwo by \tw@
    \divide\@wwo by \@wwi
  \@wwi = 10sp
  \@wwi = #8\@wwi
    \ifdim\@wwi < \z@
      \@wwi = -\@wwi
    \fi
    \divide\@wwi by 10\relax
  \ifdim\@wwi < \@wwo
    \c@@pntscale = \@ne
  \else
    \divide\@wwi by \tw@
    \ifdim\@wwi < \@wwo
      \c@@pntscale = \tw@
    \else
      \divide\@wwi by \tw@
      \ifdim\@wwi < \@wwo
        \c@@pntscale = 4\relax
      \else
        \divide\@wwi by \tw@
        \ifdim\@wwi < \@wwo
          \c@@pntscale = 8\relax
        \else
          \c@@pntscale = 16\relax
        \fi
      \fi
    \fi
  \fi
  \@ovxx = #4\unitlength \advance\@ovxx by -#2\unitlength
    \multiply\@ovxx by \tw@
    \divide\@ovxx by \c@@pntscale
    \@ovdx = #8\@ovxx
  \@ovxx = #6\unitlength  \advance\@ovxx by -#2\unitlength
    \divide\@ovxx by \c@@pntscale
    \advance\@ovxx by -\@ovdx
    \divide\@ovxx by \@multicnt
  \@ovyy = #5\unitlength \advance\@ovyy by -#3\unitlength
    \multiply\@ovyy by \tw@
    \divide\@ovyy by \c@@pntscale
    \@ovdy = #8\@ovyy
  \@ovyy = #7\unitlength  \advance\@ovyy by -#3\unitlength
    \divide\@ovyy by \c@@pntscale
    \advance\@ovyy by -\@ovdy
    \divide\@ovyy by \@multicnt
  \setlength{\botscale}{\c@weightscale sp}
  \@wwo = \botscale
  \@wwi = #8\@wwo
  \@wwa = \@wwo  \advance\@wwa by -\@wwi
    \multiply\@wwa by \tw@
  \@wwb = \@wwa
    \divide\@wwb by \@multicnt
  \@wwi = \botscale
  \setbox\@tempboxa\hbox{\vrule \@height\@halfwidth
                                \@depth \@halfwidth
                                \@width \@wholewidth}%
  \put(#2,#3){%
    \count@ = \z@
    \@whilenum{\count@ < \@tempcnta}\do
      {\@xdim = \count@\@ovxx
         \advance\@xdim by \@ovdx
         \divide\@xdim by \@multicnt
         \multiply\@xdim by \count@
       \@ydim = \count@\@ovyy
         \advance\@ydim by \@ovdy
         \divide\@ydim by \@multicnt
         \multiply\@ydim by \count@
       \@ww = \count@\@wwb
         \advance\@ww by -\@wwa
         \divide\@ww by \@multicnt
         \multiply\@ww by \count@
         \advance\@ww by \@wwo
         \divide\@ww by \c@@pntscale
         \ifdim\@ww = \z@
         \else
           \divide\@xdim by \@ww
           \divide\@ydim by \@ww
         \fi
         \multnooverflow{\@xdim}{\botscale}%
         \multnooverflow{\@ydim}{\botscale}%
       \raise \@ydim
         \hb@xt@\z@{\kern\@xdim
                    \unhcopy\@tempboxa\hss}%
       \advance\count@\@ne}}
  \@ovxx = #4\unitlength \advance\@ovxx by -#6\unitlength
    \multiply\@ovxx by \tw@
    \divide\@ovxx by \c@@pntscale
    \@ovdx = #8\@ovxx
  \@ovxx = #2\unitlength  \advance\@ovxx by -#6\unitlength
    \divide\@ovxx by \c@@pntscale
    \advance\@ovxx by -\@ovdx
    \divide\@ovxx by \@multicnt
  \@ovyy = #5\unitlength \advance\@ovyy by -#7\unitlength
    \multiply\@ovyy by \tw@
    \divide\@ovyy by \c@@pntscale
    \@ovdy = #8\@ovyy
  \@ovyy = #3\unitlength  \advance\@ovyy by -#7\unitlength
    \divide\@ovyy by \c@@pntscale
    \advance\@ovyy by -\@ovdy
    \divide\@ovyy by \@multicnt
  \put(#6,#7){%
    \count@ = \z@
    \@whilenum{\count@ < \@tempcnta}\do
      {\@xdim = \count@\@ovxx
         \advance\@xdim by \@ovdx
         \divide\@xdim by \@multicnt
         \multiply\@xdim by \count@
       \@ydim = \count@\@ovyy
         \advance\@ydim by \@ovdy
         \divide\@ydim by \@multicnt
         \multiply\@ydim by \count@
       \@ww = \count@\@wwb
         \advance\@ww by -\@wwa
         \divide\@ww by \@multicnt
         \multiply\@ww by \count@
         \advance\@ww by \@wwo
         \divide\@ww by \c@@pntscale
         \ifnum\@ww = \z@
         \else
           \divide\@xdim by \@ww
           \divide\@ydim by \@ww
         \fi
         \multnooverflow{\@xdim}{\botscale}%
         \multnooverflow{\@ydim}{\botscale}%
       \raise \@ydim
         \hb@xt@\z@{\kern\@xdim
                    \unhcopy\@tempboxa\hss}%
       \advance\count@\@ne}}
  \fi\fi}
\endinput
%%
%% End of file `bez123.sty'.
