Plan 9 from Bell Labs’s /usr/web/sources/contrib/steve/root/sys/lib/texmf/tex/generic/xypic/xyarc.tex

Copyright © 2021 Plan 9 Foundation.
Distributed under the MIT License.
Download the Plan 9 distribution.


%% xyarc.tex from $Id: xyarc.doc,v 3.3 1996/12/18 14:21:23 ross Exp $
%%
%% Xy-pic ``Circles, Ellipses and Arcs'' feature.
%% Copyright (c) 1995-1996 Ross Moore <ross@mpce.mq.edu.au>
%%
%% This file is part of the Xy-pic package for graphs and diagrams in TeX.
%% See the companion README and INSTALL files for further information.
%% Copyright (c) 1991-1996 Kristoffer H. Rose <krisrose@brics.dk>
%%
%% The XY-pic package is free software; you can redistribute it and/or modify
%% it under the terms of the GNU General Public License as published by the
%% Free Software Foundation; either version 2 of the License, or (at your
%% option) any later version.
%%
%% The XY-pic package is distributed in the hope that it will be useful, but
%% WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
%% or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
%% for more details.
%%
%% You should have received a copy of the GNU General Public License along
%% with this package; if not, write to the Free Software Foundation, Inc.,
%% 675 Mass Ave, Cambridge, MA 02139, USA.
%%
\ifx\xyloaded\undefined \input xy \fi
\xyprovide{arc}{Circle, Ellipse and Arc feature}{\stripRCS$Revision: 3.3 $}%
 {Ross Moore}{ross@mpce.mq.edu.au}%
 {Mathematics Department, Macquarie University, NSW~2109, Australia}
\xyrequire{curve}
\xycatcodes
\xydef@\ellipse#1#{\xy@{ELLIPSE}{\hbox\bgroup\save@}%
 \let\endarc@=\endellipse@@ \xyFN@\preARC@ #1@}
\xydef@\endellipse@@{\xy@{endELLIPSE}{\leave@\origDirection@
 \edef\next@{\egroup \X@min=\the\X@min \X@max=\the\X@max
 \Y@min=\the\Y@min \Y@max=\the\Y@max }\next@}\let\bstartPLACE@=\relax}
\xydef@\preARC@{%
 \ifx\next\space@ \expandafter\DN@\space{\xyFN@\preARC@}%
 \else\ifx\next @\DN@{\xy@{ellipseARC}\ellipticARC@ \arc@}%
 \else\ifx\next ~\DN@~##1{\tildeARC@{##1}}%
 \else\DN@{\xy@{ellipticARC}\ellipticARC@ \arc@}%
 \fi\fi\fi \next@ }
\xydef@\arc@#1@#2{\xy@{arcSTYLE}{\def\arcSTYLE{#2}}\arc@i
 \DNii@{#1}%
 \ifx\nextii@\empty \DN@{\fullCircle@}%
 \else \DN@{_}%
 \ifx\next@\nextii@ \xy@{_}{\def\arcOrient@@{_}}%
 \let\arcOrient@@=\next@ \DN@{\fullCircle@}%
 \else \DN@{^}%
 \ifx\next@\nextii@ \xy@{^}{\def\arcOrient@@{^}}%
 \let\arcOrient@@=\next@ \DN@{\fullCircle@}%
 \else \DN@{\def\afterARCextents@@{%
 \xy@{aftARCext}{\let\doCircleArc@=\doCircleArc@@}%
 \ellipseArc@
 \xy@{doCircARCs}{\leave@ \doCircleArcs@}\endarc@ }%
 \xyFN@\getarcparams@#1@}\fi\fi\fi
 \next@ }
\xydef@\arc@i{\xy@{ARCi}{%
 \save@\idfromc@{0@c}\cfromp@\idfromc@{0@p}%
 \enter@\cplusthec@ \enter@\relax\begingroup\vfromslide@i{}@\czeroEdge@ 
 \leave@\idfromc@{0@m}\leave@ \zeroDivideLimit@{50}%
 \edef\origDirection@{\Direction=\the\Direction
 \relax\noexpand\imposeDirection@}%
 \let\startDirection@=\origDirection@ \def\startDirection@@{}%
 \def\endDirection@{}\def\endDirection@@{}\def\arcOrient@@{^}}%
 \def\arcOrient@@{^}\let\processDirections@=\checkstartDirection@ 
 \def\arcRadius@{}\def\ellipseRatio@{}\def\arcScale@{\arcScale@@}}
\message{circles,}
\xydef@\fullCircle@{\xy@{fullCIRC}{\let\endDirection@=\relax
 \let\doCircleArc@=\doMergeEndArc@@}\circleArc@ }%
\xydef@\getarcparams@{%
 \ifx\space@\next \expandafter\DN@\space{\xyFN@\getarcparams@}%
 \else\addLT@\ifx \next \xy@{<}{}%
 \addGT@{\addLT@\DN@##1}{\splitRadius@dim##1,,@}%
 \else\ifx\next (\DN@({\xyFN@\checkRadOpen@}%
 \else\ifx\next @\xy@{@}{}\DN@ @{\fullEllipse@}%
 \else \addLQ@\ifx \next \addLQ@\DN@{\xy@`{}\ARCturn@}%
 \else \DN@{\getarcExtents@}%
 \fi\fi\fi\fi\fi \next@ }
\xydef@\checkRadOpen@{%
 \ifx\next *\DN@{\xyFN@\getarcExtents@ (}%
 \else \xy@{(}{}\DN@##1){\splitRadius@##1,,@}%
 \fi \next@ }
\xydef@\fixedRadiusArc@{%
 \xy@{fixRadArc}{\save@ \idfromc@{0@0}\cfromp@\idfromc@{0@c}\leave@}%
 \xyFN@\fixedRadiusArc@i }
\xydef@\fixedRadiusArc@i{%
 \ifx\next\space@ \expandafter\DN@\space{\xyFN@\fixedRadiusArc@i}%
 \else\ifx\next @\xy@{@}{}\DN@ @{\fullEllipse@}%
 \else\DN@{\let\processDirections@=\processArcDirections@
 \def\afterARCextents@@{\xy@{aftARCext}{\let\doCircleArc@=\doCircleArc@@ 
 \ellipseSector@}}\xyFN@\getarcExtents@}%
 \fi\fi \next@ }
\xydef@\arcScale@@{\xy@{arcSCALE@@}{\save@
 \cfromid@{0@0}\pfromc@\cfromid@{0@p}\setbase@\X@p\Y@p\X@c\Y@c}}
\xydef@\arcScale@dim#1{\xy@{arcSCALEdim}{\save@\cfromid@{0@0}\pfromc@
 \cfromid@{0@p}\setupDirection@\cfromp@ \enter@\cplusthec@
 \enter@\relax\begingroup\vfromslide@i#1@\leave@
 \setbase@\X@p\Y@p\X@c\Y@c \idfromc@{0@p}}}
\xydef@\ellipseScale@dim#1{\xy@{ellSCALEdim}{\setupDirection@\cfromp@ 
 \enter@\cplusthec@ \aboveDirection@\xydashl@ \vfromslide@{#1}\leave@
 \setbase@@\X@c\Y@c}}
\xydef@\ellipseScale@#1{\xy@{ellSCALE@}%
 {\vfromcartesian@@0,#1@\setbase@@\X@c\Y@c}}
\xydef@\splitRadius@dim#1,#2,#3@{%
 \DN@{#1}\ifx\next@\empty\dimen@=\z@\else\dimen@=#1\relax%\splinetracing 
 \expandafter\def\expandafter\arcRadius@
 \expandafter{\arcScale@dim{#1}}\fi
 \DN@{#2}\ifx\next@\empty\dimen@ii=\z@\def\ellipseRatio@{}%
 \else\dimen@ii=#2\relax \expandafter
 \def\expandafter\ellipseRatio@\expandafter{\ellipseScale@dim{#2}}%
 \fi \fixedRadiusArc@ }
\xydef@\splitRadius@#1,#2,#3@{%
 \DN@{#1}\ifx\next@\empty\dimen@=\z@\else\dimen@=#1\p@\relax\fi
 \DN@{#2}\ifx\next@\empty\dimen@ii=\z@\else\dimen@ii=#2\p@\relax\fi 
 \ifdim\dimen@=\z@ \ifdim\dimen@ii=\z@\else \expandafter
 \def\expandafter\ellipseRatio@\expandafter{\ellipseScale@{#2}}\fi
 \else
 \ifdim\dimen@ii=\z@
 \def\arcScale@{\xy@{arcSCALE@}{\save@\cfromid@{0@0}%
 \X@origin=\X@c \Y@origin=\Y@c
 \X@xbase=#1\X@xbase \Y@xbase=#1\Y@xbase
 \X@ybase=#1\X@ybase \Y@ybase=#1\Y@ybase 
 \advance\X@c\X@xbase \advance\Y@c\Y@xbase \czeroEdge@
 \idfromc@{0@p}\idfromc@{0@c}}}%
 \else
 \def\arcScale@{\xy@{arcSCALE@}{\save@\cfromid@{0@0}%
 \X@origin=\X@c \Y@origin=\Y@c
 \X@xbase=#1\X@xbase \Y@xbase=#1\Y@xbase
 \X@ybase=#2\X@ybase \Y@ybase=#2\Y@ybase 
 \advance\X@c\X@xbase \advance\Y@c\Y@xbase \czeroEdge@
 \idfromc@{0@p}\idfromc@{0@c}}}%
 \fi
 \fi \fixedRadiusArc@ }
\xydef@\baseOrient@{\DN@{_}\ifx\next@\arcOrient@@
 \X@ybase=-\X@ybase \Y@ybase=-\Y@ybase \fi }
\message{ellipses,}
\xydef@\fullEllipse@{\xy@{fullELLIPSE}%
 {\def\startDirection@{}\let\doCircleArc@=\doMergeEndArc@@}%
 \ellipseArc@
 \xy@{doCIRCarcs}{\leave@ \doCircleArcs@}\endarc@ }
\xydef@\ellipseArc@{%
 \arcScale@ \arcRadius@ \ellipseRatio@
 \xy@{arcCONTROLS}{\baseOrient@ \arcControls@ \let\bstartPLACE@=\relax }}
\xydef@\cubicARCcontrols@@{\czeroEdge@
 \vfromcartesian@@0,1@\idfromc@{1@c}%
 \vfromcartesian@@-1,0@\idfromc@{2@c}%
 \vfromcartesian@@0,-1@\idfromc@{3@c}%
 \vfromcartesian@@1,\arcparam@ @\idfromc@{1@m}%
 \vfromcartesian@@\arcparam@,1@\idfromc@{2@m}%
 \vfromcartesian@@-\arcparam@,1@\idfromc@{3@m}%
 \vfromcartesian@@-1,\arcparam@ @\idfromc@{4@m}%
 \vfromcartesian@@-1,-\arcparam@ @\idfromc@{5@m}%
 \vfromcartesian@@-\arcparam@,-1@\idfromc@{6@m}%
 \vfromcartesian@@\arcparam@,-1@\idfromc@{7@m}%
 \vfromcartesian@@1,-\arcparam@ @\idfromc@{8@m}%
 }
\xydef@\doCircleArc@@#1#2{\save@ \ifcase#2\relax
 \doCircleArc@@@{0@p}{1@m}{2@m}{1@c}{#1}\or
 \doCircleArc@@@{1@c}{3@m}{4@m}{2@c}{#1}\or
 \doCircleArc@@@{2@c}{5@m}{6@m}{3@c}{#1}\or
 \doCircleArc@@@{3@c}{7@m}{8@m}{0@p}{#1}\or
 \doCircleArc@@@{0@p}{1@m}{2@m}{1@c}{#1}\or
 \doCircleArc@@@{1@c}{3@m}{4@m}{2@c}{#1}\or
 \doCircleArc@@@{2@c}{5@m}{6@m}{3@c}{#1}\or
 \doCircleArc@@@{3@c}{7@m}{8@m}{0@p}{#1}\fi \leave@ }
\xydef@\doCircleArc@@@#1#2#3#4#5{%
 \cfromid@{#1}\pfromc@\senter@
 \cfromid@{#2}\spushc@\cfromid@{#3}\spushc@\cfromid@{#4}%
 \connect@\crvs{#5}\relax\sinit@\sleave@}
\xydef@\doMergeEndArc@@#1#2{\save@\ifcase#2\relax
 \doMergeEnd@@@{0@p}{1@m}{2@m}{1@c}{#1}\relax\or
 \doMergeEnd@@@{1@c}{3@m}{4@m}{2@c}{#1}\relax\or
 \doMergeEnd@@@{2@c}{5@m}{6@m}{3@c}{#1}\relax\or
 \doMergeEnd@@@{3@c}{7@m}{8@m}{0@p}{#1}@\fi \leave@ }
\xydef@\doMergeEnd@@@#1#2#3#4#5#6{%
 \cfromid@{#1}\pfromc@\senter@
 \cfromid@{#2}\spushc@\cfromid@{#3}\spushc@\cfromid@{#4}%
 \ifx#6\relax
 \L@c=.1\p@ \R@c=\L@c \U@c=\L@c \D@c=\L@c \Edge@c={\rectangleEdge}\fi
 \enter@\cmergethec@\cfromid@{0@c}\leave@
 \enter@\cmergethec@\cfromcontrols@{#1}{#2}{#3}{#4}\leave@
 \connect@\crvs{#5}\relax
 \sinit@\sleave@}
\xydef@\doMergeStartArc@#1#2{\save@\ifcase#2\relax
 \doMergeStart@@{0@p}{1@m}{2@m}{1@c}{#1}@\or
 \doMergeStart@@{1@c}{3@m}{4@m}{2@c}{#1}\relax\or
 \doMergeStart@@{2@c}{5@m}{6@m}{3@c}{#1}\relax\or
 \doMergeStart@@{3@c}{7@m}{8@m}{0@p}{#1}\relax\fi \leave@ }
\xydef@\doMergeStart@@#1#2#3#4#5#6{%
 \cfromid@{#1}\ifx#6\relax
 \L@c=.1\p@ \R@c=\L@c \U@c=\L@c \D@c=\L@c \Edge@c={\rectangleEdge}\fi
 \enter@\cmergethec@\cfromid@{0@x}\leave@
 \enter@\cmergethec@\cfromcontrols@{#4}{#3}{#2}{#1}\leave@
 \pfromc@
 \senter@ \cfromid@{#2}\spushc@\cfromid@{#3}\spushc@\cfromid@{#4}%
 \connect@\crvs{#5}\relax\sinit@\sleave@}
\xydef@\doMergeBothArc@#1#2{\save@\ifcase#2\relax
 \doMergeBoth@@{0@p}{1@m}{2@m}{1@c}{#1}@\or
 \doMergeBoth@@{1@c}{3@m}{4@m}{2@c}{#1}\relax\or
 \doMergeBoth@@{2@c}{5@m}{6@m}{3@c}{#1}\relax\or
 \doMergeBoth@@{3@c}{7@m}{8@m}{0@p}{#1}\relax\fi \leave@ }
\xydef@\doMergeBoth@@#1#2#3#4#5#6{%
 \cfromid@{#1}\ifx#6\relax
 \L@c=.1\p@ \R@c=\L@c \U@c=\L@c \D@c=\L@c \Edge@c={\rectangleEdge}\fi
 \enter@\cmergethec@\cfromid@{0@x}\leave@
 \enter@\cmergethec@\cfromcontrols@{#4}{#3}{#2}{#1}\leave@
 \pfromc@
 \senter@ \cfromid@{#2}\spushc@\cfromid@{#3}\spushc@\cfromid@{#4}%
 \enter@\cmergethec@\cfromid@{0@c}\leave@ 
 \enter@\cmergethec@\cfromcontrols@{#1}{#2}{#3}{#4}\leave@
 \connect@\crvs{#5}\relax\sinit@\sleave@}
\xydef@\doMergeEndArc@#1#2{\count@@=#2\relax
 \ifnum\count@@>\thr@@ \advance\count@@-4\fi\relax
 \doMergeEndArc@@{#1}\count@@ }
\xydef@\doStraightArc@@#1{\xy@{STRAITarc}{\save@
 \cfromid@{0@p}\pfromc@\cfromid@{0@c}%
 \senter@\connect@\crvs{#1}\sinit@\sleave@\leave@}}
\xydef@\cfromcontrols@#1#2#3#4{\bgroup
 \cfromid@{#1}\L@p=\X@c \U@p=\Y@c
 \cfromid@{#4}\R@p=\X@c \D@p=\Y@c
 \cfromid@{#3}\A@=\X@c \B@=\Y@c \cfromid@{#2}%
 \ifdim\R@p>\L@p \ifdim\A@>\R@p \R@p=\A@
 \ifdim\X@c>\R@p \R@p=\X@c\fi\fi
 \else \ifdim\A@<\R@p \R@p=\A@
 \ifdim\X@c<\R@p \R@p=\X@c\fi\fi
 \fi
 \ifdim\D@p>\U@p \ifdim\B@>\D@p \D@p=\B@
 \ifdim\Y@p>\D@p \D@p=\Y@p\fi\fi
 \else \ifdim\B@<\D@p \D@p=\B@
 \ifdim\Y@p<\D@p \D@p=\Y@p\fi\fi
 \fi 
 \edef\next@{\egroup \X@c=\the\R@p \Y@c=\the\D@p}\next@ }
\xydef@\doCircleArcs@{\save@
 \cfromid@{0@0}\pfromc@\cfromid@{0@p}\setupDirection@
 \startDirection@ \edef\startDirection@@{\the\Direction}%
 \cfromid@{1@c}\setupDirection@ \edef\quadDirection@{\the\Direction}\relax 
 \count@=\quadDirection@ \relax\def\nextii@{^}%
 \let\preDirection@@=\startDirection@@ 
 \ifx\nextii@\arcOrient@@
 \ifnum\quadDirection@>\startDirection@@ \relax
 \else \advance\count@ by8192 \relax\edef\quadDirection@{\the\count@}\fi
 \ifx\endDirection@@\empty
 \ifx\endDirection@\relax
 \bgroup\cfromid@{0@c}\setupDirection@
 \edef\next@{\egroup \count@@=\the\Direction}\next@ \relax
 \ifnum\count@@<\startDirection@@ \advance\count@@ 8192 \fi
 \edef\endDirection@@{\the\count@@}%
 \else
 \count@@=\startDirection@@
 \advance\count@@ by8192 \edef\endDirection@@{\the\count@@}%
 \fi
 \else 
 \count@@=\endDirection@@ \relax\ifnum\count@@<\startDirection@@ \relax
 \advance\count@@ by8192 \edef\endDirection@@{\the\count@@}\fi
 \fi
 \ifnum\endDirection@@>\quadDirection@
 \DN@{\expandafter\doCircleArc@@\expandafter{\arcSTYLE}{0}}%
 \else
 \DN@{\expandafter\doCircleArc@\expandafter{\arcSTYLE}{0}}%
 \fi
 \else
 \ifnum\count@<\startDirection@@\relax\else\advance\count@ by-8192 \relax
 \edef\quadDirection@{\the\count@}\fi
 \ifx\endDirection@@\empty
 \ifx\endDirection@\relax
 \bgroup\cfromid@{0@c}\setupDirection@
 \edef\next@{\egroup \count@@=\the\Direction}\next@ \relax
 \ifnum\count@@>\startDirection@@ \advance\count@@-8192 \fi
 \edef\endDirection@@{\the\count@@}%
 \else
 \count@@=\startDirection@@
 \advance\count@@ by-8192 \edef\endDirection@@{\the\count@@}%
 \fi
 \else 
 \count@@=\endDirection@@ \relax \ifnum\count@@>\startDirection@@
 \advance\count@@ by-8192 \edef\endDirection@@{\the\count@@}\fi
 \fi
 \ifnum\endDirection@@<\quadDirection@
 \DN@{\expandafter\doCircleArc@@\expandafter{\arcSTYLE}{0}}%
 \else \DN@{\expandafter\doCircleArc@\expandafter{\arcSTYLE}{0}}\fi
 \fi
 \next@ \relax
 \count@=\quadDirection@ \relax\def\nextii@{^}\DN@{}%
 \ifx\nextii@\arcOrient@@
 \count@@=\startDirection@@ \advance\count@@ by4096 \relax
 \ifnum \count@<\endDirection@@ \relax
 \ifnum\endDirection@@>\count@@
 \DN@{\expandafter\doCircleArc@@\expandafter{\arcSTYLE}{1}}%
 \else \DN@{\expandafter\doCircleArc@\expandafter{\arcSTYLE}{1}}\fi
 \fi
 \else 
 \count@@=\startDirection@@ \advance\count@@ by-4096 \relax
 \ifnum \count@>\endDirection@@ \relax 
 \ifnum\endDirection@@<\count@@
 \DN@{\expandafter\doCircleArc@@\expandafter{\arcSTYLE}{1}}%
 \else \DN@{\expandafter\doCircleArc@\expandafter{\arcSTYLE}{1}}\fi
 \fi\fi 
 \next@ \relax
 \ifx\next@\empty \else \relax
 \count@=\startDirection@@ \relax\def\nextii@{^}\DN@{}%
 \ifx\nextii@\arcOrient@@ \advance\count@ by4096 \relax
 \count@@=\quadDirection@ \advance\count@@ by4096 \relax
 \ifnum \count@<\endDirection@@ 
 \ifnum\endDirection@@>\count@@
 \DN@{\expandafter\doCircleArc@@\expandafter{\arcSTYLE}{2}}%
 \else \DN@{\expandafter\doCircleArc@\expandafter{\arcSTYLE}{2}}\fi
 \fi
 \else \advance\count@ by-4096 \relax
 \count@@=\quadDirection@ \advance\count@@ by-4096 \relax
 \ifnum \count@>\endDirection@@ \relax
 \ifnum\endDirection@@<\count@@
 \DN@{\expandafter\doCircleArc@@\expandafter{\arcSTYLE}{2}}%
 \else \DN@{\expandafter\doCircleArc@\expandafter{\arcSTYLE}{2}}\fi
 \fi\fi 
 \next@ \relax
 \fi
 \ifx\next@\empty \else \relax
 \count@=\quadDirection@ \def\nextii@{^}\DN@{}%
 \ifx\nextii@\arcOrient@@ \advance\count@ by4096 \relax
 \ifnum \count@<\endDirection@@
 \DN@{\expandafter\doCircleArc@\expandafter{\arcSTYLE}{3}}\fi
 \else \advance\count@ by-4096 \relax
 \ifnum \count@>\endDirection@@ 
 \DN@{\expandafter\doCircleArc@\expandafter{\arcSTYLE}{3}}\fi
 \fi \next@ \relax
 \fi
 \leave@ }
\message{elliptical arcs,}
\xydef@\arcmagic@@{0.5517847}
\xylet@\arcmagic=\arcmagic@@
\xydef@\tildeARC@#1{%
 \if q#1\DN@{\xy@{quadARC}\quadARC@ \arc@}%
 \else\if c#1\DN@{\xyFN@\cubicARC@i}%
 \else\if e#1\DN@{\xy@{ellipticARC}\ellipticARC@ \arc@}%
 \else\if i#1\DN@{\xy@{interpARC}\interpARC@ \arc@}%
 \else\if p#1\DN@{\xy@{cuspidalARC}\cuspidalARC@ \arc@}%
 \else\xywarning@{unknown arc type: #1 }%
 \DN@{\xy@{ellipticARC}\ellipticARC@ \arc@}%
 \fi\fi\fi\fi\fi \next@ }
\xydef@\cubicARC@i{%
 \ifx\next\space@ \expandafter\DN@\space{\xyFN@\cubicARC@i}%
 \else\ifx\next (\DN@(##1){\xy@{cubicARC(##1)}{\cubicARC@{##1}}\arc@}%
 \else \DN@{\xy@{cubicARC(1)}{\cubicARC@{1}}\arc@}%
 \fi\fi \next@ }
\xydef@\ellipticARC@{\let\arcControls@=\cubicARCcontrols@@
 \edef\arcparam@{\arcmagic@@}}
\xydef@\cubicARC@#1{\let\arcControls@=\cubicARCcontrols@@
 \dimen@=#1\p@ \edef\arcparam@{\expandafter\removePT@\the\dimen@}}
\xydef@\quadARC@{\let\arcControls@=\cubicARCcontrols@@
 \def\arcparam@{.66667}}
\xydef@\cuspidalARC@{\let\arcControls@=\cubicARCcontrols@@
 \def\arcparam@{2}}
\xydef@\interpARC@{\let\arcControls@=\cubicARCcontrols@@
 \def\arcparam@{1.33333}}
\xydef@\ARCturn@{\xy@@\bgroup\afterCOORD{%
 \xy@@{\edef\next@{\egroup \A@=\the\X@c \B@=\the\Y@c}\next@}\ARCturn@@}}
\xydef@\ARCturn@@#1@{\DN@{#1}\DNii@{^}%
 \ifx\next@\nextii@ \xy@{^}{\def\arcOrient@@{^}}%
 \else\DNii@{_}\ifx\next@\nextii@ \xy@{_}{\def\arcOrient@@{_}}%
 \else\xy@{}{\def\arcOrient@@{}}\fi\fi
 \xy@@\ARCturn@@@ \processDirections@@ }
\xydef@\ARCturn@@@{%
 \bgroup\cfromid@{0@p}\X@p=\X@c \Y@p=\Y@c \X@c=\A@ \Y@c=\B@
 \setupDirection@ \edef\next@{\egroup\count@=\the\Direction}\next@\relax
 \edef\startDirection@@{\the\count@ }%
 \bgroup\cfromid@{0@c}\X@p=\A@ \Y@p=\B@
 \setupDirection@ \edef\next@{\egroup\count@=\the\Direction}\next@\relax
 \edef\endDirection@@{\the\count@}%
 \ifx\arcOrient@@\empty
 \bgroup\cfromid@{0@p}\X@p=\X@c \Y@p=\Y@c \cfromid@{0@c}%
 \setupDirection@ \edef\next@{\egroup\count@@=\the\Direction}\next@\relax
 \count@=-\count@@ \advance\count@\startDirection@@ \relax \count@=-\count@
 \ifnum\count@>4096 \def\arcOrient@@{_}%
 \else\ifnum\count@<-4096 \def\arcOrient@@{^}%
 \else\ifnum\count@>\z@ \def\arcOrient@@{^}%
 \else\def\arcOrient@@{_}\fi\fi\fi
 \fi }
\xydef@\circleArc@{%
 \xy@{circARC@}{\cfromid@{0@p}\pfromc@\cfromp@\startDirection@ 
 \arcCenter@\idfromc@{0@0}%
 \def\startDirection@{\bgroup
 \cfromid@{0@0}\pfromc@\cfromid@{0@p}\setupDirection@ 
 \edef\next@{\egroup \Direction=\the\Direction}\next@
 \relax\imposeDirection@}}%
 \ifx\endDirection@@\empty
 \ifx\arcRadius@\empty \ifx\ellipseRatio@\empty\else
 \DN@{\arcScale@@}\ifx\arcScale@\next@\else
 \xy@@{\bgroup\cfromid@{0@0}\pfromc@\cfromid@{0@c}\setupDirection@
 \edef\next@{\egroup \Direction=\the\Direction}\next@ 
 \edef\endDirection@@{\the\Direction}}\fi\fi\fi\fi
 \ellipseArc@ \xy@@{\leave@ \doCircleArcs@}\endarc@ }
\xydef@\arcbisector{%
 \cfromid@{0@p}\pfromc@\cfromid@{0@c}\setupDirection@
 \advance\X@c\X@p\divide\X@c\tw@ 
 \advance\Y@c\Y@p\divide\Y@c\tw@ \czeroEdge@ \pfromc@
 \enter@\cplusthec@ \enter@\relax\begingroup
 \aboveDirection@\xydashl@ \vfromslide@i{}@\leave@ }
\xydef@\arcCenter@{%
 \cfromid@{0@p}\pfromc@\cfromid@{0@m}\setupDirection@
 \cfromp@\enter@\cplusthec@ \enter@\relax\begingroup
 \aboveDirection@\xydashl@ \vfromslide@i{}@\leave@\no@@
 \arcCenter@i }
\xydef@\arcCenter@i{%
 \enter@{\pfromthep@}\setupDirection@ \Creset@@
 \let\PLACEedgep@@=\PLACEedgep@ \let\PLACEedgec@@=\PLACEedgec@
 \enter@{\pfromthep@\basefromthebase@}\bgroup 
 \arcbisector \edef\next@{\egroup 
 \X@c =\the\X@c \Y@c=\the\Y@c \X@p=\the\X@p \Y@p=\the\Y@p }%
 \next@ \Cintercept@@ \leave@\leave@ }
\xydef@\getarcExtents@{%
 \ifx\space@\next\expandafter\DN@\space{\xyFN@\getarcExtents@}%
 \else\ifx\next @\xy@{@}{}\DN@ @{\fullEllipse@}%
 \else\DN@{\xy@{arcEXTENTs}{\save@ 
 \def\startDirection@{\Direction=\startDirection@@ \imposeDirection@}}%
 \xyFN@\getarcExtents@ii}\fi\fi \next@ }
\xydef@\getarcExtents@ii{%
 \ifx\next!\xy@{![[}{}\DN@![[##1]]{\getxyDirection@{##1}\getarcExtents@iv}%
 \else\DN@{\getarcExtents@iv}\fi \next@ }
\xydef@\getarcExtents@iv{\afterDIRECTIONorEMPTY
 {\xy@{startDIR}{\edef\startDirection@@{\the\Direction}\leave@}%
 \xyFN@\getarcOrientation@}%
 {\xy@{startDIR}{\edef\startDirection@@{\the\Direction}\leave@}%
 \xyFN@\getarcOrientation@}}
\xydef@\getarcOrientation@{%
 \ifx\space@\next\expandafter\DN@\space{\xyFN@\getarcOrientation@}%
 \else\ifx\next @\xy@{@}{}\DN@{\getEndDirection@x}%
 \else\ifx\next,\xy@{,}{}\DN@,{\xyFN@\getarcOrientation@i}%
 \else\DN@{\getarcOrientation@i}\fi\fi\fi \next@ }%
\xydef@\getarcOrientation@i{%
 \ifx\space@\next\expandafter\DN@\space{\xyFN@\getarcOrientation@i}%
 \else\ifx\next @\xy@{@}{}\DN@{\getEndDirection@x}%
 \else\ifx\next^{}\DN@##1{\xy@{^}{\def\arcOrient@@{^}}%
 \def\arcOrient@@{^}\xyFN@\getEndDirection@}%
 \else\ifx\next_\DN@##1{\xy@{_}{\def\arcOrient@@{_}}%
 \def\arcOrient@@{_}\xyFN@\getEndDirection@}%
 \else\DN@{\xyFN@\getEndDirection@}%
 \fi\fi\fi\fi \next@ }
\xydef@\getEndDirection@{%
 \ifx\space@\next\expandafter\DN@\space{\xyFN@\getEndDirection@}%
 \else\ifx\next,\DN@,{\xy@{,}{}\xyFN@\getEndDirection@}%
 \else\addEQ@\ifx\next\addEQ@\DN@{\xy@{=}{\save@\startDirection@}%
 \xyFN@\getEqDirection@}%
 \else \ifx\next!\DN@![[##1]]{\xy@{![[}{\save@}\getxyDirection@{##1}%
 \xy@{endDIR}{\edef\endDirection@@{\the\Direction}}%
 \xyFN@\getEndDirection@i}%
 \else \DN@{\xy@{origDIR}{\save@\origDirection@}\getEndDirection@i}%
 \fi\fi\fi\fi \next@ }
\xydef@\getEqDirection@{%
 \ifx\space@\next\expandafter\DN@\space{\xyFN@\getEqDirection@}%
 \else\ifx\next @\xy@{@}{}\DN@ @{%
 \xy@{sameDIR}{\edef\endDirection@@{\startDirection@@}\leave@}%
 \parEllipse@{1}{}}%
 \else\ifx\next (\DN@({\xyFN@\checkEqOpen@}%
 \else \DN@{\getEndDirection@i}\fi\fi\fi \next@ }
\xydef@\checkEqOpen@{%
 \ifx\next *\DN@{\getEndDirection@i (}%
 \else \DN@##1)##2@{\xy@{()}\leave@ \parEllipse@{##1}{##2}}%
 \fi \next@ }
\xydef@\getEndDirection@i{\afterDIRECTIONorEMPTY
 {\xy@{endDIR}{\edef\endDirection@@{\the\Direction}\leave@}%
 \getEndDirection@x }%
 {\xy@{endDIR}\leave@ \getEndDirection@x }}
\xydef@\getEndDirection@x#1@{%
 \DN@{#1}\ifx\next@\empty\relax \else\xywarning@{\omittingTokens@}\fi
 \processDirections@ }
\xydef@\omittingTokens@{omitting unused tokens: \codeof\next@ }
\xydef@\processDirections@@{%
 \ifx\endDirection@@\empty \skewCircle@
 \else \skewEllipse@ \expandafter \afterARCextents@@ \fi }
\xydef@\processArcDirections@{%
 \xy@{ARCdirs}{\ifx\endDirection@@\empty
 \origDirection@ \edef\endDirection@@{\the\Direction}\fi}%
 \ellipseArc@ 
 \xy@{procARCdirs}\processArcDirections@@
 \let\arcScale@=\relax \def\arcRadius@{}\def\ellipseRatio@{}%
 \xy@{circSECTORS}{\let\doCircleArc@=\doMergeEndArc@@ \doCircleSectors@}%
 \endarc@ }
\xydef@\processArcDirections@@{\save@
 \bgroup \cfromid@{0@0}\pfromc@ \Direction=\startDirection@@ 
 \DN@{_}\ifx\next@\arcOrient@@
 \advance\Direction \ifnum\Direction<\z@-\fi 4096 \relax\fi 
 \imposeDirection@
 \d@X=\cosDirection\Y@ybase \advance\d@X-\sinDirection\X@ybase
 \d@Y=-\cosDirection\Y@xbase \advance\d@Y\sinDirection\X@xbase
 \setupDirection@i
 \d@X=-\cosDirection\X@ybase \advance\d@X\sinDirection\X@xbase
 \d@Y=-\cosDirection\Y@ybase \advance\d@Y\sinDirection\Y@xbase
 \enter@\cplusthec@\X@c=\d@X \Y@c=\d@Y \leave@ \czeroEdge@
 \setupDirection@i 
 \czeroEdge@
 \edef\next@{\egroup \cfromthec@ \count@=\the\Direction}\next@
 \edef\startDirection@@{\the\count@}\idfromc@{0@x}%
 \bgroup \cfromid@{0@0}\pfromc@ \Direction=\endDirection@@
 \DN@{_}\ifx\next@\arcOrient@@
 \advance\Direction \ifnum\Direction<\z@-\fi 4096 \relax\fi 
 \imposeDirection@ 
 \d@X=\cosDirection\Y@ybase \advance\d@X-\sinDirection\X@ybase
 \d@Y=-\cosDirection\Y@xbase \advance\d@Y\sinDirection\X@xbase
 \setupDirection@i
 \d@X=-\cosDirection\X@ybase \advance\d@X\sinDirection\X@xbase
 \d@Y=-\cosDirection\Y@ybase \advance\d@Y\sinDirection\Y@xbase
 \enter@\cplusthec@\X@c=\d@X \Y@c=\d@Y \leave@
 \czeroEdge@ 
 \setupDirection@i 
 \edef\next@{\egroup \cfromthec@ \count@=\the\Direction}\next@
 \edef\endDirection@@{\the\count@}\idfromc@{0@c}%
 \count@=\startDirection@@ \relax \count@@=\endDirection@@ \relax
 \DN@{^}\ifx\arcOrient@@\next@
 \ifnum\count@@>\count@ \else\advance\count@@ 8192 \relax\fi
 \else
 \ifnum\count@@<\count@ \else\advance\count@@-8192 \relax\fi\fi
 \edef\startDirection@@{\the\count@}%
 \edef\endDirection@@{\the\count@@}}%
\xydef@\doCircleSectors@{\save@
 \cfromid@{0@0}\pfromc@\cfromid@{0@p}\setupDirection@ 
 \count@=\Direction \DN@{^}\ifx\arcOrient@@\next@
 \ifnum\count@>\startDirection@@ \advance\count@-8192 \fi\relax
 \count@@=\count@ \advance\count@@ 8192 \relax
 \ifnum\count@@<\endDirection@@ \advance\count@@ 8192 \fi\relax
 \else 
 \ifnum\count@<\startDirection@@ \advance\count@ 8192 \fi\relax
 \count@@=\count@ \advance\count@@-8192 \relax
 \ifnum\count@@>\endDirection@@ \advance\count@@-8192 \fi\relax
 \fi \relax
 \edef\preDirection@@{\the\count@}\edef\postDirection@@{\the\count@@}%
 \cfromid@{1@c}\setupDirection@ \count@=\Direction 
 \def\nextii@{^}\ifx\nextii@\arcOrient@@
 \DN@{\forwardSectors@\doEllipseSectors@}%
 \ifnum\count@<\preDirection@@ \advance\count@ 8192 \relax
 \else \count@@=\count@\advance\count@-8192 \relax
 \ifnum\count@@<\preDirection@@ \else\count@=\count@@ \fi\fi
 \else
 \DN@{\backwardSectors@\doEllipseSectors@}%
 \ifnum\count@>\preDirection@@ \advance\count@-8192 \relax
 \else \count@@=\count@\advance\count@ 8192 \relax
 \ifnum\count@@>\preDirection@@ \else\count@=\count@@ \fi\fi
 \fi \edef\quadDirection@{\the\count@}%
 \next@ }
\xydef@\forwardSectors@{%
 \ifnum \startDirection@@<\quadDirection@ \def\startSector@@{0}%
 \else\count@=\preDirection@@ \advance\count@ 4096 \relax
 \ifnum \startDirection@@<\count@ \def\startSector@@{1}%
 \else\count@=\quadDirection@ \advance\count@ 4096 \relax
 \ifnum\startDirection@@<\count@ \def\startSector@@{2}%
 \else \def\startSector@@{3}\fi\fi\fi 
 \ifnum\quadDirection@ <\endDirection@@ \relax
 \count@=\preDirection@@ \advance\count@ 4096 \relax
 \ifnum\count@<\endDirection@@ \relax
 \count@=\quadDirection@ \advance\count@ 4096 \relax
 \ifnum\count@<\endDirection@@ \relax
 \count@=\preDirection@@ \advance\count@ 8192 \relax
 \ifnum\count@<\endDirection@@ \relax
 \count@=\quadDirection@ \advance\count@ 8192 \relax
 \ifnum\count@<\endDirection@@ \relax
 \count@=\preDirection@@ \advance\count@ 12288 \relax
 \ifnum\count@<\endDirection@@ \relax
 \count@=\quadDirection@ \advance\count@ 12288 \relax
 \ifnum\count@<\endDirection@@ \def\endSector@@{7}%
 \else \def\endSector@@{6}\fi
 \else \def\endSector@@{5}\fi
 \else \def\endSector@@{4}\fi
 \else \def\endSector@@{3}\fi
 \else \def\endSector@@{2}\fi
 \else \def\endSector@@{1}\fi
 \else \def\endSector@@{0}\fi }
\xydef@\backwardSectors@{%
 \ifnum \startDirection@@>\quadDirection@ \def\startSector@@{0}%
 \else\count@=\preDirection@@ \advance\count@-4096 \relax
 \ifnum \startDirection@@>\count@ \def\startSector@@{1}%
 \else\count@=\quadDirection@ \advance\count@-4096 \relax
 \ifnum\startDirection@@>\count@ \def\startSector@@{2}%
 \else \def\startSector@@{3}\fi\fi\fi 
 \ifnum\quadDirection@>\endDirection@@ \relax
 \count@=\preDirection@@ \advance\count@-4096 \relax
 \ifnum\count@>\endDirection@@ \relax
 \count@=\quadDirection@ \advance\count@-4096 \relax
 \ifnum\count@>\endDirection@@ \relax
 \count@=\preDirection@@ \advance\count@-8192 \relax
 \ifnum\count@>\endDirection@@ \relax
 \count@=\quadDirection@ \advance\count@-8192 \relax
 \ifnum\count@>\endDirection@@ \relax
 \count@=\preDirection@@ \advance\count@-12288 \relax
 \ifnum\count@>\endDirection@@ \relax
 \count@=\quadDirection@ \advance\count@-12288 \relax
 \ifnum\count@>\endDirection@@ \def\endSector@@{7}%
 \else \def\endSector@@{6}\fi
 \else \def\endSector@@{5}\fi
 \else \def\endSector@@{4}\fi
 \else \def\endSector@@{3}\fi
 \else \def\endSector@@{2}\fi
 \else \def\endSector@@{1}\fi
 \else \def\endSector@@{0}\fi }
\xydef@\doEllipseSectors@{%
 \ifx\startSector@@\endSector@@
 \DN@{\expandafter\doMergeBothArc@\expandafter{\arcSTYLE}{\endSector@@}}%
 \else
 \expandafter\doMergeStartArc@\expandafter{\arcSTYLE}{\startSector@@}%
 \edef\countArcs@@{\startSector@@}%
 \loop@ \count@=\countArcs@@ \relax \advance\count@\@ne
 \ifnum \count@ < \endSector@@ \edef\countArcs@@{\the\count@}%
 \bgroup\expandafter\doCircleArc@@\expandafter{\arcSTYLE}{\countArcs@@}%
 \egroup 
 \repeat@
 \DN@{\expandafter\doMergeEndArc@\expandafter{\arcSTYLE}{\endSector@@}}%
 \fi \next@ \leave@}
\xydef@\checkstartDirection@{%
 \bgroup\no@@ \edef\next@{\egroup\count@@=\the\Direction}\next@\relax
 \ifnum\count@@=\startDirection@@ \relax \DN@{\straightArc@}%
 \else \advance\count@@-\startDirection@@ \relax
 \ifnum\count@@=\ifnum\count@@<\z@-\fi 4096 \relax \DN@{\straightArc@}%
 \else \DN@{\processDirections@@}\fi\fi \next@ }
\xydef@\straightArc@{\xywarning@{straight arc encountered}%
 \xy@@{\let\bstartPLACE@=\relax 
 \expandafter\doStraightArc@@\expandafter{\arcSTYLE}}\endarc@ }%
\xydef@\skewEllipse@{\xy@@{\doskewEllipse@}%
 \def\afterARCextents@@{\xy@{aftARCext}{\let\doCircleArc@=\doMergeEndArc@@}%
 \ellipseArc@ \xy@{doCircARCs}{\doCircleArcs@}\endarc@ }%
 \let\arcScale@=\relax \def\arcRadius@{}\def\ellipseRatio@{}}
\xydef@\skewCircle@{\xy@@{\setupDirection@}%
 \ifnum\Direction=\startDirection@@\relax\DN@{\halfEllipse@{1}}%
 \else
 \xy@@{\def\startDirection@{\Direction=\startDirection@@\imposeDirection@}%
 \cfromid@{0@p}\enter@\cplusthec@ \startDirection@
 \enter@\relax\begingroup\vfromslide@i{}@\czeroEdge@\leave@\idfromc@{0@m}%
 \let\endDirection@=\relax \let\doCircleArc@=\doMergeEndArc@@}%
 \DN@{\circleArc@}%
 \fi \next@ }
\xydef@\doskewEllipse@{%
 \def\startDirection@{\Direction=\startDirection@@ \relax
 \imposeDirection@}\startDirection@ \cfromid@{0@p}%
 \enter@\cplusthec@ \enter@\relax\begingroup\vfromslide@i{}@\leave@ 
 \idfromc@{0@x}%
 \ifx\endDirection@@\empty \parallelDirection@
 \else
 \def\endDirection@{\Direction=\endDirection@@ \relax
 \imposeDirection@ }\endDirection@ \skewEllB@ 
 \bgroup\setupDirection@\edef\next@{\egroup\count@@=\the\Direction}\next@
 \edef\endDirection@@{\the\count@@}%
 \fi
 \cfromid@{0@p}\bgroup \setupDirection@
 \edef\next@{\egroup \count@@=\the\Direction}\next@
 \edef\startDirection@@{\the\count@@}}
\xydef@\halfEllipse@#1{\xy@@{%
 \cfromid@{0@p}\pfromc@\cfromid@{0@c}\no@@
 \edef\endDirection@@{\the\Direction}%
 \advance\X@c\X@p \divide\X@c\tw@ \advance\Y@c\Y@p \divide\Y@c\tw@
 \idfromc@{0@0}\pfromc@ \cfromid@{0@p}\setbase@\X@p\Y@p\X@c\Y@c 
 \dimen@=\X@origin \advance\dimen@-\X@c \dimen@ii=\cosDirection\dimen@
 \dimen@=\Y@origin \advance\dimen@-\Y@c \advance\dimen@ii \sinDirection\dimen@
 \X@c=\X@origin \Y@c=\Y@origin \enter@\cplusthec@ 
 \dimen@=#1\p@ \ifdim\dimen@<\z@ \DN@{^}\dimen@ii=-#1\dimen@ii
 \ifx\next@\arcOrient@@\def\arcOrient@@{_}\else\def\arcOrient@@{^}\fi
 \else \dimen@ii=#1\dimen@ii\fi 
 \startDirection@ \enter@\relax\begingroup\expandafter
 \vfromslide@i\expandafter{\the\dimen@ii}@\leave@
 \idfromc@{1@c}\setbase@@ \X@c \Y@c \adjustBaseOrient@
 \count@@=\endDirection@@ \relax
 \DN@{^}\advance\count@@\ifx\arcOrient@@\next@\else-\fi 4096 \relax
 \edef\startDirection@@{\the\count@@}%
 \def\startDirection@{\Direction=\startDirection@@ \imposeDirection@ }%
 \let\doCircleArc@=\doMergeEndArc@@ }%
 \let\arcScale@=\relax \ellipseArc@
 \xy@@{\doCircleArcs@}\endarc@ }
\xydef@\parallelDirection@{\show\parallelDirection@}%
\xydef@\parEllipse@#1#2{\DN@{#2}\ifx\next@\empty 
 \else\xywarning@{\omittingTokens@ }\fi \halfEllipse@{#1}}
\xydef@\skewEllB@{\cfromid@{0@c}\pfromc@\enter@\cplusthec@
 \enter@\relax\begingroup\vfromslide@i{}@\leave@
 \enter@{\pfromthep@\basefromthebase@}\no@@
 \bgroup \cfromid@{0@p}\pfromc@\cfromid@{0@x}\edef\next@{\egroup 
 \X@c =\the\X@c \Y@c=\the\Y@c \X@p=\the\X@p \Y@p=\the\Y@p }\next@
 \Cintercept@@\leave@ \idfromc@{0@x}\cfromid@{0@p}\enter@\cplusthec@
 \cfromid@{0@c}\leave@ \enter@\cplusthec@ \cfromid@{0@x}%
 \X@c=-\X@c \Y@c=-\Y@c \leave@ \idfromc@{0@0}\pfromc@\cfromid@{0@p}%
 \setbase@\X@p\Y@p\X@c\Y@c \cfromid@{0@c}\setbase@@\X@c\Y@c
 \adjustBaseOrient@ }
\xydef@\adjustBaseOrient@{%
 \edef\tmp@{\expandafter\removePT@\the\X@xbase}\dimen@=\Y@ybase
 \divide\dimen@ 64 \relax \dimen@ii=\tmp@\dimen@
 \edef\tmp@{\expandafter\removePT@\the\X@ybase}\dimen@=\Y@xbase
 \divide\dimen@ 64 \relax \dimen@=\tmp@\dimen@
 \ifdim\dimen@>\dimen@ii \X@ybase=-\X@ybase \Y@ybase=-\Y@ybase \fi }
\xyendinput

Bell Labs OSI certified Powered by Plan 9

(Return to Plan 9 Home Page)

Copyright © 2021 Plan 9 Foundation. All Rights Reserved.
Comments to webmaster@9p.io.