\typeout{%
Autograph v0.4.1 Nov. 14, 1996}
%%----------------------------------------------------------------------
%%
%% Macros pour dessiner des automates et des graphes sous l'environnement
%% picture de LaTeX 2.09 ou LaTeX2e. Exemples d'utilisations et
%% documentation dans doc_autograph.tex
%%
%% Paul Gastin
%% LITP - IBP
%% Universite Paris 7
%% 2, place Jussieu
%% F-75251 Paris Cedex 05
%% email : Paul.Gastin@litp.ibp.fr
%%
%%----------------------------------------------------------------------
%%
%% D�clarations:

\newif\if@arrow\@arrowtrue
\newif\if@milieu\@milieufalse

\unitlength=4pt
% \d@my@unit est l'unit� utilis�e par tous les dessins de autograph.sty.
% Les valeurs donn�es en \unitlength sont transform�es en \d@my@unit.
% Ceci a pour effet d'augmenter la pr�cision des dessins.
\newdimen\d@my@unit
% \d@my@unit= 2048sp % environ 0.011 mm
% \d@my@unit= 4096sp % environ 0.022 mm
  \d@my@unit= 8192sp % environ 0.044 mm
% \d@my@unit=16384sp % environ 0.088 mm

\newcount\c@aux \newdimen\d@aux
\newcount\c@auxa \newcount\c@auxb \newcount\c@auxc \newcount\c@auxd
\newcount\c@xa \newcount\c@xb \newcount\c@xc \newcount\c@xd
\newcount\c@ya \newcount\c@yb \newcount\c@yc \newcount\c@yd
\newcount\c@deltax \newcount\c@deltay
\newbox\temp@box

\def\setstatediam#1{
  \d@aux=#1\unitlength \c@aux=\d@aux \divide\c@aux\d@my@unit
  \edef\state@diam{\the\c@aux}
  }
\setstatediam{6}

\def\setrepeatedstatediam#1{
  \d@aux=#1\unitlength \c@aux=\d@aux \divide\c@aux\d@my@unit
  \edef\repeted@diam{\the\c@aux}
  }
\setrepeatedstatediam{5}

\def\setloopdiam#1{
  \d@aux=#1\unitlength \c@aux=\d@aux \divide\c@aux\d@my@unit
  \edef\loop@diam{\the\c@aux}
  }
\setloopdiam{6}

\def\settranslabelskip#1{
  \d@aux=#1\unitlength \c@aux=\d@aux \divide\c@aux\d@my@unit
  \edef\trans@label@skip{\the\c@aux}
  }
\settranslabelskip{1}

\def\settransdecal#1{
  \d@aux=#1\unitlength \c@aux=\d@aux \divide\c@aux\d@my@unit
  \edef\trans@decal{\the\c@aux}
  }
\settransdecal{0}

\def\setprofcurve#1{
  \d@aux=#1\unitlength \c@aux=\d@aux \divide\c@aux\d@my@unit
  \edef\prof@curve{\the\c@aux}
  }
\setprofcurve{3}

\def\setmaxbezier#1{\def\max@bezier{#1}}
\def\setnbptbezier#1{\def\max@bezier{#1}} % compatibilit� version 0.3
\setmaxbezier{500}

\def\setprecision#1{} % compatibilit� version 0.3

%%----------------------------------------------------------------------
%%
%% D�finition d'un �tat

\def\letstate{
  \@ifnextchar[{\letstate@un}{\letstate@deux}}
\def\letstate@un[#1,#2] #3=(#4,#5){
  \d@aux=#4\unitlength \c@aux=\d@aux \divide\c@aux\d@my@unit
  \expandafter\edef\csname state@#3@x\endcsname{\the\c@aux}
  \d@aux=#5\unitlength \c@aux=\d@aux \divide\c@aux\d@my@unit
  \expandafter\edef\csname state@#3@y\endcsname{\the\c@aux}
  \d@aux=#1\unitlength \c@aux=\d@aux \divide\c@aux\d@my@unit
  \expandafter\edef\csname state@#3@diam\endcsname{\the\c@aux}
  \d@aux=#2\unitlength \c@aux=\d@aux \divide\c@aux\d@my@unit
  \expandafter\edef\csname state@#3@repdiam\endcsname{\the\c@aux}
  }
\def\letstate@deux #1=(#2,#3){
  \d@aux=#2\unitlength \c@aux=\d@aux \divide\c@aux\d@my@unit
  \expandafter\edef\csname state@#1@x\endcsname{\the\c@aux}
  \d@aux=#3\unitlength \c@aux=\d@aux \divide\c@aux\d@my@unit
  \expandafter\edef\csname state@#1@y\endcsname{\the\c@aux}
  \expandafter\edef\csname state@#1@diam\endcsname{\state@diam}
  \expandafter\edef\csname state@#1@repdiam\endcsname{\repeted@diam}
  }

%% Dessin d'un �tat

\def\drawstate(#1)#2{{
  \unitlength=\d@my@unit
  \edef\cs@x{\csname state@#1@x\endcsname}
  \edef\cs@y{\csname state@#1@y\endcsname}
  \put(\cs@x,\cs@y){\makebox(0,0){#2}}
  \put(\cs@x,\cs@y){\circle{\csname state@#1@diam\endcsname}}
  }}

\def\drawinitialstate{
  \@ifnextchar[{\@idrawinitialstate}{\@idrawinitialstate[l]}}
\def\@idrawinitialstate[#1](#2)#3{{
  \unitlength=\d@my@unit
  \c@xa=\csname state@#2@x\endcsname
  \c@ya=\csname state@#2@y\endcsname
  \edef\cs@diam{\csname state@#2@diam\endcsname}
  \c@auxa=\cs@diam \divide\c@auxa by 2
  \put(\c@xa,\c@ya){\makebox(0,0){#3}}
  \put(\c@xa,\c@ya){\circle{\cs@diam}}
  \if#1l \advance\c@xa by -\cs@diam \put(\c@xa,\c@ya){\vector( 1,0){\c@auxa}} \fi
  \if#1r \advance\c@xa by  \cs@diam \put(\c@xa,\c@ya){\vector(-1,0){\c@auxa}} \fi
  \if#1t \advance\c@ya by  \cs@diam \put(\c@xa,\c@ya){\vector(0,-1){\c@auxa}} \fi
  \if#1b \advance\c@ya by -\cs@diam \put(\c@xa,\c@ya){\vector(0, 1){\c@auxa}} \fi
  }}

\def\drawfinalstate{
  \@ifnextchar[{\@idrawfinalstate}{\@idrawfinalstate[r]}}
\def\@idrawfinalstate[#1](#2)#3{{
  \unitlength=\d@my@unit
  \c@xa=\csname state@#2@x\endcsname
  \c@ya=\csname state@#2@y\endcsname
  \c@auxa=\csname state@#2@diam\endcsname
  \put(\c@xa,\c@ya){\makebox(0,0){#3}}
  \put(\c@xa,\c@ya){\circle{\c@auxa}}
  \divide\c@auxa by 2
  \if#1l \advance\c@xa by -\c@auxa \put(\c@xa,\c@ya){\vector(-1,0){\c@auxa}} \fi
  \if#1r \advance\c@xa by  \c@auxa \put(\c@xa,\c@ya){\vector( 1,0){\c@auxa}} \fi
  \if#1t \advance\c@ya by  \c@auxa \put(\c@xa,\c@ya){\vector( 0,1){\c@auxa}} \fi
  \if#1b \advance\c@ya by -\c@auxa \put(\c@xa,\c@ya){\vector(0,-1){\c@auxa}} \fi
  }}

\def\drawrepeatedstate(#1)#2{{
  \unitlength=\d@my@unit
  \edef\cs@x{\csname state@#1@x\endcsname}
  \edef\cs@y{\csname state@#1@y\endcsname}
  \put(\cs@x,\cs@y){\makebox(0,0){#2}}
  \put(\cs@x,\cs@y){\circle{\csname state@#1@diam\endcsname}}
  \put(\cs@x,\cs@y){\circle{\csname state@#1@repdiam\endcsname}}
  }}

%%----------------------------------------------------------------------
%%
%% Dessin d'une transition

\def\autograph@warning#1{
  \typeout{autograph warning on input line \the\inputlineno : 
           #1 is an old option.}
  \typeout{Still accepted for compatibility reasons. Use l or r instead.}
  \typeout{}
  }

\def\drawtrans{\@arrowtrue\@ifnextchar[{\@idrawtrans}{\@idrawtrans[l]}}
\def\@idrawtrans[#1](#2,#3)#4{{
  \if#1t \autograph@warning{t} \fi
  \if#1b \autograph@warning{b} \fi
  \unitlength=\d@my@unit
  \c@xa=\csname state@#2@x\endcsname
  \c@ya=\csname state@#2@y\endcsname
  \edef\cs@diama{\csname state@#2@diam\endcsname}
  \c@xb=\csname state@#3@x\endcsname
  \c@yb=\csname state@#3@y\endcsname
  \edef\cs@diamb{\csname state@#3@diam\endcsname}
  \c@deltax=\c@xb \advance\c@deltax -\c@xa
  \c@deltay=\c@yb \advance\c@deltay -\c@ya
  \distance(\c@xa,\c@ya)(\c@xb,\c@yb)
% Calcul des points extr�mit�s de la transition et dessin de la fl�che.
  \c@auxc=-\trans@decal
  \multiply\c@auxc\c@deltay \divide\c@auxc\@distance
  \c@auxd= \trans@decal
  \multiply\c@auxd\c@deltax \divide\c@auxd\@distance
  \if#1b \c@auxc=-\c@auxc \c@auxd=-\c@auxd \fi
% 
  \c@auxa=\cs@diama \divide\c@auxa by 2
  \multiply\c@auxa\c@deltax \divide\c@auxa\@distance
  \c@auxb=\cs@diama \divide\c@auxb by 2
  \multiply\c@auxb\c@deltay \divide\c@auxb\@distance
  \advance\c@xa\c@auxa \advance\c@xa\c@auxc
  \advance\c@ya\c@auxb \advance\c@ya\c@auxd
% 
  \c@auxa=\cs@diamb \divide\c@auxa by 2
  \multiply\c@auxa\c@deltax \divide\c@auxa\@distance
  \c@auxb=\cs@diamb \divide\c@auxb by 2
  \multiply\c@auxb\c@deltay \divide\c@auxb\@distance
  \advance\c@xb -\c@auxa \advance\c@xb\c@auxc
  \advance\c@yb -\c@auxb \advance\c@yb\c@auxd
  \if@arrow
    \drawvector(\c@xa,\c@ya)(\c@xb,\c@yb)
  \else
    \drawline(\c@xa,\c@ya)(\c@xb,\c@yb)
  \fi
% Calcul des coordonn�es (\c@xc,\c@yc) du milieu de la transition
  \c@xc=\c@xa \advance\c@xc\c@xb \divide\c@xc by 2
  \c@yc=\c@ya \advance\c@yc\c@yb \divide\c@yc by 2
% Affichage de l'�tiquette de la transition.
  \@drawlabel[#1]{#4}
  }}

\def\drawcurvedtrans{\@arrowtrue
  \@ifnextchar[{\@idrawcurvedtrans}{\@idrawcurvedtrans[l]}}
\def\@idrawcurvedtrans[#1](#2,#3)#4{{
  \if#1t \autograph@warning{t} \fi
  \if#1b \autograph@warning{b} \fi
  \unitlength=\d@my@unit
  \edef\cs@xa{\csname state@#2@x\endcsname}
  \edef\cs@ya{\csname state@#2@y\endcsname}
  \edef\cs@diama{\csname state@#2@diam\endcsname}
  \edef\cs@xb{\csname state@#3@x\endcsname}
  \edef\cs@yb{\csname state@#3@y\endcsname}
  \edef\cs@diamb{\csname state@#3@diam\endcsname}
  \c@deltax=\cs@xb \advance\c@deltax by -\cs@xa
  \c@deltay=\cs@yb \advance\c@deltay by -\cs@ya
  \distance(\cs@xa,\cs@ya)(\cs@xb,\cs@yb)
% Calcul du point D d�finissant les tangentes de la courbe de B�zier.
  \c@aux=\prof@curve \multiply\c@aux by 2 \if#1b \c@aux=-\c@aux \fi
  \multiply\c@aux\c@deltay \divide\c@aux\@distance
  \c@xd=\cs@xa \advance\c@xd\cs@xb \divide\c@xd by 2 \advance\c@xd by -\c@aux
  \c@aux=\prof@curve \multiply\c@aux by 2 \if#1b \c@aux=-\c@aux \fi
  \multiply\c@aux\c@deltax \divide\c@aux\@distance
  \c@yd=\cs@ya \advance\c@yd\cs@yb \divide\c@yd by 2 \advance\c@yd by  \c@aux
% Dessin de l'arc de B�zier.
% Calcul des coordonn�es (\c@xc,\c@yc) du milieu de la courbe de B�zier
  \@milieutrue
  \mon@qbezier(\cs@xa,\cs@ya,\cs@diama)(\c@xd,\c@yd)(\cs@xb,\cs@yb,\cs@diamb)
% Affichage de l'�tiquette de la transition.
  \@drawlabel[#1]{#4}
  }}

\def\drawqbeziertrans{\@arrowtrue
  \@ifnextchar[{\@idrawqbeziertrans}{\@idrawqbeziertrans[l]}}
\def\@idrawqbeziertrans[#1](#2)(#3,#4)(#5)#6{{
  \if#1t \autograph@warning{t} \fi
  \if#1b \autograph@warning{b} \fi
  \d@aux=#3\unitlength \c@xd=\d@aux \divide\c@xd\d@my@unit
  \d@aux=#4\unitlength \c@yd=\d@aux \divide\c@yd\d@my@unit
  \unitlength=\d@my@unit
  \edef\cs@xa{\csname state@#2@x\endcsname}
  \edef\cs@ya{\csname state@#2@y\endcsname}
  \edef\cs@diama{\csname state@#2@diam\endcsname}
  \edef\cs@xb{\csname state@#5@x\endcsname}
  \edef\cs@yb{\csname state@#5@y\endcsname}
  \edef\cs@diamb{\csname state@#5@diam\endcsname}
  \c@deltax=\cs@xb \advance\c@deltax -\cs@xa
  \c@deltay=\cs@yb \advance\c@deltay -\cs@ya
  \distance(\cs@xa,\cs@ya)(\cs@xb,\cs@yb)
% Dessin de l'arc de B�zier.
% Calcul des coordonn�es (\c@xc,\c@yc) du milieu de la courbe de B�zier
  \@milieutrue
  \mon@qbezier(\cs@xa,\cs@ya,\cs@diama)(\c@xd,\c@yd)(\cs@xb,\cs@yb,\cs@diamb)
% Affichage de l'�tiquette de la transition.
  \@drawlabel[#1]{#6}
  }}

\def\drawcbeziertrans{\@arrowtrue
  \@ifnextchar[{\@idrawcbeziertrans}{\@idrawcbeziertrans[l]}}
\def\@idrawcbeziertrans[#1](#2)(#3,#4)(#5,#6)(#7)#8{{
  \if#1t \autograph@warning{t} \fi
  \if#1b \autograph@warning{b} \fi
  \d@aux=#3\unitlength \c@xc=\d@aux \divide\c@xc\d@my@unit
  \d@aux=#4\unitlength \c@yc=\d@aux \divide\c@yc\d@my@unit
  \d@aux=#5\unitlength \c@xd=\d@aux \divide\c@xd\d@my@unit
  \d@aux=#6\unitlength \c@yd=\d@aux \divide\c@yd\d@my@unit
  \unitlength=\d@my@unit
  \edef\cs@xa{\csname state@#2@x\endcsname}
  \edef\cs@ya{\csname state@#2@y\endcsname}
  \edef\cs@diama{\csname state@#2@diam\endcsname}
  \edef\cs@xb{\csname state@#7@x\endcsname}
  \edef\cs@yb{\csname state@#7@y\endcsname}
  \edef\cs@diamb{\csname state@#7@diam\endcsname}
% Dessin de l'arc de B�zier.
% Calcul du nombre de points � tracer et des param�tres auxiliaires
% de la courbe de B�zier.
  \cbezier@debut(\cs@xa,\cs@ya)(\c@xc,\c@yc)(\c@xd,\c@yd)(\cs@xb,\cs@yb)
% Dessin de l'arc de B�zier et  calcul des coordonn�es (\c@xc,\c@yc)
% et de la pente (\x@diff,\y@diff) du milieu de la courbe de B�zier.
  \@milieutrue
  \cbezier@fin(\cs@xa,\cs@ya,\cs@diama)(\cs@xb,\cs@yb,\cs@diamb)
% Calcul de \c@deltax, \c@deltay et \@distance pour \@drawlabel
  \c@deltax=\x@diff \divide\c@deltax\d@my@unit
  \c@deltay=\y@diff \divide\c@deltay\d@my@unit
  \sqrtandstuff{\x@diff}{\y@diff}{1\unitlength} \@distance=\num@segments
% Affichage de l'�tiquette de la transition.
  \@drawlabel[#1]{#8}
  }}

%%----------------------------------------------------------------------
%%
%% Dessin d'une boucle

\def\drawloop{\@arrowtrue\@ifnextchar[{\@idrawloop}{\@idrawloop[t]}}
\def\@idrawloop[#1](#2)#3{{
  \unitlength=\d@my@unit
  \edef\cs@xa{\csname state@#2@x\endcsname}
  \edef\cs@ya{\csname state@#2@y\endcsname}
  \edef\cs@diama{\csname state@#2@diam\endcsname}
  \c@auxa=\loop@diam \multiply\c@auxa by 2 \advance\c@auxa\cs@diama
                     \multiply\c@auxa by 2 \divide\c@auxa by 3
  \c@auxb=\loop@diam \multiply\c@auxb by 1732 \divide\c@auxb by 1000
  \if#1l
    \c@xb=\cs@xa \advance\c@xb -\c@auxa
    \c@yb=\cs@ya \advance\c@yb -\c@auxb
    \c@yd=\cs@ya \advance\c@yd  \c@auxb
    \cbezier@debut(\cs@xa,\cs@ya)(\c@xb,\c@yb)(\c@xb,\c@yd)(\cs@xa,\cs@ya)
    \@milieutrue\@arrowtrue
    \cbezier@fin(\cs@xa,\cs@ya,\cs@diama)(\cs@xa,\cs@ya,\cs@diama)
    \advance\c@xc -\trans@label@skip
    \put(\c@xc,\c@yc){\makebox(0,0)[r]{#3}}
  \fi
  \if#1r
    \c@xb=\cs@xa \advance\c@xb  \c@auxa
    \c@yb=\cs@ya \advance\c@yb  \c@auxb
    \c@yd=\cs@ya \advance\c@yd -\c@auxb
    \cbezier@debut(\cs@xa,\cs@ya)(\c@xb,\c@yb)(\c@xb,\c@yd)(\cs@xa,\cs@ya)
    \@milieutrue\@arrowtrue
    \cbezier@fin(\cs@xa,\cs@ya,\cs@diama)(\cs@xa,\cs@ya,\cs@diama)
    \advance\c@xc\trans@label@skip
    \put(\c@xc,\c@yc){\makebox(0,0)[l]{#3}}
  \fi
  \if#1t
    \c@xb=\cs@xa \advance\c@xb -\c@auxb
    \c@xd=\cs@xa \advance\c@xd  \c@auxb
    \c@yb=\cs@ya \advance\c@yb  \c@auxa
    \cbezier@debut(\cs@xa,\cs@ya)(\c@xb,\c@yb)(\c@xd,\c@yb)(\cs@xa,\cs@ya)
    \@milieutrue\@arrowtrue
    \cbezier@fin(\cs@xa,\cs@ya,\cs@diama)(\cs@xa,\cs@ya,\cs@diama)
    \advance\c@yc\trans@label@skip
    \put(\c@xc,\c@yc){\makebox(0,0)[b]{#3}}
  \fi
  \if#1b
    \c@xb=\cs@xa \advance\c@xb  \c@auxb
    \c@xd=\cs@xa \advance\c@xd -\c@auxb
    \c@yb=\cs@ya \advance\c@yb -\c@auxa
    \cbezier@debut(\cs@xa,\cs@ya)(\c@xb,\c@yb)(\c@xd,\c@yb)(\cs@xa,\cs@ya)
    \@milieutrue\@arrowtrue
    \cbezier@fin(\cs@xa,\cs@ya,\cs@diama)(\cs@xa,\cs@ya,\cs@diama)
    \advance\c@yc -\trans@label@skip
    \put(\c@xc,\c@yc){\makebox(0,0)[t]{#3}}
  \fi
}}

%%----------------------------------------------------------------------
%%
%% Graphes

\def\letvertex{
  \@ifnextchar[{\letvertex@un}{\letvertex@deux}}
\def\letvertex@un[#1] #2=(#3,#4){
  \d@aux=#3\unitlength \c@aux=\d@aux \divide\c@aux\d@my@unit
  \expandafter\edef\csname state@#2@x\endcsname{\the\c@aux}
  \d@aux=#4\unitlength \c@aux=\d@aux \divide\c@aux\d@my@unit
  \expandafter\edef\csname state@#2@y\endcsname{\the\c@aux}
  \d@aux=#1\unitlength \c@aux=\d@aux \divide\c@aux\d@my@unit
  \expandafter\edef\csname state@#2@diam\endcsname{\the\c@aux}
  }
\def\letvertex@deux #1=(#2,#3){
  \d@aux=#2\unitlength \c@aux=\d@aux \divide\c@aux\d@my@unit
  \expandafter\edef\csname state@#1@x\endcsname{\the\c@aux}
  \d@aux=#3\unitlength \c@aux=\d@aux \divide\c@aux\d@my@unit
  \expandafter\edef\csname state@#1@y\endcsname{\the\c@aux}
  \expandafter\edef\csname state@#1@diam\endcsname{\state@diam}
  }

\def\setvertexdiam{\setstatediam}
\def\setedgelabelskip{\settranslabelskip}
\def\setedgedecal{\settransdecal}
\def\drawcircledvertex{\drawstate}

\def\drawvertex(#1)#2{{
  \unitlength=\d@my@unit
  \edef\cs@x{\csname state@#1@x\endcsname}
  \edef\cs@y{\csname state@#1@y\endcsname}
  \put(\cs@x,\cs@y){\makebox(0,0){#2}}
  }}

\def\drawedge{\@arrowtrue
  \@ifnextchar[{\@idrawtrans}{\@idrawtrans[l]}}

\def\drawundirectededge{\@arrowfalse
  \@ifnextchar[{\@idrawtrans}{\@idrawtrans[l]}}

\def\drawcurvededge{\@arrowtrue
  \@ifnextchar[{\@idrawcurvedtrans}{\@idrawcurvedtrans[l]}}

\def\drawundirectedcurvededge{\@arrowfalse
  \@ifnextchar[{\@idrawcurvedtrans}{\@idrawcurvedtrans[l]}}

\def\drawqbezieredge{\@arrowtrue
  \@ifnextchar[{\@idrawqbeziertrans}{\@idrawqbeziertrans[l]}}

\def\drawundirectedqbezieredge{\@arrowfalse
  \@ifnextchar[{\@idrawqbeziertrans}{\@idrawqbeziertrans[l]}}

\def\drawcbezieredge{\@arrowtrue
  \@ifnextchar[{\@idrawcbeziertrans}{\@idrawcbeziertrans[l]}}

\def\drawundirectedcbezieredge{\@arrowfalse
  \@ifnextchar[{\@idrawcbeziertrans}{\@idrawcbeziertrans[l]}}

\def\drawundirectedloop{\@arrowfalse
  \@ifnextchar[{\@idrawloop}{\@idrawloop[t]}}

%%----------------------------------------------------------------------
%%
%% Miscellanees
%%
%% Note: Certaines macros utilisent des variables d�clar�es dans epic.
%%
%% \vecslope(x@diff dimen, y@diff dimen)
%% Inspir� de \lineslope de epic.sty.
%% Utilise des variables declar�es dans epic.sty.
%% Les commentaires ci-dessous sont ceux de \lineslope.
%%
%% Given base (x@diff) and height (y@diff) in dimensions, determines the
%% closest available slope and returns the two required integers in \@xarg
%% and \@yarg. The given base and height can be ANYTHING, -ve or +ve, or
%% even 0pt. \lineslope knows about (0,1) and (1,0) slopes too and returns
%% correct values if the conditions regarding x@diff & y@diff are obeyed
%% (see NOTE). Used by \drawline. This is the simplest and only way I could
%% figure out to accomplish it!.
%% NOTE: both the dimensions (x@diff & y@diff) must be in SAME units and the
%% larger of the two dimensions must be atleast 1pt (i.e. 65536sp). To avoid
%% dividing by 0, I make the larger dimension = 1pt if it is < 1pt.
%% will need a similar one for vectors, or maybe this can be used. For
%% vectors the range is -4, 4 unlike lines where it is -6, 6.
%\newif\if@flippedargs
\def\vecslope(#1,#2){%
\ifdim #1 <0pt \@xdim= -#1 \else\@xdim=#1\fi
\ifdim #2 <0pt \@ydim= -#2 \else\@ydim=#2\fi
%%\typeout{xdim,ydim= \the\@xdim, \the\@ydim}
\ifdim\@xdim >\@ydim \@tempdima=\@xdim \@xdim=\@ydim \@ydim=\@tempdima
\@flippedargstrue\else\@flippedargsfalse\fi% x < y
\ifdim\@ydim >1pt \@tempcnta=\@ydim
            \divide\@tempcnta by 65536% now \@tempcnta=integral part of #1.
            \divide\@xdim \@tempcnta\fi
\ifdim\@xdim <.125pt          \@xarg=1 \@yarg=0
 \else\ifdim\@xdim <.291666pt \@xarg=4 \@yarg=1
 \else\ifdim\@xdim <.416666pt \@xarg=3 \@yarg=1
 \else\ifdim\@xdim <.583333pt \@xarg=2 \@yarg=1
 \else\ifdim\@xdim <.708333pt \@xarg=3 \@yarg=2
 \else\ifdim\@xdim <.875pt    \@xarg=4 \@yarg=3
 \else                        \@xarg=1 \@yarg=1%
\fi\fi\fi\fi\fi\fi
\if@flippedargs\relax\else\@tempcnta=\@xarg \@xarg=\@yarg
                          \@yarg=\@tempcnta\fi
\ifdim #1 <0pt \@xarg= -\@xarg\fi
\ifdim #2 <0pt \@yarg= -\@yarg\fi
%%\typeout{closest slope integers = \the\@xarg, \the\@yarg}
}

%% \drawvector:
%%        Dessine un vecteur entre les points sp�cifi�s. 
%%        Aucune limitation sur la pente. 
%% ex: \drawvector(10,70)(70,20)
%%
\def\drawvector(#1,#2)(#3,#4){%
 \drawline(#1,#2)(#3,#4)
 \x@diff=#3\unitlength \advance\x@diff by -#1\unitlength
 \y@diff=#4\unitlength \advance\y@diff by -#2\unitlength
 \vecslope(\x@diff,\y@diff)% returns the two integers in \@xarg & \@yarg.
 \put(#3,#4){\vector(\@xarg,\@yarg){0}}
}

%% \distance: Calcule la distance en \unitlength entre deux points. 
%% Le r�sultat se trouve dans \@distance.
%%
\newcount\@distance
\def\distance(#1,#2)(#3,#4){
  \x@diff=#3\unitlength\relax\advance\x@diff by -#1\unitlength\relax
  \y@diff=#4\unitlength\relax\advance\y@diff by -#2\unitlength\relax
  \sqrtandstuff{\x@diff}{\y@diff}{1\unitlength}
  \@distance=\num@segments
%%\typeout{distance = \the\@distance}
}

% Affichage de l'�tiquette d'une transition.
% #1 est une lettre parmi l(eft), r(ight) qui sp�cifie o� se trouve l'�tiquette 
% par rapport � la transition lorsqu'on regarde dans le sens de la transition.
% #2 est l'�tiquette de la transition.
% On utilise,
% - les coordonn�es (\c@xc,\c@yc) du point C centre de la transition
% - \c@deltax et \c@deltay qui d�finissent la tangente au point C
% - \@distance qui donne l'hypothenuse correspondant � \c@deltax et \c@deltay.
\def\@drawlabel[#1]#2{{
% Calcul du d�placement de l'�tiquette par rapport au point C
  \setbox\temp@box\hbox{#2}
  \c@auxa=\wd\temp@box
  \divide\c@auxa\d@my@unit \multiply\c@auxa\c@deltay
  \ifnum\c@auxa<0 \c@auxa=-\c@auxa \fi
  \c@auxc=\ht\temp@box \advance\c@auxc by \dp\temp@box
  \divide\c@auxc\d@my@unit \multiply\c@auxc\c@deltax
  \ifnum\c@auxc<0 \c@auxc=-\c@auxc \fi
  \advance\c@auxc\c@auxa \divide\c@auxc\@distance \divide\c@auxc by 2
  \advance\c@auxc\trans@label@skip
  \c@auxa=-\c@deltay \multiply\c@auxa\c@auxc \divide\c@auxa\@distance
  \c@auxb=\c@deltax \multiply\c@auxb\c@auxc \divide\c@auxb\@distance
  \if#1r \c@auxa=-\c@auxa \c@auxb=-\c@auxb \fi
  \if#1b \c@auxa=-\c@auxa \c@auxb=-\c@auxb \fi
% On d�place le point C et on affiche l'�tiquette de la transition.
  \advance\c@xc\c@auxa \advance\c@yc\c@auxb
  \put(\c@xc,\c@yc){\makebox(0,0){#2}}
  }}

%% Courbe de B�zier quadratique. Inspir� de \qbezier (latex2e).
%%
%% Calcule automatiquement le nombre de points � tracer.
%% Trace une portion de la courbe de B�zier quadratique d�finie par
%% les points (#1,#2), (#4,#5) et (#6,#7).
%% Les param�tres #3 et #8 sont les diam�tres des cercles centr�s
%% en (#1,#2) et (#6,#7) d�finissant les extr�mit�s de la courbe trac�e.
%% Si \@arrowtrue, on ajoute une fl�che � la fin de la courbe.
%% Si \@milieutrue, retourne dans (\c@xc,\c@yc) les coordonn�es en 
%% \unitlength du milieu de la courbe de B�zier.

\newcount\nb@pt \newcount\nb@pt@p
\newcount\t@ \newcount\t@un \newcount\t@deux
\newdimen\r@square
\newdimen\d@x \newdimen\d@xa \newdimen\d@xb
\newdimen\d@y \newdimen\d@ya \newdimen\d@yb
\newsavebox{\box@pt}

\def\mon@qbezier(#1,#2,#3)(#4,#5)(#6,#7,#8){
% \typeout{(\the #1,\the #2,\the #3)(\the #4,\the #5)(\the #6,\the #7,\the #8)}
% Calcul du nombre de points � tracer
  \nb@pt=#6 \advance\nb@pt -#4
  \ifnum\nb@pt<0 \nb@pt -\nb@pt \fi
  \c@auxb=#4 \advance\c@auxb -#1
  \advance\nb@pt \ifnum\c@auxb<0 -\c@auxb \else \c@auxb \fi
  \c@auxb=#7 \advance\c@auxb -#5
  \advance\nb@pt \ifnum\c@auxb<0 -\c@auxb \else \c@auxb \fi
  \c@auxb=#5 \advance\c@auxb -#2
  \advance\nb@pt \ifnum\c@auxb<0 -\c@auxb \else \c@auxb \fi
  \multiply\nb@pt\unitlength \divide\nb@pt\@wholewidth
% \typeout{nombre de points � tracer = \the\nb@pt}
  \ifnum\nb@pt>\max@bezier \nb@pt=\max@bezier \fi
% Calcul de param�tres auxiliaires
  \d@xb=#4\unitlength \advance\d@xb -#1\unitlength \multiply\d@xb \tw@
  \d@xa=#6\unitlength \advance\d@xa -#1\unitlength
                      \advance\d@xa -\d@xb \divide\d@xa\nb@pt
  \d@yb=#5\unitlength \advance\d@yb -#2\unitlength \multiply\d@yb \tw@
  \d@ya=#7\unitlength \advance\d@ya -#2\unitlength
                      \advance\d@ya -\d@yb \divide\d@ya\nb@pt
  \if@milieu
% Calcul des coordonn�es (\c@xc,\c@yc) du milieu de la courbe de B�zier
	  \t@=\nb@pt \divide\t@ by 2
	  \d@x=\t@\d@xa \advance\d@x\d@xb \divide\d@x\nb@pt \multiply\d@x\t@
	  \advance\d@x #1\unitlength \c@xc=\d@x \divide\c@xc\unitlength
	  \d@y=\t@\d@ya \advance\d@y\d@yb \divide\d@y\nb@pt \multiply\d@y\t@
	  \advance\d@y #2\unitlength \c@yc=\d@y \divide\c@yc\unitlength
  \fi
% Calcul de l'indice du dernier point � tracer
  \ifnum#8=0 \nb@pt@p=\nb@pt \else
    \r@square=#8\unitlength \divide\r@square\tw@
    \divide\r@square\@halfwidth \multiply\r@square\r@square
    \t@un=0 \t@deux=\nb@pt
    \@whilenum{\t@un<\t@deux}\do
      {\t@=\t@un \advance\t@\t@deux \divide\t@\tw@
      \ifnum\t@=\t@un \t@deux=\t@un \else
        \d@x=\t@\d@xa \advance\d@x\d@xb \divide\d@x\nb@pt \multiply\d@x\t@
        \advance\d@x #1\unitlength \advance\d@x -#6\unitlength
        \d@y=\t@\d@ya \advance\d@y\d@yb \divide\d@y\nb@pt \multiply\d@y\t@
        \advance\d@y #2\unitlength \advance\d@y -#7\unitlength
        \divide\d@x\@halfwidth \multiply\d@x\d@x
        \divide\d@y\@halfwidth \multiply\d@y\d@y
        \advance\d@x\d@y
        \ifdim\d@x>\r@square \t@un=\t@ \else \t@deux=\t@ \fi
      \fi}
    \nb@pt@p=\t@un
  \fi
% \typeout{dernier point � tracer = \the\nb@pt@p}
  \advance\nb@pt@p\@ne
% Calcul de l'indice du premier point � tracer
  \ifnum#3=0 \t@=0 \else
    \r@square=#3\unitlength \divide\r@square\tw@
    \divide\r@square\@halfwidth \multiply\r@square\r@square
    \t@un=0 \t@deux=\nb@pt
    \@whilenum{\t@un<\t@deux}\do
      {\t@=\t@un \advance\t@\t@deux \divide\t@\tw@
       \ifnum\t@=\t@un \t@un=\t@deux \else
         \d@x=\t@\d@xa \advance\d@x\d@xb \divide\d@x\nb@pt \multiply\d@x\t@
         \d@y=\t@\d@ya \advance\d@y\d@yb \divide\d@y\nb@pt \multiply\d@y\t@
         \divide\d@x\@halfwidth \multiply\d@x\d@x
         \divide\d@y\@halfwidth \multiply\d@y\d@y
         \advance\d@x\d@y
         \ifdim\d@x<\r@square \t@un=\t@ \else \t@deux=\t@ \fi
       \fi}
    \t@\t@un
  \fi
% \typeout{premier point � tracer = \the\t@}
% Calcul et dessin des points de la courbe
  \setbox\box@pt\hbox{\vrule height\@halfwidth  depth\@halfwidth
                             width\@wholewidth}
  \put(#1,#2){\@whilenum{\t@<\nb@pt@p}\do
      {\d@x=\t@\d@xa \advance\d@x\d@xb \divide\d@x\nb@pt \multiply\d@x\t@
       \d@y=\t@\d@ya \advance\d@y\d@yb \divide\d@y\nb@pt \multiply\d@y\t@
       \raise \d@y \hbox to \z@{\kern\d@x \unhcopy\box@pt\hss}%
       \advance\t@\@ne}}
% Dessin de la fl�che au bout de la courbe de B�zier
  \if@arrow
% Calcul de l'extr�mit� de la fl�che
    \t@=\nb@pt@p \advance\t@ -\@ne
    \d@x=\t@\d@xa \advance\d@x\d@xb \divide\d@x\nb@pt \multiply\d@x\t@
    \advance\d@x #1\unitlength \t@un=\d@x
    \d@y=\t@\d@ya \advance\d@y\d@yb \divide\d@y\nb@pt \multiply\d@y\t@
    \advance\d@y #2\unitlength \t@deux=\d@y
% Calcul de la pente de la fl�che
    \d@x=\t@\d@xa \multiply\d@x\tw@ \advance\d@x\d@xb
    \d@y=\t@\d@ya \multiply\d@y\tw@ \advance\d@y\d@yb
    \vecslope(\d@x,\d@y)% returns the integers in \@xarg & \@yarg.
    {\divide\t@un\d@my@unit \divide\t@deux\d@my@unit
    \unitlength=\d@my@unit \put(\t@un,\t@deux){\vector(\@xarg,\@yarg){0}}}
  \fi
}

%% Courbe de B�zier quadratique avec une fl�che au bout.
%% Le nombre maximum de points de la courbe est command� par \setmaxbezier.

\def\qbeziervector(#1,#2)(#3,#4)(#5,#6){{
  \@milieufalse\@arrowtrue
  \mon@qbezier(#1,#2,0)(#3,#4)(#5,#6,0)
}}

%% Courbe de B�zier cubique.
%%
%% La macro a �t� coup�e en deux car elle n�cessite 10 param�tres.
%% Il faut donc appeler cons�cutivement \cbezier@debut et \cbezier@fin.
%%
%% \cbezier@debut calcule le nombre de points � tracer et les param�tres
%% auxiliaires pour la courbe de B�zier cubique d�finie par
%% les points (#1,#2), (#3,#4), (#5,#6), (#7,#8).

\newdimen\d@xc \newdimen\d@yc

\def\cbezier@debut(#1,#2)(#3,#4)(#5,#6)(#7,#8){
% Calcul du nombre de points � tracer
  \nb@pt=#3 \advance\nb@pt -#1
  \ifnum\nb@pt<0 \nb@pt -\nb@pt \fi
  \c@auxb=#5 \advance\c@auxb -#3
  \advance\nb@pt \ifnum\c@auxb<0 -\c@auxb \else \c@auxb \fi
  \c@auxb=#7 \advance\c@auxb -#5
  \advance\nb@pt \ifnum\c@auxb<0 -\c@auxb \else \c@auxb \fi
  \c@auxb=#4 \advance\c@auxb -#2
  \advance\nb@pt \ifnum\c@auxb<0 -\c@auxb \else \c@auxb \fi
  \c@auxb=#6 \advance\c@auxb -#4
  \advance\nb@pt \ifnum\c@auxb<0 -\c@auxb \else \c@auxb \fi
  \c@auxb=#8 \advance\c@auxb -#6
  \advance\nb@pt \ifnum\c@auxb<0 -\c@auxb \else \c@auxb \fi
  \multiply\nb@pt\unitlength \divide\nb@pt\@wholewidth
% \typeout{nombre de points � tracer = \the\nb@pt}
  \ifnum\nb@pt>\max@bezier \nb@pt=\max@bezier \fi
% Calcul de param�tres auxiliaires
  \d@xa #3\unitlength \advance\d@xa -#5\unitlength \multiply\d@xa by 3
  \advance\d@xa #7\unitlength \advance\d@xa -#1\unitlength \divide\d@xa\nb@pt
  \d@xb -#3\unitlength \multiply\d@xb by 2 \advance\d@xb #1\unitlength
  \advance\d@xb #5\unitlength \multiply\d@xb by 3
  \d@xc #3\unitlength \advance\d@xc -#1\unitlength \multiply\d@xc by 3
  \d@ya #4\unitlength \advance\d@ya -#6\unitlength \multiply\d@ya by 3
  \advance\d@ya #8\unitlength \advance\d@ya -#2\unitlength \divide\d@ya\nb@pt
  \d@yb -#4\unitlength \multiply\d@yb by 2 \advance\d@yb #2\unitlength
  \advance\d@yb #6\unitlength \multiply\d@yb by 3
  \d@yc #4\unitlength \advance\d@yc -#2\unitlength \multiply\d@yc by 3
}

%% \cbezier@fin(#1,#2,#3)(#4,#5,#6) trace une portion de la courbe
%% de B�zier cubique dont les param�tres ont �t� d�finis dans
%% le pr�c�dent appel � \cbezier@debut.
%% Les param�tres #3 et #6 sont les diam�tres des cercles centr�s
%% en (#1,#2) et (#4,#5) d�finissant les extr�mit�s de la courbe trac�e.
%% Si \@arrowtrue, on ajoute une fl�che � la fin de la courbe.
%% Si \@milieutrue, retourne dans (\c@xc,\c@yc) les coordonn�es en 
%% \unitlength du milieu de la courbe de B�zier et dans (\c@deltax,\c@deltay)
%% la pente au milieu de la courbe de B�zier.

\def\cbezier@fin(#1,#2,#3)(#4,#5,#6){
  \if@milieu
% Calcul des coordonn�es (\c@xc,\c@yc) du milieu de la courbe de B�zier
	  \t@\nb@pt \divide\t@ by 2
	  \d@x\t@\d@xa \advance\d@x\d@xb \divide\d@x\nb@pt \multiply\d@x\t@
	  \advance\d@x\d@xc \divide\d@x\nb@pt \multiply\d@x\t@
	  \advance\d@x #1\unitlength \c@xc=\d@x \divide\c@xc\unitlength
	  \d@y\t@\d@ya \advance\d@y\d@yb \divide\d@y\nb@pt \multiply\d@y\t@
	  \advance\d@y\d@yc \divide\d@y\nb@pt \multiply\d@y\t@
	  \advance\d@y #2\unitlength \c@yc=\d@y \divide\c@yc\unitlength
% Calcul de la pente (\x@diff,\y@diff) du milieu de la courbe de B�zier
	  \d@x\t@\d@xa \multiply\d@x by 3 \advance\d@x\d@xb \advance\d@x\d@xb
	  \divide\d@x\nb@pt \multiply\d@x\t@ \advance\d@x\d@xc \x@diff=\d@x
	  \d@y\t@\d@ya \multiply\d@y by 3 \advance\d@y\d@yb \advance\d@y\d@yb
	  \divide\d@y\nb@pt \multiply\d@y\t@ \advance\d@y\d@yc \y@diff=\d@y
  \fi
% Calcul de l'indice du dernier point � tracer
  \ifnum#6=0 \nb@pt@p=\nb@pt \else
	\r@square=#6\unitlength \divide\r@square\tw@
	\divide\r@square\@halfwidth \multiply\r@square\r@square
	\t@un=0 \t@deux=\nb@pt
	\@whilenum{\t@un<\t@deux}\do
	 {\t@=\t@un \advance\t@\t@deux \divide\t@\tw@
	  \ifnum\t@=\t@un \t@deux=\t@un \else
	    \d@x=\t@\d@xa \advance\d@x\d@xb \divide\d@x\nb@pt \multiply\d@x\t@
	    \advance\d@x\d@xc \divide\d@x\nb@pt \multiply\d@x\t@
	    \advance\d@x #1\unitlength \advance\d@x -#4\unitlength
	    \d@y=\t@\d@ya \advance\d@y\d@yb \divide\d@y\nb@pt \multiply\d@y\t@
	    \advance\d@y\d@yc \divide\d@y\nb@pt \multiply\d@y\t@
	    \advance\d@y #2\unitlength \advance\d@y -#5\unitlength
	    \divide\d@x\@halfwidth \multiply\d@x\d@x
	    \divide\d@y\@halfwidth \multiply\d@y\d@y
	    \advance\d@x\d@y
	    \ifdim\d@x>\r@square \t@un\t@ \else \t@deux\t@ \fi
	  \fi}
	\nb@pt@p=\t@un
  \fi
% \typeout{dernier point � tracer = \the\nb@pt@p}
  \advance\nb@pt@p\@ne
% Calcul de l'indice du premier point � tracer
  \ifnum#3=0 \t@=0 \else
	\r@square=#3\unitlength \divide\r@square\tw@
	\divide\r@square\@halfwidth \multiply\r@square\r@square
	\t@un=0 \t@deux=\nb@pt
	\@whilenum{\t@un<\t@deux}\do
	 {\t@=\t@un \advance\t@\t@deux \divide\t@\tw@
	  \ifnum\t@=\t@un \t@un=\t@deux \else
	    \d@x=\t@\d@xa \advance\d@x\d@xb \divide\d@x\nb@pt \multiply\d@x\t@
	    \advance\d@x\d@xc \divide\d@x\nb@pt \multiply\d@x\t@
	    \d@y=\t@\d@ya \advance\d@y\d@yb \divide\d@y\nb@pt \multiply\d@y\t@
	    \advance\d@y\d@yc \divide\d@y\nb@pt \multiply\d@y\t@
	    \divide\d@x\@halfwidth \multiply\d@x\d@x
	    \divide\d@y\@halfwidth \multiply\d@y\d@y
	    \advance\d@x\d@y
	    \ifdim\d@x<\r@square \t@un\t@ \else \t@deux\t@ \fi
	  \fi}
	\t@=\t@un
  \fi
% \typeout{premier point � tracer = \the\t@}
% Calcul et dessin des points de la courbe
  \setbox\box@pt\hbox{\vrule height\@halfwidth  depth\@halfwidth
                             width\@wholewidth}
  \put(#1,#2){\@whilenum{\t@<\nb@pt@p}\do
      {\d@x=\t@\d@xa \advance\d@x\d@xb \divide\d@x\nb@pt \multiply\d@x\t@
       \advance\d@x\d@xc \divide\d@x\nb@pt \multiply\d@x\t@
       \d@y=\t@\d@ya \advance\d@y\d@yb \divide\d@y\nb@pt \multiply\d@y\t@
       \advance\d@y\d@yc \divide\d@y\nb@pt \multiply\d@y\t@
       \raise \d@y \hbox to \z@{\kern\d@x \unhcopy\box@pt\hss}%
       \advance\t@\@ne}}
% Dessin de la fl�che au bout de la courbe de B�zier
  \if@arrow
% Calcul de l'extr�mit� de la fl�che
	  \t@=\nb@pt@p \advance\t@ -\@ne
	  \d@x=\t@\d@xa \advance\d@x\d@xb \divide\d@x\nb@pt \multiply\d@x\t@
	  \advance\d@x\d@xc \divide\d@x\nb@pt \multiply\d@x\t@
	  \advance\d@x #1\unitlength \t@un=\d@x
	  \d@y=\t@\d@ya \advance\d@y\d@yb \divide\d@y\nb@pt \multiply\d@y\t@
	  \advance\d@y\d@yc \divide\d@y\nb@pt \multiply\d@y\t@
	  \advance\d@y #2\unitlength \t@deux=\d@y
% Calcul de la pente de la fl�che
	  \d@x=\t@\d@xa \multiply\d@x by 3 \advance\d@x\d@xb \advance\d@x\d@xb
	  \divide\d@x\nb@pt \multiply\d@x\t@ \advance\d@x\d@xc
	  \d@y=\t@\d@ya \multiply\d@y by 3 \advance\d@y\d@yb \advance\d@y\d@yb
	  \divide\d@y\nb@pt \multiply\d@y\t@ \advance\d@y\d@yc
	  \vecslope(\d@x,\d@y)% returns the integers in \@xarg & \@yarg.
      {\divide\t@un\d@my@unit \divide\t@deux\d@my@unit
      \unitlength=\d@my@unit \put(\t@un,\t@deux){\vector(\@xarg,\@yarg){0}}}
  \fi
}

%% Courbe de B�zier cubique avec ou sans fl�che au bout.
%% Le nombre maximum de points de la courbe est command� par \setmaxbezier.

\def\cbezier(#1,#2)(#3,#4)(#5,#6)(#7,#8){{
  \@milieufalse\@arrowfalse
  \cbezier@debut(#1,#2)(#3,#4)(#5,#6)(#7,#8)
  \cbezier@fin(#1,#2,0)(#7,#8,0)
}}

\def\cbeziervector(#1,#2)(#3,#4)(#5,#6)(#7,#8){{
  \@milieufalse\@arrowtrue
  \cbezier@debut(#1,#2)(#3,#4)(#5,#6)(#7,#8)
  \cbezier@fin(#1,#2,0)(#7,#8,0)
}}

\endinput
