| 1 |
%% This is file 'diagmac2.sty' |
| 2 |
%% |
| 3 |
%% Copyright (C) 1997 J. C. Reynolds, [email protected] |
| 4 |
%% 2004-09 R. D. Tennent, [email protected] |
| 5 |
%% |
| 6 |
%% This work may be distributed and/or modified under the |
| 7 |
%% conditions of the LaTeX Project Public License, either version 1.3 |
| 8 |
%% of this license or (at your option) any later version. |
| 9 |
%% The latest version of this license is in |
| 10 |
%% http://www.latex-project.org/lppl.txt |
| 11 |
%% and version 1.3 or later is part of all distributions of LaTeX |
| 12 |
%% version 2003/12/01 or later. |
| 13 |
%% |
| 14 |
%% This work has the LPPL maintenance status "author-maintained". |
| 15 |
|
| 16 |
%MACROS FOR DIAGRAMS - J. C. Reynolds - December 1987 |
| 17 |
|
| 18 |
% Modified to use pict2e.sty by Bob Tennent |
| 19 |
% Changes indicated thusly: %%%pict2e |
| 20 |
|
| 21 |
% Changelog: |
| 22 |
% |
| 23 |
% Version 2.1 May 2009 |
| 24 |
% |
| 25 |
% Two extensions added: \drawedgebar and \ctec |
| 26 |
% User Manual TeXified and expanded |
| 27 |
% |
| 28 |
% Version 2.0 February 2004 |
| 29 |
% |
| 30 |
% Modified to use pict2e.sty |
| 31 |
% Changes indicated thusly: %%%pict2e |
| 32 |
|
| 33 |
\ProvidesPackage{diagmac2}[2009/05/09 v2.1 LaTeX style for (category-theory) diagrams] |
| 34 |
|
| 35 |
\AtBeginDocument{\RequirePackage{pict2e}} %%%pict2e |
| 36 |
\def\slopemax{1000} %%%pict2e slope factor maximum |
| 37 |
|
| 38 |
%This file contains general-purpose macros for drawing diagrams in LATEX, |
| 39 |
%followed by additional macros especially for category-theory diagrams. |
| 40 |
%A user's manual is given in the file diagmac2.tex, and a test program is %%%pict2e |
| 41 |
%given in the file diagmactest.tex. |
| 42 |
|
| 43 |
%GENERAL-PURPOSE MACROS |
| 44 |
|
| 45 |
%The following control symbols may need to be redefined by the user. |
| 46 |
\def\diagramunit{1pt}%Redefine only in main program or at the beginning |
| 47 |
% of \diagram or \ctdiagram. |
| 48 |
\def\centerheight{3pt} |
| 49 |
\def\edgeheaddisp{4pt} |
| 50 |
\def\circleheaddisp{2pt} |
| 51 |
\def\diameterlist{1pt,2pt,3pt,4pt,5pt,6pt,7pt,8pt,9pt,10pt,11pt,% |
| 52 |
12pt,13pt,14pt,15pt,16pt,20pt,24pt,28pt,32pt,36pt,40pt,} %%%pict2e: not used |
| 53 |
%Redefine if circle fonts are different. |
| 54 |
|
| 55 |
%The following registers store the representation of diagram and/or |
| 56 |
%expression programs: |
| 57 |
\newdimen\texpr\newdimen\bexpr\newdimen\lexpr\newdimen\rexpr%current rectangle |
| 58 |
\newdimen\xcenter\newdimen\ycenter%center point |
| 59 |
\newcount\xslope\newcount\yslope%slope of current edge |
| 60 |
\newdimen\xstart\newdimen\ystart%start point of current edge |
| 61 |
\newdimen\xend\newdimen\yend%end point of current edge |
| 62 |
\newdimen\dcircle%diameter of current circle |
| 63 |
\newdimen\xcircle\newdimen\ycircle%center of current circle |
| 64 |
\newcount\zzisedge%1 if current edge is defined, 0 otherwise |
| 65 |
\newcount\zziscircle%1 if current circle is defined, 0 otherwise |
| 66 |
\newbox\zzdiagbox%printable material in state |
| 67 |
\newdimen\zztotlwidth\newdimen\zztotrwidth%horizontal extent of box material |
| 68 |
\newdimen\zztotheight\newdimen\zztotdepth%vertical extent of box material |
| 69 |
|
| 70 |
%The following registers are assigned globally to communicate information |
| 71 |
%across group boundaries: |
| 72 |
\newdimen\zzglobaltotlwidth\newdimen\zzglobaltotrwidth |
| 73 |
\newdimen\zzglobaltotheight\newdimen\zzglobaltotdepth |
| 74 |
\newdimen\zzglobalxcenter\newdimen\zzglobalycenter |
| 75 |
\newcount\zzglobalcnA |
| 76 |
|
| 77 |
%The following registers are used locally for various purposes: |
| 78 |
\newdimen\zzdmA\newdimen\zzdmB\newdimen\zzdmC\newdimen\zzdmD\newdimen\zzdmE |
| 79 |
\newdimen\zzdmF\newdimen\zzdmG\newdimen\zzdmH\newdimen\zzdmI |
| 80 |
\newcount\zzcnA\newcount\zzcnB\newcount\zzcnC |
| 81 |
\newcount\zzcnD\newcount\zzcnE\newcount\zzcnF |
| 82 |
\newcount\zzcnG\newcount\zzcnH\newcount\zzcnI |
| 83 |
|
| 84 |
%Hidden macros and other defined control symbols: |
| 85 |
% generally used macros: \zzsetupbox\zznoshadow\zzissue\zzrecordwidth |
| 86 |
% \zzrecordheight\zzmultdiagramunit\zzmakepicture\zzsqroot\zzdistance |
| 87 |
% \zzreduceterms |
| 88 |
% error-checking macros: \zzisnegside\zzcheckedge\zzcheckslope\zzcheckslopea |
| 89 |
% \zzcheckcircle\zzcheckbool\zzcheckposdimen\zzchecknonnegnum |
| 90 |
% used by \vertex: \zzconsvertexlist\zzconsvertexlista\zzconsvertexlistb |
| 91 |
% used by \rect: \zzprocrect |
| 92 |
% used by \hexagon: \zzprochexagon |
| 93 |
% used by \octagon and \rorect: \zzprococtagon |
| 94 |
% used by \diamond: \zzprocdiamond |
| 95 |
% used by \rorect: \zzprocrorecta\zzsearchdiameterlist\zzsearchdiameterlista |
| 96 |
% \zzsearchdiameterlistb |
| 97 |
% used by \outline: \zzoutlinepoly\zzoutlinepolya\zzoutlinepolyb |
| 98 |
% \zzoutlinepolyc |
| 99 |
% used by \outline with \rorect: \zzoutlinerorect |
| 100 |
% used by \setedge: \zzsearchvertexlist\zzsearchvertexlista |
| 101 |
% \zzsearchvertexlistb |
| 102 |
% used by \shadeedge: \zzcastpoly\zzcastpolya\zzcastpolyb |
| 103 |
% \zzcastpolyc\zzcastpolye\zzcastpolyf\zzcastpolyg |
| 104 |
% used by \drawdashedge, \drawdotedge, and \drawsolidedge: \zzdrawedge |
| 105 |
% used by \drawedgehead: \zzdrawedgeheada |
| 106 |
% used by all abutment macros: \zzslidehoriz\zzslidevert\zzclosestpoly |
| 107 |
% \zzclosestpolya\zzclosestpolyb\zzclosestpolyc\zzclosestpolyd |
| 108 |
% used by edge abutment macros: \zzabut |
| 109 |
% used by circle abutment macros: \zzabutcircle\zzabutcirclea\zzrotate |
| 110 |
% used by \shadeedge and all abutment macros: \zzcastpolyd |
| 111 |
% used by \drawcircle: \zzdrawcirclea |
| 112 |
% multiply defined control symbols: \zzvertexlist\zzshadow\zzglobalshadow |
| 113 |
% \zztesta\zztestb\zzvertexitem\zzprocpoly\zzprocrorect\zznext |
| 114 |
% \zzstartshadow\zzendshadow\zzlocalshadow |
| 115 |
|
| 116 |
%\diagram creates a box, initializes \zztotlwidth, \zztotrwidth, and |
| 117 |
%\zzvertexlist, sets \zzisedge to 0, executes #1, which must be a diagram |
| 118 |
%program, and then issues the resulting box, surrounded by kerns so that |
| 119 |
%there are no horizontal overhangs. |
| 120 |
|
| 121 |
\def\diagram#1{{\setbox\zzdiagbox=\hbox{$\mathsurround=0pt |
| 122 |
\zztotlwidth=0pt\zztotrwidth=0pt\def\zzvertexlist{\end}\zzisedge=0\relax |
| 123 |
#1\relax\kern\zztotrwidth\global\zzglobaltotlwidth=\zztotlwidth $} |
| 124 |
\kern-\zzglobaltotlwidth\box\zzdiagbox}} |
| 125 |
|
| 126 |
%\zzsetupbox sets \zzdiagbox to the expression #1 modified by the program #2. |
| 127 |
%It also sets \zzglobalxcenter and \zzglobalycenter to the coordinates of |
| 128 |
%the center relative to the reference point, \zzglobaltotlwidth to the |
| 129 |
%negative of the left overhang width of the expression, and \zzglobalshadow |
| 130 |
%to the shadow established by the program, relative to the reference point. |
| 131 |
%Before executing #2, it initializes \texpr, \bexpr, \lexpr, \rexpr, |
| 132 |
%\xcenter, and \ycenter appropriately, and sets \zziscircle to 0. |
| 133 |
|
| 134 |
\def\zzsetupbox#1#2{\setbox\zzdiagbox=\hbox{$\mathsurround=0pt |
| 135 |
\setbox\zzdiagbox=\hbox{$\mathsurround=0pt{{#1}}$} |
| 136 |
\texpr=\ht\zzdiagbox\bexpr=-\dp\zzdiagbox\rexpr=\wd\zzdiagbox\lexpr=0pt |
| 137 |
\xcenter=\rexpr\divide\xcenter by 2\ycenter=\centerheight |
| 138 |
\zztotlwidth=0pt\zztotrwidth=\rexpr\def\zzshadow{\zznoshadow0pt,0pt:;} |
| 139 |
\zziscircle=0 |
| 140 |
\box\zzdiagbox\kern-\rexpr |
| 141 |
#2\relax |
| 142 |
\global\zzglobalxcenter=\xcenter\global\zzglobalycenter=\ycenter |
| 143 |
\global\zzglobaltotlwidth=\zztotlwidth\kern\zztotrwidth |
| 144 |
\global\let\zzglobalshadow=\zzshadow |
| 145 |
$}} |
| 146 |
|
| 147 |
%\zznoshadow is a dummy shadowing routine that gives an error when executed. |
| 148 |
|
| 149 |
\def\zznoshadow#1,#2:;{\errmessage{ATTEMPT TO OUTLINE OR ABUT AN EXPRESSION |
| 150 |
WITH NO SHADOW}} |
| 151 |
|
| 152 |
%\leftghost (\rightghost) sets \xcenter to \lexpr plus (\rexpr minus) |
| 153 |
%half of the width of its argument. |
| 154 |
|
| 155 |
\def\leftghost#1{\setbox\zzdiagbox=\hbox{$\mathsurround=0pt{{#1}}$} |
| 156 |
\xcenter=\wd\zzdiagbox\divide\xcenter by 2\advance\xcenter by \lexpr} |
| 157 |
|
| 158 |
\def\rightghost#1{\setbox\zzdiagbox=\hbox{$\mathsurround=0pt{{#1}}$} |
| 159 |
\xcenter=\wd\zzdiagbox\divide\xcenter by -2\advance\xcenter by \rexpr} |
| 160 |
|
| 161 |
%\zzissue should be executed after \zzsetupbox. It issues the contents of |
| 162 |
%\zzdiagbox with its center placed at \zzdmA, \zzdmB (which are modified), |
| 163 |
%and adjusts \zztotlwidth and \zztotrwidth appropriately. |
| 164 |
|
| 165 |
\def\zzissue{\advance\zzdmA by -\zzglobalxcenter |
| 166 |
\advance\zzdmB by -\zzglobalycenter |
| 167 |
\zzdmC=\zzdmA\advance\zzdmC by \wd\zzdiagbox |
| 168 |
\zzdmD=\zzdmA\advance\zzdmD by \zzglobaltotlwidth |
| 169 |
\zzrecordwidth\zzdmD\zzdmC |
| 170 |
\kern\zzdmA\raise\zzdmB\box\zzdiagbox\kern-\zzdmC} |
| 171 |
|
| 172 |
%\zzrecordwidth adjusts \zztotlwidth to be the minimum of its previous value |
| 173 |
%and #1, and adjusts \zztotrwidth to be the maximum of its previous value |
| 174 |
%and #2. |
| 175 |
|
| 176 |
\def\zzrecordwidth#1#2{\relax\ifdim#1<\zztotlwidth\relax\zztotlwidth=#1\fi |
| 177 |
\ifdim\zztotrwidth<#2\relax\zztotrwidth=#2\fi} |
| 178 |
|
| 179 |
%\zzrecordheight adjusts \zztotheight to be the maximum of its previous value |
| 180 |
%and #1, and adjusts \zztotdepth to be the minimum of its previous value |
| 181 |
%and #2. |
| 182 |
|
| 183 |
\def\zzrecordheight#1#2{\relax\ifdim\zztotheight<#1\relax\zztotheight=#1\fi |
| 184 |
\ifdim#2<\zztotdepth\relax\zztotdepth=#2\fi} |
| 185 |
|
| 186 |
%\placed executes \zzsetupbox{#3}{#4} and issues the contents of the resulting |
| 187 |
%\zzdiagbox with its center placed at #1, #2 (which must be dimensions). |
| 188 |
%\place is similar except that #1, #2 must be integer multiples of |
| 189 |
%\diagramunit. |
| 190 |
|
| 191 |
\def\placed#1#2#3#4{\zzsetupbox{#3}{#4}\zzdmA=#1\zzdmB=#2\zzissue} |
| 192 |
|
| 193 |
\def\place#1,#2:#3#4{\zzsetupbox{#3}{#4}\zzmultdiagramunit\zzdmA{#1} |
| 194 |
\zzmultdiagramunit\zzdmB{#2}\zzissue} |
| 195 |
|
| 196 |
%\zzmultdiagramunit sets #1 to #2 times \diagramunit. |
| 197 |
|
| 198 |
\def\zzmultdiagramunit#1#2{#1=\diagramunit\multiply#1 by #2\relax} |
| 199 |
|
| 200 |
%\vertex#1,#2:#3#4 executes \zzsetupbox{#3}{#4}, issues the contents of the |
| 201 |
%resulting \zzdiagbox with its center placed at #1, #2 times \diagramunit, |
| 202 |
%adjusts \zztotlwidth and \zztotrwidth appropriately, and adds \zzglobalshadow |
| 203 |
%to the beginning of \zzvertexlist (unless \zzglobalshadow is a call of |
| 204 |
%\zznoshadow) after readjusting the shadow to be relative |
| 205 |
%to the coordinates of the enclosing box. |
| 206 |
|
| 207 |
\def\vertex#1,#2:#3#4{\place{#1},{#2}:{#3}{#4}\zzcnA=#1\zzcnB=#2\relax |
| 208 |
\expandafter\zzconsvertexlist\zzglobalshadow} |
| 209 |
|
| 210 |
\def\zzconsvertexlist#1#2,#3:#4;{\def\zztesta{#1}\def\zztestb{\zznoshadow} |
| 211 |
\ifx\zztesta\zztestb\else |
| 212 |
\advance\zzdmA by #2\advance\zzdmB by #3\relax |
| 213 |
\edef\zzvertexitem{\the\zzcnA,\the\zzcnB:\noexpand #1\the\zzdmA,\the\zzdmB:#4;} |
| 214 |
\expandafter\zzconsvertexlista\zzvertexlist\fi} |
| 215 |
|
| 216 |
\def\zzconsvertexlista{\expandafter\zzconsvertexlistb\zzvertexitem} |
| 217 |
|
| 218 |
\def\zzconsvertexlistb#1\end{\def\zzvertexlist{#1\end}} |
| 219 |
|
| 220 |
%\rect, \hexagon, \octagon, and \diamond (and, roughly speaking, \rorect) |
| 221 |
%are polygon descriptors. A polygon descriptor defines \zzshadow to have |
| 222 |
% the form \somecontrolsymbol #1,#2:#3; such that executing |
| 223 |
%\zzshadow causes a call \zzprocpoly{#1}{#2}{<edgelist>}, where <edgelist> |
| 224 |
%depends only upon the parameter #3. Here #1, #2 are the |
| 225 |
%coordinates of a vertex of a convex polygon, and <edgelist> is a list of |
| 226 |
%triples describing the edges of the polygon in clockwise order. If an |
| 227 |
%edge is x = xs.t + x0, y = ys.t + y0 for 0 < t < tend (with the start at |
| 228 |
%t = 0 and the end at t = tend when the edge is traversed in clockwise |
| 229 |
%order) the the trip describing the edge is {xs}{ys}{tend}, where xs and |
| 230 |
%ys are numbers (the brackets may be omitted for single-digit numbers) |
| 231 |
%and tend is a dimension. xs and ys must have a least common divisor of one. |
| 232 |
|
| 233 |
\def\rect{\zzdmC=\rexpr\advance\zzdmC by -\lexpr |
| 234 |
\zzdmD=\texpr\advance\zzdmD by -\bexpr |
| 235 |
\zzisnegside{\zzdmC}{RECT}\zzisnegside{\zzdmD}{RECT} |
| 236 |
\edef\zzshadow{\noexpand\zzprocrect |
| 237 |
\the\lexpr,\the\texpr:\the\zzdmC,\the\zzdmD;}} |
| 238 |
|
| 239 |
\def\zzprocrect#1,#2:#3,#4;{\zzprocpoly |
| 240 |
{#1}{#2}{10{#3}0{-1}{#4}{-1}0{#3}01{#4}}} |
| 241 |
|
| 242 |
\def\zzisnegside#1#2{\relax\ifdim#1<0pt\errmessage |
| 243 |
{#2 WITH NEGATIVE SIDE}\fi} |
| 244 |
|
| 245 |
\def\hexagon{\zzdmC=\rexpr\advance\zzdmC by -\lexpr |
| 246 |
\zzdmD=\texpr\advance\zzdmD by -\bexpr\divide\zzdmD by 4 |
| 247 |
\zzisnegside{\zzdmC}{HEXAGON}\zzisnegside{\zzdmD}{HEXAGON} |
| 248 |
\edef\zzshadow{\noexpand\zzprochexagon |
| 249 |
\the\lexpr,\the\texpr:\the\zzdmC,\the\zzdmD;}} |
| 250 |
|
| 251 |
\def\zzprochexagon#1,#2:#3,#4;{\zzprocpoly{#1}{#2} |
| 252 |
{10{#3}1{-2}{#4}{-1}{-2}{#4}{-1}0{#3}{-1}2{#4}12{#4}}} |
| 253 |
|
| 254 |
\def\octagon#1{\zzdmC=#1\zzdmD=\zzdmC\multiply\zzdmD by -2\zzdmE=\zzdmD |
| 255 |
\advance\zzdmD by \rexpr\advance\zzdmD by -\lexpr |
| 256 |
\advance\zzdmE by \texpr\advance\zzdmE by -\bexpr |
| 257 |
\zzdmF=\lexpr\advance\zzdmF by \zzdmC |
| 258 |
\zzisnegside{\zzdmC}{OCTAGON}\zzisnegside{\zzdmD}{OCTAGON} |
| 259 |
\zzisnegside{\zzdmE}{OCTAGON} |
| 260 |
\edef\zzshadow{\noexpand\zzprococtagon |
| 261 |
\the\zzdmF,\the\texpr:\the\zzdmC,\the\zzdmD,\the\zzdmE;}} |
| 262 |
|
| 263 |
\def\zzprococtagon#1,#2:#3,#4,#5;{\zzprocpoly{#1}{#2} |
| 264 |
{10{#4}1{-1}{#3}0{-1}{#5}{-1}{-1}{#3}{-1}0{#4}{-1}1{#3}01{#5}11{#3}}} |
| 265 |
|
| 266 |
\def\diamond{\zzdmC=\texpr\advance\zzdmC by -\bexpr |
| 267 |
\advance\zzdmC by \rexpr\advance\zzdmC by -\lexpr\divide\zzdmC by 2 |
| 268 |
\zzdmD=\lexpr\advance\zzdmD by \rexpr\divide\zzdmD by 2 |
| 269 |
\zzdmE=\texpr\advance\zzdmE by \bexpr\divide\zzdmE by 2\advance\zzdmE by \zzdmC |
| 270 |
\zzisnegside{\zzdmC}{DIAMOND} |
| 271 |
\edef\zzshadow{\noexpand\zzprocdiamond |
| 272 |
\the\zzdmD,\the\zzdmE:\the\zzdmC;}} |
| 273 |
|
| 274 |
\def\zzprocdiamond#1,#2:#3;{\zzprocpoly{#1}{#2} |
| 275 |
{1{-1}{#3}{-1}{-1}{#3}{-1}1{#3}11{#3}}} |
| 276 |
|
| 277 |
\def\rorect#1#2#3{\zzcheckposdimen{#1}{FIRST}{RORECT} |
| 278 |
\zzcheckbool{#2}{SECOND}{RORECT}\zzcheckbool{#3}{THIRD}{RORECT} |
| 279 |
\zzdmD=\rexpr\advance\zzdmD by -\lexpr\zzdmE=\texpr\advance\zzdmE by -\bexpr |
| 280 |
\zzdmC=#1\relax |
| 281 |
\ifnum#2=1\relax\ifdim\zzdmD>\zzdmC\relax\zzdmC=\zzdmD\fi\fi |
| 282 |
\ifnum#3=1\relax\ifdim\zzdmE>\zzdmC\relax\zzdmC=\zzdmE\fi\fi |
| 283 |
%\expandafter\zzsearchdiameterlist\diameterlist\end\zzdmC=\zzdmF\relax %%%pict2e |
| 284 |
\ifdim\zzdmC>\zzdmD\relax\zzdmD=\zzdmC\fi |
| 285 |
\ifdim\zzdmC>\zzdmE\relax\zzdmE=\zzdmC\fi |
| 286 |
\zzdmF=\lexpr\advance\zzdmF by \rexpr\divide\zzdmF by 2 |
| 287 |
\zzdmG=\bexpr\advance\zzdmG by \texpr\divide\zzdmG by 2 |
| 288 |
\edef\zzshadow{\noexpand\zzprocrorect |
| 289 |
\the\zzdmF,\the\zzdmG:\the\zzdmC,\the\zzdmD,\the\zzdmE;}} |
| 290 |
|
| 291 |
\def\zzsearchdiameterlist#1{\def\zztesta{#1}\def\zztestb{\end} |
| 292 |
\ifx\zztesta\zztestb\let\zznext=\zzsearchdiameterlista |
| 293 |
\else\let\zznext=\zzsearchdiameterlistb\fi\zznext #1} |
| 294 |
|
| 295 |
\def\zzsearchdiameterlista#1\end{} |
| 296 |
|
| 297 |
\def\zzsearchdiameterlistb#1,{\zzdmF=#1\relax |
| 298 |
\ifdim\zzdmF<\zzdmC\relax\let\zznext=\zzsearchdiameterlist |
| 299 |
\else\let\zznext=\zzsearchdiameterlista\fi\zznext} |
| 300 |
|
| 301 |
%\outline uses \zzoutlinepoly and \zzoutlinerorect to issue an outline of |
| 302 |
%the shadow. |
| 303 |
|
| 304 |
\def\outline{\def\zzprocpoly{\zzoutlinepoly} |
| 305 |
\def\zzprocrorect{\zzoutlinerorect}\zzshadow} |
| 306 |
|
| 307 |
%\zzmakepicture encapsulates all usage of the LATEX picture facility. |
| 308 |
|
| 309 |
\def\zzmakepicture#1{{\setlength{\unitlength}{1sp}\begin{picture}(0,0) |
| 310 |
#1\relax |
| 311 |
\global\zzglobaltotlwidth=\zztotlwidth\global\zzglobaltotrwidth=\zztotrwidth |
| 312 |
\global\zzglobaltotheight=\zztotheight\global\zzglobaltotdepth=\zztotdepth |
| 313 |
\end{picture}\vrule height\zzglobaltotheight depth-\zzglobaltotdepth width0pt} |
| 314 |
\zztotlwidth=\zzglobaltotlwidth\zztotrwidth=\zzglobaltotrwidth} |
| 315 |
|
| 316 |
\def\zzoutlinepoly#1#2#3{\zzmakepicture{\zzdmA=#1\zzdmB=#2\relax |
| 317 |
\zztotheight=\zzdmB\zztotdepth=\zzdmB\zzoutlinepolya #3\end}} |
| 318 |
|
| 319 |
\def\zzoutlinepolya#1{\def\zztesta{#1}\def\zztestb{\end} |
| 320 |
\ifx\zztesta\zztestb\let\zznext=\zzoutlinepolyb |
| 321 |
\else\let\zznext=\zzoutlinepolyc\fi\zznext {#1}} |
| 322 |
|
| 323 |
\def\zzoutlinepolyb#1{} |
| 324 |
|
| 325 |
\def\zzoutlinepolyc#1#2#3{\zzrecordwidth\zzdmA\zzdmA\zzrecordheight\zzdmB\zzdmB |
| 326 |
\zzdmE=#3\multiply\zzdmE by #1\zzdmF=#3\multiply\zzdmF by #2\relax |
| 327 |
\zzcnA=\zzdmA\zzcnB=\zzdmB\relax |
| 328 |
\ifnum #1=0\relax\zzcnC=\zzdmF\else\zzcnC=\zzdmE\fi |
| 329 |
\ifnum\zzcnC<0\relax\zzcnC=-\zzcnC\fi |
| 330 |
\put(\zzcnA,\zzcnB){\line(#1,#2){\zzcnC}} |
| 331 |
\advance\zzdmA by \zzdmE\advance\zzdmB by \zzdmF |
| 332 |
\zzoutlinepolya} |
| 333 |
|
| 334 |
\def\zzoutlinerorect#1,#2:#3,#4,#5;{\zzmakepicture{ |
| 335 |
\zzdmA=#1\zzdmB=#2\zzdmC=#3\zzdmD=#4\zzdmE=#5 |
| 336 |
\zzcnA=\zzdmA\zzcnB=\zzdmB\zzcnC=\zzdmC\zzcnD=\zzdmD\zzcnE=\zzdmE |
| 337 |
\ifnum\zzcnD=\zzcnC\relax\put(\zzcnA,\zzcnB){\oval(\zzcnD,\zzcnE)} |
| 338 |
\else\ifnum\zzcnE=\zzcnC\relax\put(\zzcnA,\zzcnB){\oval(\zzcnD,\zzcnE)} |
| 339 |
\else\advance\zzcnE by -\zzcnC |
| 340 |
\zzcnF=\zzcnE\divide\zzcnF by 2\advance\zzcnF by \zzcnB |
| 341 |
\put(\zzcnA,\zzcnF){\oval(\zzcnD,\zzcnC)[t]} |
| 342 |
\advance\zzcnF by -\zzcnE |
| 343 |
\put(\zzcnA,\zzcnF){\oval(\zzcnD,\zzcnC)[b]} |
| 344 |
\zzcnC=\zzcnD\divide\zzcnC by 2\advance\zzcnA by \zzcnC |
| 345 |
\put(\zzcnA,\zzcnF){\line(0,1){\zzcnE}} |
| 346 |
\advance\zzcnA by -\zzcnD |
| 347 |
\put(\zzcnA,\zzcnF){\line(0,1){\zzcnE}}\fi\fi |
| 348 |
\zztotheight=\zzdmE\divide\zztotheight by 2\advance\zztotheight by \zzdmB |
| 349 |
\zztotdepth=\zztotheight\advance\zztotdepth by -\zzdmE |
| 350 |
\zzdmC=\zzdmD\divide\zzdmC by -2\advance\zzdmC by \zzdmA |
| 351 |
\advance\zzdmD by \zzdmC\zzrecordwidth\zzdmC\zzdmD}} |
| 352 |
|
| 353 |
%\border, \borderto, and \symmetrize adjust the current rectangle. |
| 354 |
|
| 355 |
\def\border#1#2{\advance\texpr by #2\advance\bexpr by -#2 |
| 356 |
\advance\lexpr by -#1\advance\rexpr by #1} |
| 357 |
|
| 358 |
\def\borderto#1#2{\zzdmA=\rexpr\advance\zzdmA by -\lexpr\relax |
| 359 |
\ifdim#1>\zzdmA\relax\advance\zzdmA by -#1\divide\zzdmA by 2 |
| 360 |
\advance\rexpr by -\zzdmA\advance\lexpr by \zzdmA\fi |
| 361 |
\zzdmA=\texpr\advance\zzdmA by -\bexpr\relax |
| 362 |
\ifdim#2>\zzdmA\relax\advance\zzdmA by -#2\divide\zzdmA by 2 |
| 363 |
\advance\texpr by -\zzdmA\advance\bexpr by \zzdmA\fi} |
| 364 |
|
| 365 |
\def\symmetrize{\zzdmA=\texpr\advance\zzdmA by -\ycenter |
| 366 |
\zzdmB=\ycenter\advance\zzdmB by -\bexpr\relax |
| 367 |
\ifdim\zzdmA<\zzdmB\relax\zzdmA=\zzdmB\fi |
| 368 |
\texpr=\ycenter\advance\texpr by \zzdmA |
| 369 |
\bexpr=\ycenter\advance\bexpr by -\zzdmA} |
| 370 |
|
| 371 |
%\setedge#1,#2,#3,#4: accepts four numbers (giving dimensions as multiples of |
| 372 |
%\diagramunit). It sets \xstart, \ystart, \xend, \yend to #1, #2, #3, |
| 373 |
%#4, each multiplied by \diagramunit, and \xslope, \yslope to numbers |
| 374 |
% giving the slope of the line from \xstart, \ystart to \xend, \yend, |
| 375 |
%reduced to have a least common divisor. It uses \zzsearchvertexlist to set |
| 376 |
%\zzstartshadow (\zzendshadow) to the \zzshadow stored on \zzvertexlist with |
| 377 |
%coordinates #1, #2 (#3, #4). It sets \zzisedge to 1. |
| 378 |
|
| 379 |
\def\setedge#1,#2,#3,#4:{\zzcnA=#1\zzcnB=#2 |
| 380 |
\zzmultdiagramunit\xstart\zzcnA\zzmultdiagramunit\ystart\zzcnB |
| 381 |
\expandafter\zzsearchvertexlist\zzvertexlist |
| 382 |
\let\zzstartshadow=\zzshadow |
| 383 |
\zzcnA=#3\zzcnB=#4 |
| 384 |
\zzmultdiagramunit\xend\zzcnA\zzmultdiagramunit\yend\zzcnB |
| 385 |
\expandafter\zzsearchvertexlist\zzvertexlist |
| 386 |
\let\zzendshadow=\zzshadow |
| 387 |
\xslope=#3\advance\xslope by -#1\relax |
| 388 |
\yslope=#4\advance\yslope by -#2\relax |
| 389 |
\zzreduceterms\xslope\yslope{START AND END OF EDGE ARE BOTH THE SAME} |
| 390 |
\xslope=\zzcnC\yslope=\zzcnD\zzisedge=1} |
| 391 |
|
| 392 |
%\zzreduceterms sets \zzcnC and \zzcnD to the results of dividing the numbers |
| 393 |
% #1 and #2 by their greatest common divisor. The error message #3 is given |
| 394 |
%if #1 and #2 are both zero. |
| 395 |
|
| 396 |
\def\zzreduceterms#1#2#3{{ |
| 397 |
\ifnum#1<0\relax\zzcnA=-#1\else\zzcnA=#1\fi |
| 398 |
\ifnum#2<0\relax\zzcnB=-#2\else\zzcnB=#2\fi |
| 399 |
\loop\ifnum\zzcnB>0\relax |
| 400 |
\zzcnC=\zzcnA\divide\zzcnC by \zzcnB\multiply\zzcnC by -\zzcnB |
| 401 |
\advance\zzcnC by \zzcnA\zzcnA=\zzcnB\zzcnB=\zzcnC |
| 402 |
\repeat\relax |
| 403 |
\ifnum\zzcnA=0\errmessage{#3}\fi |
| 404 |
\global\zzglobalcnA=\zzcnA} |
| 405 |
\zzcnC=#1\divide\zzcnC by \zzglobalcnA\zzcnD=#2\divide\zzcnD by \zzglobalcnA} |
| 406 |
|
| 407 |
%\zzsearchvertexlist\zzvertexlist searches \zzvertexlist for an entry of the |
| 408 |
%form #1,#2:#3; for which #1 = \zzcnA and #2 = \zzcnB. If such an entry is |
| 409 |
%found, \zzshadow is defined to be #3;. Otherwise, \zzshadow is defined to be |
| 410 |
%\zzdmE=\zzdmA\zzdmF=\zzdmB. |
| 411 |
|
| 412 |
\def\zzsearchvertexlist#1{\def\zztesta{#1}\def\zztestb{\end} |
| 413 |
\ifx\zztesta\zztestb\def\zzshadow{\zzdmE=\zzdmA\zzdmF=\zzdmB} |
| 414 |
\let\zznext=\zzsearchvertexlista |
| 415 |
\else\let\zznext=\zzsearchvertexlistb\fi\zznext #1} |
| 416 |
|
| 417 |
\def\zzsearchvertexlista#1\end{} |
| 418 |
|
| 419 |
\def\zzsearchvertexlistb#1,#2:#3;{\relax |
| 420 |
\ifnum\zzcnA=#1\relax\ifnum\zzcnB=#2\relax |
| 421 |
\def\zzshadow{#3;}\let\zznext=\zzsearchvertexlista |
| 422 |
\else\let\zznext=\zzsearchvertexlist\fi |
| 423 |
\else\let\zznext=\zzsearchvertexlist\fi\zznext} |
| 424 |
|
| 425 |
%\shadeedge shades the start and end of the current edge, changing \xstart, |
| 426 |
%\ystart, \xend, \yend. |
| 427 |
|
| 428 |
\def\shadeedge{\zzcheckedge{SHADE} |
| 429 |
\def\zzprocpoly{\zzcastpoly}\def\zzprocrorect{\zzprocrorecta} |
| 430 |
\zzdmA=\xstart\zzdmB=\ystart\zzcnA=\xslope\zzcnB=\yslope |
| 431 |
\zzstartshadow\xstart=\zzdmE\ystart=\zzdmF |
| 432 |
\zzdmA=\xend\zzdmB=\yend\zzcnA=-\xslope\zzcnB=-\yslope |
| 433 |
\zzendshadow\xend=\zzdmE\yend=\zzdmF} |
| 434 |
|
| 435 |
\def\zzcheckedge#1{\relax\ifnum\zzisedge=0\relax\errmessage |
| 436 |
{ATTEMPT TO #1 NONEXISTENT EDGE}\fi} |
| 437 |
|
| 438 |
%\zzprocrorecta is used as the definition of \zzprocrorect within \shadeedge |
| 439 |
%and \zzabut. It causes a rounded rectangle to be treated as the |
| 440 |
%circumscribed octagon for purposes of shadowing or abutment. |
| 441 |
|
| 442 |
\def\zzprocrorecta#1,#2:#3,#4,#5;{\zzdmC=#3 |
| 443 |
\multiply\zzdmC by 53\divide\zzdmC by 181 |
| 444 |
\zzdmD=\zzdmC\multiply\zzdmD by -2\zzdmE=\zzdmD |
| 445 |
\advance\zzdmD by #4\advance\zzdmE by #5 |
| 446 |
\zzdmF=#4\divide\zzdmF by -2\advance\zzdmF by #1\advance\zzdmF by \zzdmC |
| 447 |
\zzdmG=#5\divide\zzdmG by 2\advance\zzdmG by #2 |
| 448 |
\edef\zzlocalshadow{\noexpand\zzprococtagon |
| 449 |
\the\zzdmF,\the\zzdmG:\the\zzdmC,\the\zzdmD,\the\zzdmE;} |
| 450 |
\zzlocalshadow} |
| 451 |
|
| 452 |
%\zzcastpoly computes the outgoing intersection of a directed line, |
| 453 |
%x = xs.t+x0, y = ys.t+y0 with a convex polygon. It is called |
| 454 |
%by defining \zzprocpoly to be \zzcastpoly, setting \zzdmA, \zzdmB, \zzcnA, |
| 455 |
%\zzcnB to x0, y0, xs, ys, and executing \zzshadow, which must have been |
| 456 |
%defined by a polygon descriptor. The result is left in \zzdmE, \zzdmF. |
| 457 |
%If the directed line does not intersect the polygon, the result is the |
| 458 |
%point on the line that is closest to the polygon. |
| 459 |
|
| 460 |
\def\zzcastpoly#1#2#3{\zzdmC=#1\zzdmD=#2\zzcnC=0 |
| 461 |
\zzcastpolya #3\end} |
| 462 |
|
| 463 |
\def\zzcastpolya#1{\def\zztesta{#1}\def\zztestb{\end} |
| 464 |
\ifx\zztesta\zztestb\let\zznext=\zzcastpolyg |
| 465 |
\else\let\zznext=\zzcastpolyc\fi\zznext {#1}} |
| 466 |
|
| 467 |
\def\zzcastpolyb#1\end{\zzcnC=\zzcnA\multiply\zzcnC by \zzcnA |
| 468 |
\zzcnD=\zzcnB\multiply\zzcnD by \zzcnB\advance\zzcnC by \zzcnD |
| 469 |
\zzdmE=\zzdmC\advance\zzdmE by -\zzdmA\multiply\zzdmE by \zzcnA |
| 470 |
\zzdmF=\zzdmD\advance\zzdmF by -\zzdmB\multiply\zzdmF by \zzcnB |
| 471 |
\advance\zzdmE by \zzdmF\divide\zzdmE by \zzcnC\zzdmF=\zzdmE |
| 472 |
\multiply\zzdmE by \zzcnA\advance\zzdmE by \zzdmA |
| 473 |
\multiply\zzdmF by \zzcnB\advance\zzdmF by \zzdmB} |
| 474 |
|
| 475 |
|
| 476 |
\def\zzcastpolyc#1#2#3{\zzcnD=\zzcnB\multiply\zzcnD by #1\relax |
| 477 |
\zzcnE=\zzcnA\multiply\zzcnE by #2\relax\advance\zzcnD by -\zzcnE\relax |
| 478 |
\ifnum\zzcnD>0\relax |
| 479 |
\ifnum\zzcnC=2\zzcastpolyd{#1}{#2}{#3}\let\zznext=\zzcastpolya\else |
| 480 |
\zzdmE=\zzdmA\advance\zzdmE by -\zzdmC\multiply\zzdmE by \zzcnB |
| 481 |
\zzdmF=\zzdmB\advance\zzdmF by -\zzdmD\multiply\zzdmF by \zzcnA |
| 482 |
\advance\zzdmE by -\zzdmF\divide\zzdmE by \zzcnD\relax |
| 483 |
\ifdim\zzdmE>#3\relax\zzcnC=3\zzcastpolyd{#1}{#2}{#3}\let\zznext=\zzcastpolya |
| 484 |
\else\ifnum\zzcnC=3\zzcastpolyf{#1}{#2}\let\zznext=\zzcastpolye\else |
| 485 |
\ifdim\zzdmE<0pt\relax |
| 486 |
\ifnum\zzcnC=1\let\zznext=\zzcastpolyb\else |
| 487 |
\zzcnC=2\zzcastpolyd{#1}{#2}{#3}\let\zznext=\zzcastpolya\fi |
| 488 |
\else\zzcastpolyf{#1}{#2}\let\zznext=\zzcastpolye\fi\fi\fi\fi |
| 489 |
\else\ifnum\zzcnC=3\let\zznext=\zzcastpolyb |
| 490 |
\else\zzcnC=1\zzcastpolyd{#1}{#2}{#3}\let\zznext=\zzcastpolya\fi\fi |
| 491 |
\zznext} |
| 492 |
|
| 493 |
\def\zzcastpolyd#1#2#3{ |
| 494 |
\zzdmE=#3\multiply\zzdmE by #1\advance\zzdmC by \zzdmE |
| 495 |
\zzdmE=#3\multiply\zzdmE by #2\advance\zzdmD by \zzdmE} |
| 496 |
|
| 497 |
\def\zzcastpolye#1\end{} |
| 498 |
|
| 499 |
\def\zzcastpolyf#1#2{\zzdmF=\zzdmE |
| 500 |
\multiply\zzdmE by #1\relax\advance\zzdmE by \zzdmC |
| 501 |
\multiply\zzdmF by #2\relax\advance\zzdmF by \zzdmD} |
| 502 |
|
| 503 |
\def\zzcastpolyg#1{\zzcastpolyb\end} |
| 504 |
|
| 505 |
%\shiftedge changes \xstart, \ystart, \xend, \yend so as to displace |
| 506 |
%the edge from \xstart, \ystart to \xend, \yend by a vector of length |
| 507 |
%#1 (a dimension) that is rotated 90 degrees counterclockwise from the edge. |
| 508 |
|
| 509 |
\def\shiftedge#1{\zzcheckedge{SHIFT} |
| 510 |
\zzdistance\xslope\yslope |
| 511 |
\zzdmA=#1\multiply\zzdmA by 100\divide\zzdmA by \zzglobalcnA\zzdmB=\zzdmA |
| 512 |
\multiply\zzdmA by -\yslope\multiply\zzdmB by \xslope |
| 513 |
\advance\xstart by \zzdmA \advance\xend by \zzdmA |
| 514 |
\advance\ystart by \zzdmB \advance\yend by \zzdmB} |
| 515 |
|
| 516 |
%\zzsqroot#1 accepts an integer and sets \zzglobalcnA to the integer part |
| 517 |
%of its square root. It works for numbers up to at least 1,000,000,000. |
| 518 |
|
| 519 |
\def\zzsqroot#1{{\zzcnA=#1 |
| 520 |
%x is \zzcnA, y is \zzcnB, n is \zzcnC, z is \zzcnD |
| 521 |
\zzcnC=0\zzcnD=1 |
| 522 |
\loop\zzcnE=\zzcnA\divide\zzcnE by \zzcnD\advance\zzcnE by 1 |
| 523 |
\relax\ifnum\zzcnD<\zzcnE\relax |
| 524 |
\advance \zzcnC by 1\multiply\zzcnD by 2 |
| 525 |
\repeat |
| 526 |
\zzcnB=0 |
| 527 |
\loop\ifnum\zzcnC>0\relax |
| 528 |
\advance\zzcnC by -1\divide\zzcnD by 2 |
| 529 |
\zzcnE=\zzcnB\advance\zzcnE by \zzcnD\multiply\zzcnE by \zzcnE\relax |
| 530 |
\ifnum\zzcnA<\zzcnE\relax\else\advance\zzcnB by \zzcnD\fi |
| 531 |
\repeat |
| 532 |
\global\zzglobalcnA=\zzcnB}} |
| 533 |
|
| 534 |
%\zzdistance#1#2 accepts two integers and sets \zzglobalcnA to 100 times |
| 535 |
%the square root of the sum of their squares. |
| 536 |
|
| 537 |
\def\zzdistance#1#2{{\zzcnA=#1\multiply\zzcnA by \zzcnA |
| 538 |
\zzcnB=#2\multiply\zzcnB by \zzcnB |
| 539 |
\advance\zzcnA by \zzcnB\multiply\zzcnA by 10000 |
| 540 |
\zzsqroot\zzcnA}} |
| 541 |
|
| 542 |
%\drawdashedge, \drawdotedge, or \drawsolidedge draws a dashed, dotted, or |
| 543 |
%solid line along the current edge. |
| 544 |
|
| 545 |
\def\drawdashedge#1#2#3#4{\zzcnA=1\zzdmA=#1\zzdmB=#2 |
| 546 |
\zzcheckposdimen\zzdmA{FIRST}{DRAWDASHEDGE} |
| 547 |
\zzcheckposdimen\zzdmB{SECOND}{DRAWDASHEDGE} |
| 548 |
\zzchecknonnegnum{#3}{THIRD}{DRAWDASHEDGE} |
| 549 |
\zzchecknonnegnum{#4}{FOURTH}{DRAWDASHEDGE} |
| 550 |
\zzcnI=#3\relax\advance\zzcnI by #4\relax |
| 551 |
\ifnum\zzcnI>0\else\errmessage |
| 552 |
{SUM OF THIRD AND FOURTH PARAMETERS OF DRAWDASHEDGE MUST BE POSITIVE}\fi |
| 553 |
\advance\zzdmB by \zzdmA |
| 554 |
\zzdrawedge{\advance\zzcnC by -\zzcnD |
| 555 |
\zzcnG=\zzcnC\divide\zzcnG by \zzcnE\relax |
| 556 |
\ifnum\zzcnG>0\relax |
| 557 |
\zzcnH=\zzcnG\multiply\zzcnH by \zzcnE\advance\zzcnC by -\zzcnH |
| 558 |
\zzcnH=\zzcnI\multiply\zzcnH by \zzcnG |
| 559 |
\advance\zzcnH by #3\divide\zzcnC by \zzcnH |
| 560 |
\zzcnH=#3\multiply\zzcnH by \zzcnC\advance\zzcnD by \zzcnH |
| 561 |
\multiply\zzcnC by \zzcnI\advance\zzcnE by \zzcnC |
| 562 |
\else\advance\zzcnD by \zzcnC\fi} |
| 563 |
{\line(\xslope,\yslope){\zzcnD}}} |
| 564 |
|
| 565 |
\def\zzcheckposdimen#1#2#3{\relax\ifdim#1>0pt\else\errmessage{ |
| 566 |
#2 PARAMETER OF #3 MUST BE POSITIVE}\fi} |
| 567 |
|
| 568 |
\def\zzchecknonnegnum#1#2#3{\relax\ifnum#1<0\relax\errmessage{ |
| 569 |
#2 PARAMETER OF #3 MUST BE NONNEGATIVE}\fi} |
| 570 |
|
| 571 |
\def\drawdotedge#1#2{\zzcnA=0\zzdmA=0pt\zzdmB=#1 |
| 572 |
\zzcheckposdimen\zzdmB{}{DRAWDOTEDGE}\zzcheckbool{#2}{SECOND}{DRAWDOTEDGE} |
| 573 |
\zzdrawedge{\zzcnG=\zzcnC\divide\zzcnG by \zzcnE\relax |
| 574 |
\ifnum\zzcnG<1\relax\zzcnG=1\fi\zzcnE=\zzcnC\divide\zzcnE by \zzcnG\relax |
| 575 |
\ifnum#2=0\relax\advance\zzcnG by -1\fi} |
| 576 |
{\kern-1.39pt\raise-.76pt\hbox{.}}} |
| 577 |
|
| 578 |
\def\drawsolidedge{\zzcnA=1\zzdmA=0pt\zzdmB=0pt |
| 579 |
\zzdrawedge{\zzcnG=0\zzcnD=\zzcnC} |
| 580 |
{\line(\xslope,\yslope){\zzcnD}}} |
| 581 |
|
| 582 |
\def\zzdrawedge#1#2{\zzcheckedge{DRAW}\relax |
| 583 |
\ifnum\zzcnA=1\relax\zzcheckslope\xslope\yslope\slopemax{SOLID OR DASHED EDGE}\fi%%%pict2e |
| 584 |
\zzcnA=\xstart\zzcnB=\ystart\zzcnD=\zzdmA\zzcnE=\zzdmB\relax |
| 585 |
\ifnum\xslope=0\relax\zzcnC=\yend\advance\zzcnC by -\zzcnB\zzcnF=\yslope |
| 586 |
\else\zzcnC=\xend\advance\zzcnC by -\zzcnA\zzcnF=\xslope |
| 587 |
\zzdistance\xslope\yslope\relax |
| 588 |
\ifnum\xslope<0\relax\global\zzglobalcnA=-\zzglobalcnA\fi |
| 589 |
\multiply\zzcnD by 100\divide\zzcnD by \zzglobalcnA\multiply\zzcnD by \xslope |
| 590 |
\multiply\zzcnE by 100\divide\zzcnE by \zzglobalcnA\multiply\zzcnE by \xslope |
| 591 |
\fi |
| 592 |
\ifnum\zzcnF<0\relax\zzcnC=-\zzcnC\fi |
| 593 |
\ifnum\zzcnC>0\relax #1\relax |
| 594 |
\ifnum\zzcnF<0\relax\zzcnE=-\zzcnE\fi\zzcnF=\zzcnE\relax |
| 595 |
\ifnum\xslope=0\relax\zzcnE=0 |
| 596 |
\else\multiply\zzcnF by \yslope\divide\zzcnF by \xslope\fi |
| 597 |
\zzmakepicture{\loop\put(\zzcnA,\zzcnB){#2} |
| 598 |
\ifnum\zzcnG>0\relax\advance\zzcnG by -1 |
| 599 |
\advance\zzcnA by \zzcnE\advance\zzcnB by \zzcnF\repeat |
| 600 |
\zzrecordwidth\xstart\xstart\zzrecordwidth\xend\xend |
| 601 |
\zztotheight=\ystart\zztotdepth=\ystart\zzrecordheight\yend\yend}\fi} |
| 602 |
|
| 603 |
%\drawedgehead draws an arrowhead along the current edge. |
| 604 |
|
| 605 |
\def\drawedgehead#1#2#3{\zzcheckbool{#2}{SECOND}{DRAWEDGEHEAD} |
| 606 |
\zzcheckbool{#3}{THIRD}{DRAWEDGEHEAD}\zzcnB=#3 |
| 607 |
\relax\ifnum#2=1\relax\zzcnA=#1\relax |
| 608 |
\zzdrawedgeheada\xstart\ystart\xend\yend\xslope\yslope |
| 609 |
\else\zzcnA=100\advance\zzcnA by -#1\relax |
| 610 |
\zzdrawedgeheada\xend\yend\xstart\ystart{-\xslope}{-\yslope}\fi} |
| 611 |
|
| 612 |
%\zzcheckbool gives an error message unless its first argument is 1 or 0. |
| 613 |
|
| 614 |
\def\zzcheckbool#1#2#3{ |
| 615 |
\ifnum#1<0\errmessage{#2 PARAMETER OF #3 MUST BE 1 OR 0}\fi |
| 616 |
\ifnum#1>1\errmessage{#2 PARAMETER OF #3 MUST BE 1 OR 0}\fi} |
| 617 |
|
| 618 |
\def\zzdrawedgeheada#1#2#3#4#5#6{\zzcheckedge{DRAW ARROWHEAD FOR} |
| 619 |
\zzcheckslope{#5}{#6}\slopemax{ARROWHEAD}%%%pict2e |
| 620 |
\zzdmA=#3\advance\zzdmA by -#1 |
| 621 |
\divide\zzdmA by 10\multiply\zzdmA by \zzcnA\divide\zzdmA by 10 |
| 622 |
\zzdmB=#4\advance\zzdmB by -#2 |
| 623 |
\divide\zzdmB by 10\multiply\zzdmB by \zzcnA\divide\zzdmB by 10 |
| 624 |
\relax\ifnum\zzcnB=1\relax |
| 625 |
\zzdistance{#5}{#6}\zzdmC=\edgeheaddisp |
| 626 |
\multiply\zzdmC by 100\divide\zzdmC by \zzglobalcnA\zzdmD=\zzdmC |
| 627 |
\multiply\zzdmC by #5\multiply\zzdmD by #6 |
| 628 |
\advance\zzdmA by \zzdmC\advance\zzdmB by \zzdmD\fi |
| 629 |
\advance\zzdmA by #1\zzcnA=\zzdmA\advance\zzdmB by #2\zzcnB=\zzdmB |
| 630 |
\zzmakepicture{\put(\zzcnA,\zzcnB){\vector(#5,#6){0}} |
| 631 |
\zzrecordwidth\zzdmA\zzdmA\zztotheight=\zzdmB\zztotdepth=\zzdmB}} |
| 632 |
|
| 633 |
%\zzcheckslope gives an errormessage if the absolute value of #1 or #2 |
| 634 |
%is greater than #3. |
| 635 |
|
| 636 |
\def\zzcheckslope#1#2#3#4{\relax |
| 637 |
\ifnum#1>#3\zzcheckslopea{#1}{#2}{#4}\fi |
| 638 |
\ifnum#1<-#3\zzcheckslopea{#1}{#2}{#4}\fi |
| 639 |
\ifnum#2>#3\zzcheckslopea{#1}{#2}{#4}\fi |
| 640 |
\ifnum#2<-#3\zzcheckslopea{#1}{#2}{#4}\fi} |
| 641 |
|
| 642 |
\def\zzcheckslopea#1#2#3{\errmessage{\the#1,\the#2 IS ILLEGAL SLOPE FOR #3}} |
| 643 |
|
| 644 |
%The following macros each call \zzsetupbox{#2}{#3} and then issue the |
| 645 |
%resulting expression so that its shadow touches the edge x = \xslope.t |
| 646 |
%+\xstart, y = \yslope.t+\ystart. \abutX places the expression to the X |
| 647 |
%of the edge. For \abutleft and \abutright, #1 gives the y-coordinate |
| 648 |
%of the expression as an integer multiple of \diagramunit. For \abutbelow |
| 649 |
%and \abutabove, #1 gives the x-coordinate similarly. The macros \abutXd |
| 650 |
%are similar, except that #1 should be a dimension. |
| 651 |
|
| 652 |
\def\abutleft#1:#2#3{\zzabut{#1}{#2}{#3}{-\yslope}{\zzslidehoriz}{1}} |
| 653 |
\def\abutright#1:#2#3{\zzabut{#1}{#2}{#3}{\yslope}{\zzslidehoriz}{1}} |
| 654 |
\def\abutbelow#1:#2#3{\zzabut{#1}{#2}{#3}{\xslope}{\zzslidevert}{1}} |
| 655 |
\def\abutabove#1:#2#3{\zzabut{#1}{#2}{#3}{-\xslope}{\zzslidevert}{1}} |
| 656 |
|
| 657 |
\def\abutleftd#1#2#3{\zzabut{#1}{#2}{#3}{-\yslope}{\zzslidehoriz}{0}} |
| 658 |
\def\abutrightd#1#2#3{\zzabut{#1}{#2}{#3}{\yslope}{\zzslidehoriz}{0}} |
| 659 |
\def\abutbelowd#1#2#3{\zzabut{#1}{#2}{#3}{\xslope}{\zzslidevert}{0}} |
| 660 |
\def\abutaboved#1#2#3{\zzabut{#1}{#2}{#3}{-\xslope}{\zzslidevert}{0}} |
| 661 |
|
| 662 |
\def\zzabut#1#2#3#4#5#6{\zzcheckedge{ABUT TO} |
| 663 |
\zzsetupbox{#2}{#3}\zzcnA=\xslope\zzcnB=\yslope |
| 664 |
\relax\ifnum#4<0\relax\zzcnA=-\zzcnA\zzcnB=-\zzcnB\fi |
| 665 |
\def\zzprocpoly{\zzclosestpoly}\def\zzprocrorect{\zzprocrorecta} |
| 666 |
\zzglobalshadow |
| 667 |
\advance\zzdmC by -\zzglobalxcenter\advance\zzdmD by -\zzglobalycenter |
| 668 |
\relax\ifnum#6=1\relax\zzmultdiagramunit\zzdmA{#1}\else\zzdmA=#1\fi |
| 669 |
\zzdmB=\zzdmA#5\relax\zzissue} |
| 670 |
|
| 671 |
\def\zzslidehoriz{\relax\ifnum\yslope=0\errmessage |
| 672 |
{ABUTLEFT OR ABUTRIGHT ATTEMPTED FOR HORIZONTAL EDGE}\fi |
| 673 |
\advance\zzdmA by \zzdmD\advance\zzdmA by -\ystart |
| 674 |
\multiply\zzdmA by \xslope\divide\zzdmA by \yslope |
| 675 |
\advance\zzdmA by \xstart\advance\zzdmA by -\zzdmC} |
| 676 |
|
| 677 |
\def\zzslidevert{\relax\ifnum\xslope=0\errmessage |
| 678 |
{ABUTBELOW OR ABUTABOVE ATTEMPTED FOR VERTICAL EDGE}\fi |
| 679 |
\advance\zzdmB by \zzdmC\advance\zzdmB by -\xstart |
| 680 |
\multiply\zzdmB by \yslope\divide\zzdmB by \xslope |
| 681 |
\advance\zzdmB by \ystart\advance\zzdmB by -\zzdmD} |
| 682 |
|
| 683 |
%\zzclosestpoly finds the vertex of a convex polygon that is closest to a |
| 684 |
%directed line, x = xs.t+x0, y = ys.t+y0, assuming that the directed line |
| 685 |
%is to the left (right) of the polygon if ys is positive (negative) |
| 686 |
%and above (below) the polygon if xs is positive (negative). |
| 687 |
%It is called by defining \zzprocpoly to be \zzclosestpoly, setting \zzcnA, |
| 688 |
%\zzcnB to xs, ys, and executing \zzglobalshadow, which must have been |
| 689 |
%defined by a polygon descriptor. The output is left in \zzdmC, \zzdmD. |
| 690 |
|
| 691 |
\def\zzclosestpoly#1#2#3{\zzdmC=#1\zzdmD=#2\zzcnC=0\zzclosestpolya #3\end} |
| 692 |
|
| 693 |
\def\zzclosestpolya#1{\def\zztesta{#1}\def\zztestb{\end} |
| 694 |
\ifx\zztesta\zztestb\let\zznext=\zzclosestpolyb |
| 695 |
\else\let\zznext=\zzclosestpolyc\fi\zznext {#1}} |
| 696 |
|
| 697 |
\def\zzclosestpolyb#1{} |
| 698 |
|
| 699 |
\def\zzclosestpolyc#1#2#3{\zzcnD=\zzcnB\multiply\zzcnD by #1\relax |
| 700 |
\zzcnE=\zzcnA\multiply\zzcnE by #2\relax\advance\zzcnD by -\zzcnE\relax |
| 701 |
\ifnum\zzcnD>0\relax |
| 702 |
\ifnum\zzcnC=1\let\zznext=\zzclosestpolyd |
| 703 |
\else\zzcnC=0\zzcastpolyd{#1}{#2}{#3}\let\zznext=\zzclosestpolya\fi |
| 704 |
\else\zzcnC=1\zzcastpolyd{#1}{#2}{#3}\let\zznext=\zzclosestpolya\fi |
| 705 |
\zznext} |
| 706 |
|
| 707 |
\def\zzclosestpolyd#1\end{} |
| 708 |
|
| 709 |
%\setcircle initializes \dcircle, \xcircle, and \ycircle to its first |
| 710 |
%three parameters, and sets \zziscircle to 1. |
| 711 |
|
| 712 |
\def\setcircle#1#2#3{\dcircle=#1\xcircle=#2\ycircle=#3\zziscircle=1} |
| 713 |
|
| 714 |
%\shiftcircle#1#2 displaces \xcircle, \ycircle by #1, #2. |
| 715 |
|
| 716 |
\def\shiftcircle#1#2{\zzcheckcircle{SHIFT} |
| 717 |
\advance\xcircle by #1\advance\ycircle by #2} |
| 718 |
|
| 719 |
\def\zzcheckcircle#1{\relax\ifnum\zziscircle=0\errmessage |
| 720 |
{ATTEMPT TO #1 NONEXISTENT CIRCLE}\fi} |
| 721 |
|
| 722 |
%\drawcircle draws quadrants of the current circle. |
| 723 |
|
| 724 |
\def\drawcircle#1#2#3#4{\zzcheckcircle{DRAW}\zzdmA=\dcircle\divide\zzdmA by 2 |
| 725 |
\zzmakepicture{\zzcnA=\dcircle\zzcnB=\xcircle\zzcnC=\ycircle |
| 726 |
\zztotheight=\ycircle\zztotdepth=\ycircle |
| 727 |
\zzrecordwidth\xcircle\xcircle\relax |
| 728 |
\zzdrawcirclea{#1}{tr}{\zzdmA}{\zzdmA}\zzdrawcirclea{#2}{br}{\zzdmA}{-\zzdmA} |
| 729 |
\zzdrawcirclea{#3}{bl}{-\zzdmA}{-\zzdmA} |
| 730 |
\zzdrawcirclea{#4}{tl}{-\zzdmA}{\zzdmA}}} |
| 731 |
|
| 732 |
\def\zzdrawcirclea#1#2#3#4{\zzcheckbool{#1}{}{DRAWCIRCLE}\ifnum#1=1\relax |
| 733 |
\put(\zzcnB,\zzcnC){\oval(\zzcnA,\zzcnA)[#2]} |
| 734 |
\zzdmB=\xcircle\advance\zzdmB by #3\zzrecordwidth\zzdmB\zzdmB |
| 735 |
\zzdmB=\ycircle\advance\zzdmB by #4\zzrecordheight\zzdmB\zzdmB\fi} |
| 736 |
|
| 737 |
%\drawcirclehead issues an arrowhead placed on the current circle. |
| 738 |
|
| 739 |
\def\drawcirclehead#1#2#3{\zzcheckcircle{DRAW ARROWHEAD FOR} |
| 740 |
\zzreduceterms{#1}{#2}{0,0 ARE ILLEGAL PARAMETERS FOR DRAWCIRCLEHEAD} |
| 741 |
\zzdistance{\zzcnC}{\zzcnD}\zzcheckbool{#3}{THIRD}{DRAWCIRCLEHEAD} |
| 742 |
\ifnum#3=1\relax\zzcnA=\zzcnD\zzcnB=-\zzcnC\else\zzcnA=-\zzcnD\zzcnB=\zzcnC\fi |
| 743 |
\zzdmA=\dcircle\multiply\zzdmA by 50\divide\zzdmA by \zzglobalcnA |
| 744 |
\zzdmB=\circleheaddisp\multiply\zzdmB by 100\divide\zzdmB by \zzglobalcnA |
| 745 |
\zzdmE=\zzdmA\multiply\zzdmE by \zzcnC\zzdmC=\xcircle\advance\zzdmC by \zzdmE |
| 746 |
\zzdmE=\zzdmB\multiply\zzdmE by \zzcnA\advance\zzdmC by \zzdmE |
| 747 |
\zzdmE=\zzdmA\multiply\zzdmE by \zzcnD\zzdmD=\ycircle\advance\zzdmD by \zzdmE |
| 748 |
\zzdmE=\zzdmB\multiply\zzdmE by \zzcnB\advance\zzdmD by \zzdmE |
| 749 |
\zzcnC=\zzdmC\zzcnD=\zzdmD\zzcheckslope\zzcnA\zzcnB\slopemax{ARROWHEAD}%%%pict2e |
| 750 |
\zzmakepicture{\put(\zzcnC,\zzcnD){\vector(\zzcnA,\zzcnB){0}} |
| 751 |
\zzrecordwidth\zzdmC\zzdmC\zztotheight=\zzdmD\zztotdepth=\zzdmD}} |
| 752 |
|
| 753 |
%The next four macros cause an expression to be abutted to the current |
| 754 |
%circle. |
| 755 |
|
| 756 |
\def\abutcircleleft#1#2#3{\zzabutcircle{#1}{#2}{#3}{} |
| 757 |
\zzslidehoriz{\relax\ifdim\zzdmA>\zzdmH\relax\zzdmH=\zzdmA\fi}} |
| 758 |
|
| 759 |
\def\abutcircleright#1#2#3{\zzabutcircle{#1}{#2}{#3}{\zzrotate\zzrotate} |
| 760 |
\zzslidehoriz{\relax\ifdim\zzdmA<\zzdmH\relax\zzdmH=\zzdmA\fi}} |
| 761 |
|
| 762 |
\def\abutcirclebelow#1#2#3{\zzabutcircle{#1}{#2}{#3}{\zzrotate} |
| 763 |
\zzslidevert{\relax\ifdim\zzdmB>\zzdmI\relax\zzdmI=\zzdmB\fi}} |
| 764 |
|
| 765 |
\def\abutcircleabove#1#2#3{\zzabutcircle |
| 766 |
{#1}{#2}{#3}{\zzrotate\zzrotate\zzrotate} |
| 767 |
\zzslidevert{\relax\ifdim\zzdmB<\zzdmI\relax\zzdmI=\zzdmB\fi}} |
| 768 |
|
| 769 |
\def\zzabutcircle#1#2#3#4#5#6{\zzcheckcircle{ABUT TO} |
| 770 |
\zzsetupbox{#2}{#3}\def\zzprocpoly{\zzclosestpoly} |
| 771 |
\def\zzprocrorect{\zzprocrorecta} |
| 772 |
\zzdmF=\dcircle\divide\zzdmF by 2 |
| 773 |
\zzdmG=\dcircle\multiply\zzdmG by 100\divide\zzdmG by 283 |
| 774 |
\xstart=-\zzdmF\ystart=0pt\xslope=0\yslope=-1 |
| 775 |
\zzabutcirclea{#1}{#4}{#5}\zzdmH=\zzdmA\zzdmI=\zzdmB |
| 776 |
\xstart=-\zzdmG\ystart=\zzdmG\xslope=-1\yslope=-1 |
| 777 |
\zzabutcirclea{#1}{#4}{#5}#6\relax |
| 778 |
\xstart=-\zzdmG\ystart=-\zzdmG\xslope=1\yslope=-1 |
| 779 |
\zzabutcirclea{#1}{#4}{#5}#6\relax |
| 780 |
\zzdmA=\zzdmH\advance\zzdmA by \xcircle |
| 781 |
\zzdmB=\zzdmI\advance\zzdmB by \ycircle |
| 782 |
\zzissue} |
| 783 |
|
| 784 |
\def\zzabutcirclea#1#2#3{#2\relax |
| 785 |
\zzcnA=\xslope\zzcnB=\yslope |
| 786 |
\zzglobalshadow |
| 787 |
\advance\zzdmC by -\zzglobalxcenter\advance\zzdmD by -\zzglobalycenter |
| 788 |
\zzdmA=#1\zzdmB=\zzdmA #3\relax} |
| 789 |
|
| 790 |
\def\zzrotate{\zzdmE=\xstart\xstart=-\ystart\ystart=\zzdmE |
| 791 |
\zzcnC=\xslope\xslope=-\yslope\yslope=\zzcnC} |
| 792 |
|
| 793 |
%MACROS FOR CATEGORY-THEORY DIAGRAMS |
| 794 |
|
| 795 |
%The following control symbols may be redefined by the user: |
| 796 |
\def\ctvertexstyle{\displaystyle} |
| 797 |
\def\ctabutstyle{\textstyle} |
| 798 |
\def\ctvertexborderlr{3pt} |
| 799 |
\def\ctvertexbordertb{4pt} |
| 800 |
\def\ctloopdiameter{20pt} |
| 801 |
\def\ctabutcircledisp{5pt} |
| 802 |
\def\ctabutborderlr{2pt} |
| 803 |
\def\ctabutbordertb{2pt} |
| 804 |
\def\ctabutborderinset{3pt} |
| 805 |
\def\ctabutborderinsetdouble{6pt}%Must be twice \ctabutborderinset |
| 806 |
\def\ctdoubleedgedisp{2pt} |
| 807 |
|
| 808 |
%The following registers are used locally: |
| 809 |
\newdimen\zzdmX\newdimen\zzdmY |
| 810 |
|
| 811 |
%Hidden macros and other defined control symbols: |
| 812 |
% used by \ctdiagram: \diagram\ctsolid\cthead |
| 813 |
% used by \ctv and \ctvg: \vertex\border\rect |
| 814 |
% used by \ctgl: \leftghost |
| 815 |
% used by \ctgr: \rightghost |
| 816 |
% used by \ctlptl, \ctlptlcc, \ctlptr, \ctlptrcc, \ctlpbr, \ctlpbrcc, |
| 817 |
% \ctlpbl, \ctlpblcc: \zzctlp\border\setcircle\shiftcircle\drawcircle |
| 818 |
% \drawcirclehead\abutcircleleft\abutcircleright\zzctabutprog |
| 819 |
% \octagon |
| 820 |
% used by \cten, \ctet, \cteb, \ctel, \cter, \ctetg, \ctebg, \ctelg, \cterg, |
| 821 |
% \ctetb, \ctelr, \ctetbg, \ctelrg: \setedge\zzctxmean\zzctymean |
| 822 |
% \zzmultdiagramunit\zzcte\zzctee\shadeedge\abutaboved\abutbelowd |
| 823 |
% \abutleftd\abutrightd\zzctabutprog\border\octagon\shiftedge |
| 824 |
% \drawsolidedge\zzctdrawdashedge\drawdashedge\zzctdrawdotedge |
| 825 |
% \drawdotedge\zzctdrawedgehead\drawedgehead\zzctnodrawedgehead |
| 826 |
% multiply defined control symbols: \zzctdrawedge\zzctdrawhead |
| 827 |
% \zzctxmeanadj\zzctymeanadj |
| 828 |
|
| 829 |
%\ctdiagram is similar to \diagram, except that it executes \ctsolid and |
| 830 |
%\cthead before the expression program #1. |
| 831 |
|
| 832 |
\def\ctdiagram#1{\diagram{\ctsolid\cthead\ctoutermid #1}} |
| 833 |
|
| 834 |
%\ctvg is similar to \vertex except that the expression #3 is printed in |
| 835 |
%\ctvertexstyle mode, and the expression program #4 is followed by a |
| 836 |
%standard program that borders the current rectangle by \ctvertexborderlr |
| 837 |
%on the sides and \ctvertexbordertb on the top and bottom, and then |
| 838 |
%creates a rectangular shadow. \ctv is similar to \ctvg except that the |
| 839 |
%expression program is empty (except for the standard program). |
| 840 |
|
| 841 |
\def\ctvg#1,#2:#3#4{\vertex #1,#2:{\ctvertexstyle #3}{#4\relax |
| 842 |
\border\ctvertexborderlr\ctvertexbordertb\rect}} |
| 843 |
|
| 844 |
\def\ctv#1,#2:#3{\ctvg #1,#2:{#3}{}} |
| 845 |
|
| 846 |
%\ctgl and \ctgr are similar to \leftghost and \rightghost except that |
| 847 |
%the expression #1 is printed in \ctvertexstyle. |
| 848 |
|
| 849 |
\def\ctgl#1{\leftghost{\ctvertexstyle #1}} |
| 850 |
|
| 851 |
\def\ctgr#1{\rightghost{\ctvertexstyle #1}} |
| 852 |
|
| 853 |
%The following eight macros print a three-quarter-circle loop of diameter |
| 854 |
%\ctloopdiameter at one of the corners of an expanded current rectangle, |
| 855 |
%with an arrowhead at one end of the loop. |
| 856 |
|
| 857 |
\def\ctlptl#1{\zzctlp{\lexpr\texpr}{{0pt}\circleheaddisp}{1011}{101} |
| 858 |
{\abutcircleleft\ctabutcircledisp}{#1}} |
| 859 |
|
| 860 |
\def\ctlptlcc#1{\zzctlp{\lexpr\texpr}{{-\circleheaddisp}{0pt}}{1011}{0{-1}0} |
| 861 |
{\abutcircleleft\ctabutcircledisp}{#1}} |
| 862 |
|
| 863 |
\def\ctlptr#1{\zzctlp{\rexpr\texpr}{\circleheaddisp{0pt}}{1101}{0{-1}1} |
| 864 |
{\abutcircleright\ctabutcircledisp}{#1}} |
| 865 |
|
| 866 |
\def\ctlptrcc#1{\zzctlp{\rexpr\texpr}{{0pt}\circleheaddisp}{1101}{{-1}00} |
| 867 |
{\abutcircleright\ctabutcircledisp}{#1}} |
| 868 |
|
| 869 |
\def\ctlpbr#1{\zzctlp{\rexpr\bexpr}{{0pt}{-\circleheaddisp}}{1110}{{-1}01} |
| 870 |
{\abutcircleright{-\ctabutcircledisp}}{#1}} |
| 871 |
|
| 872 |
\def\ctlpbrcc#1{\zzctlp{\rexpr\bexpr}{\circleheaddisp{0pt}}{1110}{010} |
| 873 |
{\abutcircleright{-\ctabutcircledisp}}{#1}} |
| 874 |
|
| 875 |
\def\ctlpbl#1{\zzctlp{\lexpr\bexpr}{{-\circleheaddisp}{0pt}}{0111}{011} |
| 876 |
{\abutcircleleft{-\ctabutcircledisp}}{#1}} |
| 877 |
|
| 878 |
\def\ctlpblcc#1{\zzctlp{\lexpr\bexpr}{{0pt}{-\circleheaddisp}}{0111}{100} |
| 879 |
{\abutcircleleft{-\ctabutcircledisp}}{#1}} |
| 880 |
|
| 881 |
\def\zzctlp#1#2#3#4#5#6{\border\ctvertexborderlr\ctvertexbordertb |
| 882 |
\setcircle\ctloopdiameter #1 |
| 883 |
\border{-\ctvertexborderlr}{-\ctvertexbordertb} |
| 884 |
\shiftcircle #2\drawcircle #3\drawcirclehead #4 |
| 885 |
#5{\ctabutstyle #6}\zzctabutprog} |
| 886 |
|
| 887 |
\def\zzctabutprog{\border\ctabutborderlr\ctabutbordertb |
| 888 |
\borderto{\ctabutborderinsetdouble}{\ctabutborderinsetdouble} |
| 889 |
\octagon\ctabutborderinset} |
| 890 |
|
| 891 |
%\cten#1,#2,#3,#4: draws a shaded edge from #1,#2 to #3,#4, possibly with |
| 892 |
%an arrowhead at its end. |
| 893 |
|
| 894 |
\def\cten#1:{\setedge#1:\shadeedge\zzctdrawedge\zzctdrawhead1} |
| 895 |
|
| 896 |
%The following four macros draw a shaded edge, possibly with an arrowhead |
| 897 |
%at the end, and abut an expression to the edge at its midpoint. |
| 898 |
|
| 899 |
\def\ctet#1:#2{\setedge#1:\zzctxmean\zzcte\abutaboved{#2}\zzctxmeanadj} |
| 900 |
|
| 901 |
\def\cteb#1:#2{\setedge#1:\zzctxmean\zzcte\abutbelowd{#2}\zzctxmeanadj} |
| 902 |
|
| 903 |
\def\ctel#1:#2{\setedge#1:\zzctymean\zzcte\abutleftd{#2}\zzctymeanadj} |
| 904 |
|
| 905 |
\def\cter#1:#2{\setedge#1:\zzctymean\zzcte\abutrightd{#2}\zzctymeanadj} |
| 906 |
|
| 907 |
\def\zzctxmean{\zzdmX=\xstart\advance\zzdmX by \xend\divide\zzdmX by 2} |
| 908 |
|
| 909 |
\def\zzctymean{\zzdmX=\ystart\advance\zzdmX by \yend\divide\zzdmX by 2} |
| 910 |
|
| 911 |
\def\zzcte#1#2#3{\shadeedge #3\zzctdrawedge\zzctdrawhead1 |
| 912 |
#1\zzdmX{\ctabutstyle #2}\zzctabutprog} |
| 913 |
|
| 914 |
%The next four macros behave similarly to those above, but abut an |
| 915 |
%expression to a specified point on the edge. |
| 916 |
|
| 917 |
\def\ctetg#1;#2:#3{\setedge#1:\zzmultdiagramunit\zzdmX{#2}\zzcte |
| 918 |
\abutaboved{#3}\relax} |
| 919 |
|
| 920 |
\def\ctebg#1;#2:#3{\setedge#1:\zzmultdiagramunit\zzdmX{#2}\zzcte |
| 921 |
\abutbelowd{#3}\relax} |
| 922 |
|
| 923 |
\def\ctelg#1;#2:#3{\setedge#1:\zzmultdiagramunit\zzdmX{#2}\zzcte |
| 924 |
\abutleftd{#3}\relax} |
| 925 |
|
| 926 |
\def\cterg#1;#2:#3{\setedge#1:\zzmultdiagramunit\zzdmX{#2}\zzcte |
| 927 |
\abutrightd{#3}\relax} |
| 928 |
|
| 929 |
%\ctetb (\ctelr) draws a pair of shaded edges, with two expressions |
| 930 |
%abutted to the top and bottom (left and right) of the midpoint. |
| 931 |
%\ctetbg and \ctelrg are similar, but abut to a specified point on the edge. |
| 932 |
|
| 933 |
\def\ctetb#1:#2#3#4#5{\zzcheckbool{#2}{FIFTH}{CTETB} |
| 934 |
\zzcheckbool{#3}{SIXTH}{CTETB} |
| 935 |
\setedge#1:\zzctxmean\zzctee\xslope\abutaboved\abutbelowd |
| 936 |
{#2}{#3}{#4}{#5}\zzctxmeanadj} |
| 937 |
|
| 938 |
\def\ctelr#1:#2#3#4#5{\zzcheckbool{#2}{FIFTH}{CTELR} |
| 939 |
\zzcheckbool{#3}{SIXTH}{CTELR} |
| 940 |
\setedge#1:\zzctymean\zzctee\yslope\abutleftd\abutrightd |
| 941 |
{#2}{#3}{#4}{#5}\zzctymeanadj} |
| 942 |
|
| 943 |
\def\ctetbg#1;#2,#3:#4#5#6#7{\zzcheckbool{#4}{SEVENTH}{CTETBG} |
| 944 |
\zzcheckbool{#5}{EIGHTH}{CTETBG}\setedge#1:\zzmultdiagramunit\zzdmX{#2} |
| 945 |
\zzctee\xslope |
| 946 |
\abutaboved{\zzmultdiagramunit\zzdmX{#3}\abutbelowd}{#4}{#5}{#6}{#7}\relax} |
| 947 |
|
| 948 |
\def\ctelrg#1;#2,#3:#4#5#6#7{\zzcheckbool{#4}{SEVENTH}{CTELRG} |
| 949 |
\zzcheckbool{#5}{EIGHTH}{CTELRG}\setedge#1:\zzmultdiagramunit\zzdmX{#2} |
| 950 |
\zzctee\yslope |
| 951 |
\abutleftd{\zzmultdiagramunit\zzdmX{#3}\abutrightd}{#4}{#5}{#6}{#7}\relax} |
| 952 |
|
| 953 |
\def\zzctee#1#2#3#4#5#6#7#8{ |
| 954 |
\ifnum#1>0\relax\zzdmY=\ctdoubleedgedisp\else\zzdmY=-\ctdoubleedgedisp\fi |
| 955 |
\shiftedge\zzdmY\shadeedge #8\zzctdrawedge\zzctdrawhead{#4} |
| 956 |
#2\zzdmX{\ctabutstyle #6}\zzctabutprog |
| 957 |
\multiply\zzdmY by -2\relax |
| 958 |
\shiftedge\zzdmY\shadeedge #8\zzctdrawedge\zzctdrawhead{#5} |
| 959 |
#3\zzdmX{\ctabutstyle #7}\zzctabutprog} |
| 960 |
|
| 961 |
%\ctinnermid defines \zzctxmeanadj and \zzctymeanadj so that \ctet, \cteb, |
| 962 |
%\ctel, \cter, \ctetb, and \ctelr recompute the midpoint of the current |
| 963 |
%edge after shading. \ctoutermid defines these control symbols so that |
| 964 |
%these routines do not recompute the midpoint. |
| 965 |
|
| 966 |
\def\ctinnermid{\def\zzctxmeanadj{\zzctxmean}\def\zzctymeanadj{\zzctymean}} |
| 967 |
|
| 968 |
\def\ctoutermid{\def\zzctxmeanadj{\relax}\def\zzctymeanadj{\relax}} |
| 969 |
|
| 970 |
%\zzctdrawdashedge draws a dashed edge. |
| 971 |
|
| 972 |
\def\zzctdrawdashedge{\relax |
| 973 |
\ifnum\xslope=0\relax\drawdashedge{7pt}{7pt}11 |
| 974 |
\else\ifnum\yslope=0\relax\drawdashedge{7pt}{7pt}11 |
| 975 |
\else\drawdashedge{15pt}{7pt}01\fi\fi} |
| 976 |
|
| 977 |
%\zzctdrawdotedge draws a dotted edge. |
| 978 |
|
| 979 |
\def\zzctdrawdotedge{\drawdotedge{8pt}1} |
| 980 |
|
| 981 |
%\ctsolid (\ctdash,\ctdot) defines \zzctdrawedge to be \drawsolidedge |
| 982 |
%(\zzctdrawdashedge,\zzctdrawdotedge), so that edges will be solid |
| 983 |
%(dashed, dotted). |
| 984 |
|
| 985 |
\def\ctsolid{\def\zzctdrawedge{\drawsolidedge}} |
| 986 |
|
| 987 |
\def\ctdash{\def\zzctdrawedge{\zzctdrawdashedge}} |
| 988 |
|
| 989 |
\def\ctdot{\def\zzctdrawedge{\zzctdrawdotedge}} |
| 990 |
|
| 991 |
%\zzctdrawedgehead places a forward-pointing arrowhead at the end of an edge |
| 992 |
%if #1=1 or a backward-pointing arrowhead at the beginning if #1=0. |
| 993 |
%\zzctnodrawedgehead is called in the same way but does nothing. |
| 994 |
|
| 995 |
\def\zzctdrawedgehead#1{\relax\ifnum#1=1\relax |
| 996 |
\drawedgehead{100}10\else\drawedgehead{0}00\fi} |
| 997 |
|
| 998 |
\def\zzctnodrawedgehead#1{} |
| 999 |
|
| 1000 |
%\cthead (\ctnohead) defines \zzctdrawhead to be \zzctdrawedgehead |
| 1001 |
%(\zzctnodrawedgehead), so that edges will (will not) have arrowheads. |
| 1002 |
|
| 1003 |
\def\cthead{\def\zzctdrawhead{\zzctdrawedgehead}} |
| 1004 |
|
| 1005 |
\def\ctnohead{\def\zzctdrawhead{\zzctnodrawedgehead}} |
| 1006 |
|
| 1007 |
|
| 1008 |
% Extensions by Bob Tennent (May 2009): |
| 1009 |
% |
| 1010 |
%\drawedgebar draws a bar across the end of the current edge. |
| 1011 |
% |
| 1012 |
\def\drawedgebar{\zzdrawedgebara\xend\yend\xstart\ystart{-\xslope}{-\yslope}} |
| 1013 |
\def\zzdrawedgebara#1#2#3#4#5#6{\zzcheckedge{DRAW ARROWBAR FOR} |
| 1014 |
\zzcheckslope{#5}{#6}4{ARROWBAR} |
| 1015 |
\zzdmA=#3\advance\zzdmA by -#1 |
| 1016 |
\divide\zzdmA by 10\multiply\zzdmA by 100\divide\zzdmA by 10 |
| 1017 |
\zzdmB=#4\advance\zzdmB by -#2 |
| 1018 |
\divide\zzdmB by 10\multiply\zzdmB by 100\divide\zzdmB by 10 |
| 1019 |
\zzdistance{#5}{#6}\zzdmC=0pt |
| 1020 |
\multiply\zzdmC by 100\divide\zzdmC by \zzglobalcnA\zzdmD=\zzdmC |
| 1021 |
\multiply\zzdmC by #5\multiply\zzdmD by #6 |
| 1022 |
\advance\zzdmA by \zzdmC\advance\zzdmB by \zzdmD |
| 1023 |
\advance\zzdmA by #1\zzcnA=\zzdmA\advance\zzdmB by #2\zzcnB=\zzdmB |
| 1024 |
\zzmakepicture{\put(\zzcnA,\zzcnB){\line(#6,-#5){140000}} |
| 1025 |
\zzrecordwidth\zzdmA\zzdmA\zztotheight=\zzdmB\zztotdepth=\zzdmB} |
| 1026 |
\zzmakepicture{\put(\zzcnA,\zzcnB){\line(-#6,#5){140000}} |
| 1027 |
\zzrecordwidth\zzdmA\zzdmA\zztotheight=\zzdmB\zztotdepth=\zzdmB} |
| 1028 |
} |
| 1029 |
|
| 1030 |
% \ctec draws a bezier-curve edge from (#1,#2) to (#3,#4) using (#5,#6) as a |
| 1031 |
% control point; the balanced math text #7 is centered at the control point |
| 1032 |
% |
| 1033 |
\def\ctec#1,#2,#3,#4,#5,#6:#7{ |
| 1034 |
\ctv #5,#6:{#7} |
| 1035 |
% get and save \xstart,\ystart after shadowing |
| 1036 |
\setedge#1,#2,#5,#6: |
| 1037 |
\def\zzprocpoly{\zzcastpoly}\def\zzprocrorect{\zzprocrorecta} |
| 1038 |
\zzdmA=\xstart\zzdmB=\ystart\zzcnA=\xslope\zzcnB=\yslope |
| 1039 |
\zzstartshadow\xstart=\zzdmE\ystart=\zzdmF |
| 1040 |
\zzdmH=\xstart\zzdmI=\ystart |
| 1041 |
% get \xend, \yend and shadow |
| 1042 |
\setedge#5,#6,#3,#4: |
| 1043 |
\def\zzprocpoly{\zzcastpoly}\def\zzprocrorect{\zzprocrorecta} |
| 1044 |
\zzdmA=\xend\zzdmB=\yend\zzcnA=-\xslope\zzcnB=-\yslope |
| 1045 |
\zzendshadow\xend=\zzdmE\yend=\zzdmF |
| 1046 |
% draw head |
| 1047 |
\zzctdrawhead1 |
| 1048 |
% restore saved \xstart, \ystart |
| 1049 |
\xstart=\zzdmH\ystart=\zzdmI |
| 1050 |
% compute control-point parameters |
| 1051 |
\zzcnA=#5\zzcnB=#6 |
| 1052 |
\zzmultdiagramunit\zzdmH\zzcnA\zzmultdiagramunit\zzdmI\zzcnB |
| 1053 |
\zzcnA=\xstart\zzcnB=\ystart\zzcnC=\xend\zzcnD=\yend\zzcnE=\zzdmH\zzcnF=\zzdmI |
| 1054 |
% draw bezier curve |
| 1055 |
\zzmakepicture{\qbezier(\zzcnA,\zzcnB)(\zzcnE,\zzcnF)(\zzcnC,\zzcnD) |
| 1056 |
\zzrecordwidth\xstart\xstart\zzrecordwidth\xend\xend |
| 1057 |
\zztotheight=\ystart\zztotdepth=\ystart\zzrecordheight\yend\yend}} |
| 1058 |
|
| 1059 |
|