Debian Codegraph @

texmf-dist/tex/generic/pictex/pictexwd.tex

raw
1 % G"andertes PiCTeX.TEX mit weniger Dimensionsregistern %
2 % von Andreas Schrell, ohne Gew"ahr!!!!!!!
3 % Version 0.0 vom 31.03.1994
4 % FEHLERMELDUNGEN an [email protected]
5
6 % This is PiCTeXWD, Version 1.1 9/21/87
7
8 % CAVEAT: The PiCTeX manual often has a more lucid explanation
9 % of any given topic than you will find in the internal documentation
10 % of the macros.
11
12 % PiCTeX's commands can be classified into two groups: (1) public (or
13 % external), and (2) private (or internal). The public macros are
14 % discussed at length in the manual. The only discussion of the private
15 % macros is the internal documentation. The private macros all have
16 % names beginning with an exclamation point (!) of category code 11.
17 % Since in normal usage "!" has category code 12, these macros can't
18 % be accessed or modified by the general user.
19
20 % The macros are organized into thematically related groups. For example,
21 % the macros dealing with dots & dashes are all in the DASHPATTERN group.
22 % The table below shows which macros are in which groups. The table
23 % covers all public macros, and many (but not all) of PiCTeX's upper level
24 % private macros. Following the table, the various groups are listed
25 % in the order in which they appear in the table.
26
27 % *********************** TABLE OF GROUPS OF MACROS **********************
28
29 % HACKS: Utility macros
30 % \PiC
31 % \PiCTeX
32 % \placevalueinpts
33 % \!!loop
34 % \!cfor
35 % \!copylist
36 % \!ecfor
37 % \!etfor
38 % \!getnext
39 % \!getnextvalueof
40 % \!ifempty
41 % \!ifnextchar
42 % \!leftappend
43 % \!listaddon
44 % \!loop
45 % \!lop
46 % \!mlap
47 % \!not
48 % \!removept
49 % \!rightappend
50 % \!tfor
51 % \!vmlap
52 % \!wlet
53
54 % ALLOCATION: Allocates registers
55
56 % AREAS: Deals with plot areas
57 % \axis
58 % \grid
59 % \invisibleaxes
60 % \normalgraphs
61 % \plotheading
62 % \setplotarea
63 % \visibleaxes
64
65 % ARROWS: Draws arrows
66 % \arrow
67 % \betweenarrows
68
69 % BARS: Draws bars
70 % \putbar
71 % \setbars
72
73 % BOXES: Draws rectangles
74 % \frame
75 % \putrectangle
76 % \rectangle
77 % \shaderectangleson
78 % \shaderectanglesoff
79
80 % CURVES: Upper level plot commands
81 % \hshade
82 % \plot
83 % \sethistograms
84 % \setlinear
85 % \setquadratic
86 % \vshade
87
88 % DASHPATTERNS: Sets up dash patterns
89 % \findlength
90 % \setdashes
91 % \setdashesnear
92 % \setdashpattern
93 % \setdots
94 % \setdotsnear
95 % \setsolid
96 % \!dashingoff
97 % \!dashingon
98
99 % DIVISION: Does long division of dimension registers
100 % \Divide
101 % \!divide
102
103 % ELLIPSES: Draws ellipses and circles
104 % \circulararc
105 % \ellipticalarc
106
107 % RULES: Draws rules, i.e., horizontal & vertical lines
108 % \putrule
109 % \!putdashedhline
110 % \!putdashedvline
111 % \!puthline
112 % \!putsolidhline
113 % \!putsolidvline
114 % \!putvline
115
116 % LINEAR ARC: Draws straight lines -- solid and dashed
117 % \inboundscheckoff
118 % \inboundscheckon
119 % \!advancedashing
120 % \!drawlinearsegment
121 % \!initinboundscheck
122 % \!linearsolid
123 % \!lineardashed
124 % \!ljoin
125 % \!plotifinbounds
126 % \!start
127
128 % LOGTEN: Log_10 function
129 % \!logten
130
131 % PICTURES: Basic setups for PiCtures; \put commands
132 % \accountingoff
133 % \accountingon
134 % \beginpicture
135 % \endpicture
136 % \endpicturesave
137 % \lines
138 % \multiput
139 % \put
140 % \setcoordinatemode
141 % \setcoordinatesystem
142 % \setdimensionmode
143 % \stack
144 % \Lines
145 % \Xdistance
146 % \Ydistance
147 % \!dimenput
148 % \!ifcoordmode
149 % \!ifdimenmode
150 % \!setcoordmode
151 % \!setdimenmode
152 % \!setputobject
153
154 % PLOTTING: Things to do with plotting
155 % \dontsavelinesandcurves
156 % \replot
157 % \savelinesandcurves
158 % \setplotsymbol
159 % \writesavefile
160 % \!plot
161
162 % PYTHAGORAS: Euclidean distance function
163 % \placehypotenuse
164 % \!Pythag
165
166 % QUADRATIC ARC: Draws a quadratic arc
167 % \!qjoin
168
169 % ROTATIONS: Handles rotations
170 % \startrotation
171 % \stoprotation
172 % \!rotateaboutpivot
173 % \!rotateonly
174
175 % SHADING: Handles shading
176 % \setshadegrid
177 % \setshadesymbol
178 % \!lshade
179 % \!qshade
180 % \!starthshade
181 % \!startvshade
182
183 % TICKS: Draws ticks on graphs
184 % \gridlines
185 % \loggedticks
186 % \nogridlines
187 % \ticksin
188 % \ticksout
189 % \unloggesticks
190
191 % ***************** END OF TABLE OF GROUPS OF MACROS ********************
192
193
194 \catcode`!=11 % ***** THIS MUST NEVER BE OMITTED
195 % *******************************
196 % *** HACKS (Utility macros) ***
197 % *******************************
198
199 % ** User commands
200 % ** \PiC{P\kern-.12em\lower.5ex\hbox{I}\kern-.075emC}
201 % ** \PiCTeX{\PiC\kern-.11em\TeX}
202 % ** \placevalueinpts of <DIMENSION REGISTER> in {CONTROL SEQUENCE}
203
204 % ** Internal commands
205 % ** \!ifnextchar{CHARACTER}{TRUE ACTION}{FALSE ACTION}
206 % ** \!tfor NAME := LIST \do {BODY}
207 % ** \!etfor NAME:= LIST \do {BODY}
208 % ** \!cfor NAME := LIST \do {BODY}
209 % ** \!ecfor NAME:= LIST \do {BODY}
210 % ** \!ifempty{MACRO}{TRUE ACTION}{FALSE ACTION}
211 % ** \!getnext\\ITEMfrom\LIST
212 % ** \!getnextvalueof\DIMEN\from\LIST
213 % ** \!copylist\LISTMACRO_A\to\LISTMACRO_B
214 % ** \!wlet\CONTROL_SEQUENCE_A=\CONTROL_SEQUENCE_B
215 % ** \!listaddon ITEM LIST
216 % ** \!rightappendITEM\withCS\to\LISTMACRO
217 % ** \!leftappendITEM\withCS\to\LISTMACRO
218 % ** \!lop\LISTMACRO\to\ITEM
219 % ** \!loop ... repeat
220 % ** \!!loop ... repeat
221 % ** \!removept{DIMENSION REGISTER}{CONTROL SEQUENCE}
222 % ** \!mlap{...}
223 % ** \!vmlap{...}
224 % ** \!not{TEK if-CONDITION}
225
226 % ** First, here are the the PiCTeX logo, and the syllable PiC:
227 \def\PiC{P\kern-.12em\lower.5ex\hbox{I}\kern-.075emC}
228 \def\PiCTeX{\PiC\kern-.11em\TeX}
229
230 % ** The following macro expands to parameter #2 or parameter #3 according to
231 % ** whether the next non-blank character following the macro is or is not #1.
232 % ** Blanks following the macro are gobbled.
233 \def\!ifnextchar#1#2#3{%
234 \let\!testchar=#1%
235 \def\!first{#2}%
236 \def\!second{#3}%
237 \futurelet\!nextchar\!testnext}
238 \def\!testnext{%
239 \ifx \!nextchar \!spacetoken
240 \let\!next=\!skipspacetestagain
241 \else
242 \ifx \!nextchar \!testchar
243 \let\!next=\!first
244 \else
245 \let\!next=\!second
246 \fi
247 \fi
248 \!next}
249 \def\\{\!skipspacetestagain}
250 \expandafter\def\\ {\futurelet\!nextchar\!testnext}
251 \def\\{\let\!spacetoken= } \\ % ** set \spacetoken to a space token
252
253
254 % ** Borrow the "tfor" macro from Latex:
255 % ** \!tfor NAME := LIST \do {BODY}
256 % ** if, before expansion, LIST = T1 ... Tn, where each Ti is a token
257 % ** or {...}, then executes BODY n times, with NAME = Ti on the
258 % ** i-th iteration. Works for n=0.
259 \def\!tfor#1:=#2\do#3{%
260 \edef\!fortemp{#2}%
261 \ifx\!fortemp\!empty
262 \else
263 \!tforloop#2\!nil\!nil\!!#1{#3}%
264 \fi}
265 \def\!tforloop#1#2\!!#3#4{%
266 \def#3{#1}%
267 \ifx #3\!nnil
268 \let\!nextwhile=\!fornoop
269 \else
270 #4\relax
271 \let\!nextwhile=\!tforloop
272 \fi
273 \!nextwhile#2\!!#3{#4}}
274
275
276 % ** \!etfor NAME:= LIST\do {BODY}
277 % ** This is like \!cfor, but LIST is any balanced token list whose complete
278 % ** expansion has the form T1 ... Tn
279 \def\!etfor#1:=#2\do#3{%
280 \def\!!tfor{\!tfor#1:=}%
281 \edef\!!!tfor{#2}%
282 \expandafter\!!tfor\!!!tfor\do{#3}}
283
284
285 % ** modify the Latex \tfor (token-for) loop to a \cfor (comma-for) loop.
286 % ** \!cfor NAME := LIST \do {BODY}
287 % ** if, before expansion, LIST = a1,a2,...an, then executes BODY n times,
288 % ** with NAME = ai on the i-th iteration. Works for n=0.
289 \def\!cfor#1:=#2\do#3{%
290 \edef\!fortemp{#2}%
291 \ifx\!fortemp\!empty
292 \else
293 \!cforloop#2,\!nil,\!nil\!!#1{#3}%
294 \fi}
295 \def\!cforloop#1,#2\!!#3#4{%
296 \def#3{#1}%
297 \ifx #3\!nnil
298 \let\!nextwhile=\!fornoop
299 \else
300 #4\relax
301 \let\!nextwhile=\!cforloop
302 \fi
303 \!nextwhile#2\!!#3{#4}}
304
305
306 % ** \!ecfor NAME:= LIST\do {BODY}
307 % ** This is like \!cfor, but LIST is any balanced token list whose complete
308 % ** expansion has the form a1,a2,...,an.
309 \def\!ecfor#1:=#2\do#3{%
310 \def\!!cfor{\!cfor#1:=}%
311 \edef\!!!cfor{#2}%
312 \expandafter\!!cfor\!!!cfor\do{#3}}
313
314
315 \def\!empty{}
316 \def\!nnil{\!nil}
317 \def\!fornoop#1\!!#2#3{}
318
319
320 % ** \!ifempty{ARG}{TRUE ACTION}{FALSE ACTION}
321 \def\!ifempty#1#2#3{%
322 \edef\!emptyarg{#1}%
323 \ifx\!emptyarg\!empty
324 #2%
325 \else
326 #3%
327 \fi}
328
329 % ** \!getnext\\ITEMfrom\LIST
330 % ** \LIST has the form \\{item1}\\{item2}\\{item3}...\\{itemk}
331 % ** This routine sets \ITEM to item1, and cycles \LIST to
332 % ** \\{item2}\\{item3}...\\{itemk}\\{item1}
333 \def\!getnext#1\from#2{%
334 \expandafter\!gnext#2\!#1#2}%
335 \def\!gnext\\#1#2\!#3#4{%
336 \def#3{#1}%
337 \def#4{#2\\{#1}}%
338 \ignorespaces}
339
340
341 % ** \!getnextvalueof\DIMEN\from\LIST
342 % ** Similar to !getnext.
343 % ** \LIST has the form \\{dimen1}\\{dimen2}\\{dimen3} ...
344 % ** \DIMEN is a dimension register
345 % ** Works also for counts
346 %
347 \def\!getnextvalueof#1\from#2{%
348 \expandafter\!gnextv#2\!#1#2}%
349 \def\!gnextv\\#1#2\!#3#4{%
350 #3=#1%
351 \def#4{#2\\{#1}}%
352 \ignorespaces}
353
354
355 % ** \!copylist\LISTMACROA\to\LISTMACROB
356 % ** makes the replacement text of LISTMACRO B identical to that of
357 % ** list macro A.
358 \def\!copylist#1\to#2{%
359 \expandafter\!!copylist#1\!#2}
360 \def\!!copylist#1\!#2{%
361 \def#2{#1}\ignorespaces}
362
363
364 % ** \!wlet\CSA=\CSB
365 % ** lets control sequence \CSB = control sequence \CSA, and writes a
366 % ** message to that effect in the log file using plain TEK's \wlog
367 \def\!wlet#1=#2{%
368 \let#1=#2
369 \wlog{\string#1=\string#2}}
370
371 % ** \!listaddon ITEM LIST
372 % ** LIST <-- LIST \\ ITEM
373 \def\!listaddon#1#2{%
374 \expandafter\!!listaddon#2\!{#1}#2}
375 \def\!!listaddon#1\!#2#3{%
376 \def#3{#1\\#2}}
377
378 % ** \!rightappendITEM\to\LISTMACRO
379 % ** \LISTMACRO --> \LISTMACRO\\{ITEM}
380 %\def\!rightappend#1\to#2{\expandafter\!!rightappend#2\!{#1}#2}
381 %\def\!!rightappend#1\!#2#3{\def#3{#1\\{#2}}}
382
383
384 % ** \!rightappendITEM\withCS\to\LISTMACRO
385 % ** \LISTMACRO --> \LISTMACRO||CS||{ITEM}
386 \def\!rightappend#1\withCS#2\to#3{\expandafter\!!rightappend#3\!#2{#1}#3}
387 \def\!!rightappend#1\!#2#3#4{\def#4{#1#2{#3}}}
388
389
390 % ** \!leftappendITEM\withCS\to\LISTMACRO
391 % ** \LISTMACRO --> CS||{ITEM}||\LISTMACRO
392 \def\!leftappend#1\withCS#2\to#3{\expandafter\!!leftappend#3\!#2{#1}#3}
393 \def\!!leftappend#1\!#2#3#4{\def#4{#2{#3}#1}}
394
395
396 % ** \!lop\LISTMACRO\to\ITEM
397 % ** \\{item1}\\{item2}\\{item3} ... --> \\{item2}\\{item3} ...
398 % ** item1 --> \ITEM
399 \def\!lop#1\to#2{\expandafter\!!lop#1\!#1#2}
400 \def\!!lop\\#1#2\!#3#4{\def#4{#1}\def#3{#2}}
401
402
403 % ** \!placeNUMBER\of\LISTMACRO\in\ITEM
404 % ** the NUMBERth item of \LISTMACRO --> replacement text of \ITEM
405 %\def\!place#1\of#2\in#3{\def#3{\outofrange}%
406 %{\count0=#1\def\\##1{\advance\count0-1 \ifnum\count0=0 \gdef#3{##1}\fi}#2}}
407
408
409 % ** Following code converts a commalist to a list macro, with all items
410 % ** fully expanded.
411 %\!ecfor\item:=\commalist\do{\expandafter\!rightappend\item\to\list}
412
413
414 % ** \!loop ... repeat
415 % ** This is exactly like TEX's \loop ... repeat. It can be used in nesting
416 % ** two loops, without puting the inner one inside a group.
417 \def\!loop#1\repeat{\def\!body{#1}\!iterate}
418 \def\!iterate{\!body\let\!next=\!iterate\else\let\!next=\relax\fi\!next}
419
420 % ** \!!loop ... repeat
421 % ** This is exactly like TEX's \loop ... repeat. It can be used in nesting
422 % ** two loops, without puting the inner one inside a group.
423 \def\!!loop#1\repeat{\def\!!body{#1}\!!iterate}
424 \def\!!iterate{\!!body\let\!!next=\!!iterate\else\let\!!next=\relax\fi\!!next}
425 % (\multiput uses \!!loop)
426
427 % ** \!removept{DIMENREG}{\CS}
428 % ** Defines the control sequence CS to be the value (in points) in the
429 % ** dimension register DIMENREG (but without the "pt" TEK usually adds)
430 % ** E.g., after \dimen0=12.3pt \!removept\dimen0\A, \A expands to 12.3
431 \def\!removept#1#2{\edef#2{\expandafter\!!removePT\the#1}}
432 {\catcode`p=12 \catcode`t=12 \gdef\!!removePT#1pt{#1}}
433
434 % ** \pladevalueinpts of <DIMENSION REGISTER> in {CONTROL SEQUENCE}
435 \def\placevalueinpts of <#1> in #2 {%
436 \!removept{#1}{#2}}
437
438 % ** \!mlap{...} \!vmlap{...}
439 % ** Center ... in a box of width 0.
440 \def\!mlap#1{\hbox to 0pt{\hss#1\hss}}
441 \def\!vmlap#1{\vbox to 0pt{\vss#1\vss}}
442
443 % ** \!not{TEK if-CONDITION}
444 % ** By a TEK if-CONDITION is meant something like
445 % ** \ifnum\N<0, or \ifdim\A>\B
446 % ** \!not produces an if-condition which is false if the original condition
447 % ** is true, and true if the original condition is false.
448 \def\!not#1{%
449 #1\relax
450 \!switchfalse
451 \else
452 \!switchtrue
453 \fi
454 \if!switch
455 \ignorespaces}
456
457
458 % *******************
459 % *** ALLOCATIONS ***
460 % *******************
461
462 % This section allocates all the registers PiCTeX uses. Following
463 % each allocation is a string of the form ....N.D...L......... ;
464 % the various letters show which sections of PiCTeX make explicit
465 % reference to that register, according to the following code:
466
467 % H Hacks
468 % A Areas
469 % W arroWs
470 % B Bars
471 % X boXes
472 % C Curves
473 % D Dashpattterns
474 % V diVision
475 % E Ellipses
476 % U rUles
477 % L Linear arc
478 % G loGten
479 % P Pictures
480 % O plOtting
481 % Y pYthagoras
482 % Q Quadratic arc
483 % R Rotations
484 % S Shading
485 % T Ticks
486
487 % Turn off messages from TeX's allocation macros
488 \let\!!!wlog=\wlog % "\wlog" is defined in plain TeX
489 \def\wlog#1{}
490
491 \newskip\headingtoplotskip %.A................. %-as-%
492 \newskip\linethickness %.A..X....U........T
493 \newskip\longticklength %.A................T %-as-%
494 \newskip\plotsymbolspacing %......D...L....Q...
495 \newskip\shortticklength %.A................T %-as-%
496 \newskip\stackleading %.A..........P...... %-as-%
497 \newskip\tickstovaluesleading %.A................T %-as-%
498 \newskip\totalarclength %......D...L....Q...
499 \newskip\valuestolabelleading %.A................. %-as-%
500
501 \newbox\!boxA %.AW...............T
502 \newbox\!boxB %..W................
503 \newbox\!picbox %............P......
504 \newbox\!plotsymbol %..........L..O.....
505 \newbox\!putobject %............PO...S.
506 \newbox\!shadesymbol %.................S.
507
508 \newcount\!countA %.A....D..UL....Q.ST
509 \newcount\!countB %......D..U.....Q.ST
510 \newcount\!countC %...............Q..T
511 \newcount\!countD %...................
512 \newcount\!countE %.............O....T
513 \newcount\!countF %.............O....T
514 \newcount\!countG %..................T
515 \newcount\!fiftypt %.........U.........
516 \newcount\!intervalno %..........L....Q...
517 \newcount\!npoints %..........L........
518 \newcount\!nsegments %.........U.........
519 \newcount\!ntemp %............P......
520 \newcount\!parity %.................S.
521 \newcount\!scalefactor %..................T
522 \newcount\!tickcase %..................T
523
524 \newskip\!Xleft %............P......
525 \newskip\!Xright %............P......
526 \newskip\!Xsave %.A................T
527 \newskip\!Ybot %............P......
528 \newskip\!Ysave %.A................T
529 \newskip\!Ytop %............P......
530 \newskip\!angle %........E..........
531 \newskip\!arclength %..W......UL....Q...
532 \newskip\!areabloc %.A........L........
533 \newskip\!arealloc %.A........L........
534 \newskip\!arearloc %.A........L........
535 \newskip\!areatloc %.A........L........
536 \newskip\!bshrinkage %.................S.
537 \newskip\!checkbot %..........L........
538 \newskip\!checkleft %..........L........
539 \newskip\!checkright %..........L........
540 \newskip\!checktop %..........L........
541 \newdimen\!dimenA %.AW.X.DVEUL..OYQRST
542 \newdimen\!dimenB %....X.DVEU...O.QRS.
543 \newdimen\!dimenC %..W.X.DVEU......RS.
544 \newdimen\!dimenD %..W.X.DVEU....Y.RS.
545 \newdimen\!dimenE %..W........G..YQ.S.
546 \newdimen\!dimenF %...........G..YQ.S.
547 \newdimen\!dimenG %...........G..YQ.S.
548 \newdimen\!dimenH %...........G..Y..S.
549 \newdimen\!dimenI %...BX.........Y....
550 \newdimen\!distacross %..........L....Q...
551 \newdimen\!downlength %..........L........
552 \newdimen\!dp %.A..X.......P....S.
553 \newdimen\!dshade %.................S.
554 \newdimen\!dxpos %..W......U..P....S.
555 \newdimen\!dxprime %...............Q...
556 \newdimen\!dypos %..WB.....U..P......
557 \newdimen\!dyprime %...............Q...
558 \newdimen\!ht %.A..X.......P....S.
559 \newdimen\!leaderlength %......D..U.........
560 \newdimen\!lshrinkage %.................S.
561 \newdimen\!midarclength %...............Q...
562 \newdimen\!offset %.A................T
563 \newdimen\!plotheadingoffset %.A.................
564 \newdimen\!plotsymbolxshift %..........L..O.....
565 \newdimen\!plotsymbolyshift %..........L..O.....
566 \newdimen\!plotxorigin %..........L..O.....
567 \newdimen\!plotyorigin %..........L..O.....
568 \newdimen\!rshrinkage %.................S.
569 \newdimen\!shadesymbolxshift %.................S.
570 \newdimen\!shadesymbolyshift %.................S.
571 \newdimen\!tshrinkage %.................S.
572 \newdimen\!uplength %..........L........
573 \newdimen\!wd %....X.......P....S.
574 \newdimen\!xB %...............Q...
575 \newdimen\!xC %...............Q...
576 \newdimen\!xE %..W.....E.L....Q.S.
577 \newdimen\!xM %..W.....E......Q.S.
578 \newdimen\!xS %..W.....E.L....Q.S.
579 \newdimen\!xaxislength %.A................T
580 \newdimen\!xdiff %..........L........
581 \newdimen\!xleft %............P......
582 \newdimen\!xloc %..WB.....U.......S.
583 \newdimen\!xorigin %.A........L.P....S.
584 \newdimen\!xpivot %................R..
585 \newdimen\!xpos %..........L.P..Q.ST
586 \newdimen\!xprime %...............Q...
587 \newdimen\!xright %............P......
588 \newdimen\!xshade %.................S.
589 \newdimen\!xshift %..W.........PO...S.
590 \newdimen\!xtemp %............P......
591 \newdimen\!xunit %.AWBX...EUL.P..QRS.
592 \newdimen\!xxE %........E..........
593 \newdimen\!xxM %........E..........
594 \newdimen\!xxS %........E..........
595 \newdimen\!xxloc %..WB....EU.........
596 \newdimen\!yB %...............Q...
597 \newdimen\!yC %...............Q...
598 \newdimen\!yE %..W.....E.L....Q...
599 \newdimen\!yM %..W.....E......Q...
600 \newdimen\!yS %..W.....E.L....Q...
601 \newdimen\!yaxislength %.A................T
602 \newdimen\!ybot %............P......
603 \newdimen\!ydiff %..........L........
604 \newdimen\!yloc %..WB.....U.......S.
605 \newdimen\!yorigin %.A........L.P....S.
606 \newdimen\!ypivot %................R..
607 \newdimen\!ypos %..........L.P..Q.ST
608 \newdimen\!yprime %...............Q...
609 \newdimen\!yshade %.................S.
610 \newdimen\!yshift %..W.........PO...S.
611 \newdimen\!ytemp %............P......
612 \newdimen\!ytop %............P......
613 \newdimen\!yunit %.AWBX...EUL.P..QRS.
614 \newdimen\!yyE %........E..........
615 \newdimen\!yyM %........E..........
616 \newdimen\!yyS %........E..........
617 \newdimen\!yyloc %..WB....EU.........
618
619 \newif\if!axisvisible %.A.................
620 \newif\if!gridlinestoo %..................T
621 \newif\if!keepPO %...................
622 \newif\if!placeaxislabel %.A.................
623 \newif\if!switch %H..................
624 \newif\if!xswitch %.A................T
625
626 \newtoks\!axisLaBeL %.A.................
627 \newtoks\!keywordtoks %.A.................
628
629 \newwrite\!replotfile %.............O.....
630
631 \newhelp\!keywordhelp{The keyword mentioned in the error message in unknown.
632 Replace NEW KEYWORD in the indicated response by the keyword that
633 should have been specified.} %.A.................
634
635 % The following commands assign alternate names to some of the
636 % above registers. "\!wlet" is defined in Hacks.
637 \!wlet\!!origin=\!xM %.A................T
638 \!wlet\!!unit=\!uplength %.A................T
639 \!wlet\!Lresiduallength=\!dimenG %.........U.........
640 \!wlet\!Rresiduallength=\!dimenF %.........U.........
641 \!wlet\!axisLength=\!distacross %.A................T
642 \!wlet\!axisend=\!ydiff %.A................T
643 \!wlet\!axisstart=\!xdiff %.A................T
644 \!wlet\!axisxlevel=\!arclength %.A................T
645 \!wlet\!axisylevel=\!downlength %.A................T
646 \!wlet\!beta=\!dimenE %...............Q...
647 \!wlet\!gamma=\!dimenF %...............Q...
648 \!wlet\!shadexorigin=\!plotxorigin %.................S.
649 \!wlet\!shadeyorigin=\!plotyorigin %.................S.
650 \!wlet\!ticklength=\!xS %..................T
651 \!wlet\!ticklocation=\!xE %..................T
652 \!wlet\!ticklocationincr=\!yE %..................T
653 \!wlet\!tickwidth=\!yS %..................T
654 \!wlet\!totalleaderlength=\!dimenE %.........U.........
655 \!wlet\!xone=\!xprime %....X..............
656 \!wlet\!xtwo=\!dxprime %....X..............
657 \!wlet\!ySsave=\!yM %...................
658 \!wlet\!ybB=\!yB %.................S.
659 \!wlet\!ybC=\!yC %.................S.
660 \!wlet\!ybE=\!yE %.................S.
661 \!wlet\!ybM=\!yM %.................S.
662 \!wlet\!ybS=\!yS %.................S.
663 \!wlet\!ybpos=\!yyloc %.................S.
664 \!wlet\!yone=\!yprime %....X..............
665 \!wlet\!ytB=\!xB %.................S.
666 \!wlet\!ytC=\!xC %.................S.
667 \!wlet\!ytE=\!downlength %.................S.
668 \!wlet\!ytM=\!arclength %.................S.
669 \!wlet\!ytS=\!distacross %.................S.
670 \!wlet\!ytpos=\!xxloc %.................S.
671 \!wlet\!ytwo=\!dyprime %....X..............
672
673
674 % Initial values for registers
675 \def\!zpt{0pt} % static
676 \!xunit=1pt
677 \!yunit=1pt
678 \!arearloc=\!xunit
679 \!areatloc=\!yunit
680 \!dshade=5pt
681 \!leaderlength=24in
682 \def\!tfs{256} % static
683 \def\!wmax{5.3pt} % static
684 \def\!wmin{2.7pt} % static
685 \!xaxislength=\!xunit
686 \!xpivot=\!zpt
687 \!yaxislength=\!yunit
688 \!ypivot=\!zpt
689 \plotsymbolspacing=.4pt
690 \!dimenA=50pt \def\!fiftypt{\the\!dimenA} % static
691
692 \def\!rootten{3.162278pt} % static
693 \def\!tenAa{8.690286pt} % static (A5)
694 \def\!tenAc{2.773839pt} % static (A3)
695 \def\!tenAe{2.543275pt} % static (A1)
696
697 % Initial values for control sequences
698 \def\!cosrotationangle{1} %................R..
699 \def\!sinrotationangle{0} %................R..
700 \def\!xpivotcoord{0} %................R..
701 \def\!xref{0} %............P......
702 \def\!xshadesave{0} %.................S.
703 \def\!ypivotcoord{0} %................R..
704 \def\!yref{0} %............P......
705 \def\!yshadesave{0} %.................S.
706 \def\!zero{0} %..................T
707
708 % Reset TeX to report allocations
709 \let\wlog=\!!!wlog
710 % *************************************
711 % *** AREAS: Deals with plot areas ***
712 % *************************************
713 %
714 % ** User commands
715 % ** \setplotarea x from LEFT XCOORD to RIGTH XCOORD, y from BOTTOM YCOORD
716 % ** to TOP YCOORD
717 % ** \axis BOTTOM-LEFT-TOP-RIGHT [SHIFTEDTO xy=COORD] [VISIBLE-INVISIBLE]
718 % ** [LABEL {label}] [TICKS] /
719 % ** \visibleaxes
720 % ** \invisibleaxes
721 % ** \plotheading {HEADING}
722 % ** \grid {# of columns} {# of rows}
723 % ** \normalgraphs
724
725 % ** \normalgraphs
726 % ** Sets defaults for graph setup. See Subsection 3.4 of manual.
727 \def\normalgraphs{%
728 \longticklength=.4\baselineskip
729 \shortticklength=.25\baselineskip
730 \tickstovaluesleading=.25\baselineskip
731 \valuestolabelleading=.8\baselineskip
732 \linethickness=.4pt
733 \stackleading=.17\baselineskip
734 \headingtoplotskip=1.5\baselineskip
735 \visibleaxes
736 \ticksout
737 \nogridlines
738 \unloggedticks}
739 %
740 % ** \setplotarea x from LEFT XCOORD to RIGTH XCOORD, y from BOTTOM YCOORD
741 % ** to TOP YCOORD
742 % ** Reserves space in PICBOX for a rectangular box with the indicated
743 % ** coordinates. Must be specified before calls to \axis,
744 % ** \grid, \plotheading.
745 % ** See Subsection 3.1 of the manual.
746 \def\setplotarea x from #1 to #2, y from #3 to #4 {%
747 \!arealloc=\!M{#1}\!xunit \advance \!arealloc -\!xorigin
748 \!areabloc=\!M{#3}\!yunit \advance \!areabloc -\!yorigin
749 \!arearloc=\!M{#2}\!xunit \advance \!arearloc -\!xorigin
750 \!areatloc=\!M{#4}\!yunit \advance \!areatloc -\!yorigin
751 \!initinboundscheck
752 \!xaxislength=\!arearloc \advance\!xaxislength -\!arealloc
753 \!yaxislength=\!areatloc \advance\!yaxislength -\!areabloc
754 \!plotheadingoffset=\!zpt
755 \!dimenput {{\setbox0=\hbox{}\wd0=\!xaxislength\ht0=\!yaxislength\box0}}
756 [bl] (\!arealloc,\!areabloc)}
757 %
758 % ** \visibleaxes, \invisibleaxes
759 % ** Switches for setting visibility of subsequent axes.
760 % ** See Subsection 3.2 of the manual.
761 \def\visibleaxes{%
762 \def\!axisvisibility{\!axisvisibletrue}}
763 \def\invisibleaxes{%
764 \def\!axisvisibility{\!axisvisiblefalse}}
765 %
766 % ** The next few macros enable the user to fix up an erroneous keyword
767 % ** in the \axis command.
768 % \newhelp is in ALLOCATIONS
769 % \newhelp\!keywordhelp{The keyword mentioned in the error message in unknown.
770 % Replace NEW KEYWORD in the indicated response by the keyword that
771 % should have been specified.}
772
773 \def\!fixkeyword#1{%
774 \errhelp=\!keywordhelp
775 \errmessage{Unrecognized keyword `#1': \the\!keywordtoks{NEW KEYWORD}'}}
776
777 % \newtoks\!keywordtoks In ALLOCATIONS.
778 \!keywordtoks={enter `i\fixkeyword}
779
780 \def\fixkeyword#1{%
781 \!nextkeyword#1 }
782
783 % ** \axis BOTTOM-LEFT-TOP-RIGHT [SHIFTEDTO xy=COORD] [VISIBLE-INVISIBLE]
784 % ** [LABEL {label}] [TICKS] /
785 % ** Exactly one of the keywords BOTTOM, LEFT, TOP, RIGHT must be
786 % ** specified. Axis is drawn along the indicated edge of the current
787 % ** plot area, shifted if the SHIFTEDTO option is used, visible or
788 % ** invisible according the selected option, with an optional LABEL,
789 % ** and optional TICKS (see ticks.tex for the options avialabel with
790 % ** TICKS). The TICKS option must be the last one specified. The \axis
791 % ** MUST be terminated with a / followed by a space.
792 % ** See Subsection 3.2 of the manual for more information.
793
794 % ** The various options of the \axis command are processed by the
795 % ** \!nextkeyword macro defined below. For example,
796 % ** `\!nextkeyword shiftedto ' expands to `\!axisshiftedto'.
797 \def\axis {%
798 \def\!nextkeyword##1 {%
799 \expandafter\ifx\csname !axis##1\endcsname \relax
800 \def\!next{\!fixkeyword{##1}}%
801 \else
802 \def\!next{\csname !axis##1\endcsname}%
803 \fi
804 \!next}%
805 \!offset=\!zpt
806 \!axisvisibility
807 \!placeaxislabelfalse
808 \!nextkeyword}
809
810 % ** This and the various macros that follow handle the keyword
811 % ** specifications on the \axis command
812 % ** See Subsection 3.2 of the manual.
813 \def\!axisbottom{%
814 \!axisylevel=\!areabloc
815 \def\!tickxsign{0}%
816 \def\!tickysign{-}%
817 \def\!axissetup{\!axisxsetup}%
818 \def\!axislabeltbrl{t}%
819 \!nextkeyword}
820
821 \def\!axistop{%
822 \!axisylevel=\!areatloc
823 \def\!tickxsign{0}%
824 \def\!tickysign{+}%
825 \def\!axissetup{\!axisxsetup}%
826 \def\!axislabeltbrl{b}%
827 \!nextkeyword}
828
829 \def\!axisleft{%
830 \!axisxlevel=\!arealloc
831 \def\!tickxsign{-}%
832 \def\!tickysign{0}%
833 \def\!axissetup{\!axisysetup}%
834 \def\!axislabeltbrl{r}%
835 \!nextkeyword}
836
837 \def\!axisright{%
838 \!axisxlevel=\!arearloc
839 \def\!tickxsign{+}%
840 \def\!tickysign{0}%
841 \def\!axissetup{\!axisysetup}%
842 \def\!axislabeltbrl{l}%
843 \!nextkeyword}
844
845 \def\!axisshiftedto#1=#2 {%
846 \if 0\!tickxsign
847 \!axisylevel=\!M{#2}\!yunit
848 \advance\!axisylevel -\!yorigin
849 \else
850 \!axisxlevel=\!M{#2}\!xunit
851 \advance\!axisxlevel -\!xorigin
852 \fi
853 \!nextkeyword}
854
855 \def\!axisvisible{%
856 \!axisvisibletrue
857 \!nextkeyword}
858
859 \def\!axisinvisible{%
860 \!axisvisiblefalse
861 \!nextkeyword}
862
863 \def\!axislabel#1 {%
864 \!axisLaBeL={#1}%
865 \!placeaxislabeltrue
866 \!nextkeyword}
867
868 \expandafter\def\csname !axis/\endcsname{%
869 \!axissetup % This could done already by "ticks"; if so, now \relax
870 \if!placeaxislabel
871 \!placeaxislabel
872 \fi
873 \if +\!tickysign % ** (A "top" axis)
874 \!dimenA=\!axisylevel
875 \advance\!dimenA \!offset % ** dimA = top of the axis structure
876 \advance\!dimenA -\!areatloc % ** dimA = excess over the plot area
877 \ifdim \!dimenA>\!plotheadingoffset
878 \!plotheadingoffset=\!dimenA % ** Greatest excess over the plot area
879 \fi
880 \fi}
881
882 % ** \grid {c} {r}
883 % ** Partitions the plot area into c columns and r rows; see Subsection 3.3
884 % ** of the manual.
885 % ** (Other grid patterns can be drawn with the TICKS option of the \axis
886 % ** command.
887 \def\grid #1 #2 {%
888 \!countA=#1\advance\!countA 1
889 \axis bottom invisible ticks length <\!zpt> andacross quantity {\!countA} /
890 \!countA=#2\advance\!countA 1
891 \axis left invisible ticks length <\!zpt> andacross quantity {\!countA} / }
892
893 % ** \plotheading{HEADING}
894 % ** Places HEADING centered above the top of the plotarea (and above
895 % ** any top axis ticks marks, tick labels, and axis label); see
896 % ** Subsection 3.3 of the manual.
897 \def\plotheading#1 {%
898 \advance\!plotheadingoffset \headingtoplotskip
899 \!dimenput {#1} [B] <.5\!xaxislength,\!plotheadingoffset>
900 (\!arealloc,\!areatloc)}
901
902 % ** From here on, the routines are internal.
903 \def\!axisxsetup{%
904 \!axisxlevel=\!arealloc
905 \!axisstart=\!arealloc
906 \!axisend=\!arearloc
907 \!axisLength=\!xaxislength
908 \!!origin=\!xorigin
909 \!!unit=\!xunit
910 \!xswitchtrue
911 \if!axisvisible
912 \!makeaxis
913 \fi}
914
915 \def\!axisysetup{%
916 \!axisylevel=\!areabloc
917 \!axisstart=\!areabloc
918 \!axisend=\!areatloc
919 \!axisLength=\!yaxislength
920 \!!origin=\!yorigin
921 \!!unit=\!yunit
922 \!xswitchfalse
923 \if!axisvisible
924 \!makeaxis
925 \fi}
926
927 \def\!makeaxis{%
928 \setbox\!boxA=\hbox{% (Make a pseudo-y[x] tick for an x[y]-axis)
929 \beginpicture
930 \!setdimenmode
931 \setcoordinatesystem point at {\!zpt} {\!zpt}
932 \putrule from {\!zpt} {\!zpt} to
933 {\!tickysign\!tickysign\!axisLength}
934 {\!tickxsign\!tickxsign\!axisLength}
935 \endpicturesave <\!Xsave,\!Ysave>}%
936 \wd\!boxA=\!zpt
937 \!placetick\!axisstart}
938
939 \def\!placeaxislabel{%
940 \advance\!offset \valuestolabelleading
941 \if!xswitch
942 \!dimenput {\the\!axisLaBeL} [\!axislabeltbrl]
943 <.5\!axisLength,\!tickysign\!offset> (\!axisxlevel,\!axisylevel)
944 \advance\!offset \!dp % ** advance offset by the "tallness"
945 \advance\!offset \!ht % ** of the label
946 \else
947 \!dimenput {\the\!axisLaBeL} [\!axislabeltbrl]
948 <\!tickxsign\!offset,.5\!axisLength> (\!axisxlevel,\!axisylevel)
949 \fi
950 \!axisLaBeL={}}
951
952
953 % *******************************
954 % *** ARROWS (Draws arrows) ***
955 % *******************************
956 %
957 % ** User commands
958 % ** \arrow <ARROW HEAD LENGTH> [MID FRACTION, BASE FRACTION]
959 % ** [<XSHIFT,YSHIFT>] from XFROM YFROM to XTO YTO
960 % ** \betweenarrows {TEXT} [orientation & shift] from XFROM YFROM to XTO YTO
961
962 % ** \arrow <ARROW HEAD LENGTH> [MID FRACTION, BASE FRACTION]
963 % ** [<XSHIFT,YSHIFT>] from XFROM YFROM to XTO YTO
964 % ** Draws an arrow from (XFROM,YFROM) to (XTO,YTO). The arrow head
965 % ** is constructed two quadratic arcs, which extend back a distance
966 % ** ARROW HEAD LENGTH (a dimension) on both sides of the arrow shaft.
967 % ** All the way back the arcs are a distance BASE FRACTION*ARROW HEAD
968 % ** LENGTH apart, while half-way back they are a distance MID FRACTION*
969 % ** ARROW HEAD LENGTH apart. <XSHIFT,YSHIFT> is optional, and has
970 % ** its usual interpreation. See Subsection 5.4 of the manual.
971
972 \def\arrow <#1> [#2,#3]{%
973 \!ifnextchar<{\!arrow{#1}{#2}{#3}}{\!arrow{#1}{#2}{#3}<\!zpt,\!zpt> }}
974
975 \def\!arrow#1#2#3<#4,#5> from #6 #7 to #8 #9 {%
976 %
977 % ** convert to dimensions
978 \!xloc=\!M{#8}\!xunit
979 \!yloc=\!M{#9}\!yunit
980 \!dxpos=\!xloc \!dimenA=\!M{#6}\!xunit \advance \!dxpos -\!dimenA
981 \!dypos=\!yloc \!dimenA=\!M{#7}\!yunit \advance \!dypos -\!dimenA
982 \let\!MAH=\!M% ** save current c/d mode
983 \!setdimenmode% ** go into dimension mode
984 %
985 \!xshift=#4\relax \!yshift=#5\relax% ** pick up shift
986 \!reverserotateonly\!xshift\!yshift% ** back rotate shift
987 \advance\!xshift\!xloc \advance\!yshift\!yloc
988 %
989 % ** draw shaft of arrow
990 \!xS=-\!dxpos \advance\!xS\!xshift
991 \!yS=-\!dypos \advance\!yS\!yshift
992 \!start (\!xS,\!yS)
993 \!ljoin (\!xshift,\!yshift)
994 %
995 % ** find 32*cosine and 32*sine of angle of rotation
996 \!Pythag\!dxpos\!dypos\!arclength
997 \!divide\!dxpos\!arclength\!dxpos
998 \!dxpos=32\!dxpos \!removept\!dxpos\!!cos
999 \!divide\!dypos\!arclength\!dypos
1000 \!dypos=32\!dypos \!removept\!dypos\!!sin
1001 %
1002 % ** construct arrowhead
1003 \!halfhead{#1}{#2}{#3}% ** draw half of arrow head
1004 \!halfhead{#1}{-#2}{-#3}% ** draw other half
1005 %
1006 \let\!M=\!MAH% ** restore old c/d mode
1007 \ignorespaces}
1008 %
1009 % ** draw half of arrow head
1010 \def\!halfhead#1#2#3{%
1011 \!dimenC=-#1%
1012 \divide \!dimenC 2 % ** half way back
1013 \!dimenD=#2\!dimenC% ** half the mid width
1014 \!rotate(\!dimenC,\!dimenD)by(\!!cos,\!!sin)to(\!xM,\!yM)
1015 \!dimenC=-#1% ** all the way back
1016 \!dimenD=#3\!dimenC
1017 \!dimenD=.5\!dimenD% ** half the full width
1018 \!rotate(\!dimenC,\!dimenD)by(\!!cos,\!!sin)to(\!xE,\!yE)
1019 \!start (\!xshift,\!yshift)
1020 \advance\!xM\!xshift \advance\!yM\!yshift
1021 \advance\!xE\!xshift \advance\!yE\!yshift
1022 \!qjoin (\!xM,\!yM) (\!xE,\!yE)
1023 \ignorespaces}
1024
1025
1026 % ** \betweenarrows {TEXT} [orientation & shift] from XFROM YFROM to XTO YTO
1027 % ** Makes things like <--- text --->, using arrow heads from TeX's fonts.
1028 % ** See Subsection 5.4 of the manual.
1029 \def\betweenarrows #1#2 from #3 #4 to #5 #6 {%
1030 \!xloc=\!M{#3}\!xunit \!xxloc=\!M{#5}\!xunit%
1031 \!yloc=\!M{#4}\!yunit \!yyloc=\!M{#6}\!yunit%
1032 \!dxpos=\!xxloc \advance\!dxpos by -\!xloc
1033 \!dypos=\!yyloc \advance\!dypos by -\!yloc
1034 \advance\!xloc .5\!dxpos
1035 \advance\!yloc .5\!dypos
1036 %
1037 \let\!MBA=\!M% ** save current coord\dimen mode
1038 \!setdimenmode% ** express locations in dimens
1039 \ifdim\!dypos=\!zpt
1040 \ifdim\!dxpos<\!zpt \!dxpos=-\!dxpos \fi
1041 \put {\!lrarrows{\!dxpos}{#1}}#2{} at {\!xloc} {\!yloc}
1042 \else
1043 \ifdim\!dxpos=\!zpt
1044 \ifdim\!dypos<\!zpt \!dypos=-\!zpt \fi
1045 \put {\!udarrows{\!dypos}{#1}}#2{} at {\!xloc} {\!yloc}
1046 \fi
1047 \fi
1048 \let\!M=\!MBA% ** restore previous c/d mode
1049 \ignorespaces}
1050
1051 % ** Subroutine for left-right between arrows
1052 \def\!lrarrows#1#2{% #1=width, #2=text
1053 {\setbox\!boxA=\hbox{$\mkern-2mu\mathord-\mkern-2mu$}%
1054 \setbox\!boxB=\hbox{$\leftarrow$}\!dimenE=\ht\!boxB
1055 \setbox\!boxB=\hbox{}\ht\!boxB=2\!dimenE
1056 \hbox to #1{$\mathord\leftarrow\mkern-6mu
1057 \cleaders\copy\!boxA\hfil
1058 \mkern-6mu\mathord-$%
1059 \kern.4em $\vcenter{\box\!boxB}$$\vcenter{\hbox{#2}}$\kern.4em
1060 $\mathord-\mkern-6mu
1061 \cleaders\copy\!boxA\hfil
1062 \mkern-6mu\mathord\rightarrow$}}}
1063
1064 % ** Subroutine for up-down between arrows
1065 \def\!udarrows#1#2{% #1=width, #2=text
1066 {\setbox\!boxB=\hbox{#2}%
1067 \setbox\!boxA=\hbox to \wd\!boxB{\hss$\vert$\hss}%
1068 \!dimenE=\ht\!boxA \advance\!dimenE \dp\!boxA \divide\!dimenE 2
1069 \vbox to #1{\offinterlineskip
1070 \vskip .05556\!dimenE
1071 \hbox to \wd\!boxB{\hss$\mkern.4mu\uparrow$\hss}\vskip-\!dimenE
1072 \cleaders\copy\!boxA\vfil
1073 \vskip-\!dimenE\copy\!boxA
1074 \vskip\!dimenE\copy\!boxB\vskip.4em
1075 \copy\!boxA\vskip-\!dimenE
1076 \cleaders\copy\!boxA\vfil
1077 \vskip-\!dimenE \hbox to \wd\!boxB{\hss$\mkern.4mu\downarrow$\hss}
1078 \vskip .05556\!dimenE}}}
1079
1080
1081 % ***************************
1082 % *** BARS (Draws bars) ***
1083 % ***************************
1084 %
1085 % ** User commands:
1086 % ** \putbar [<XSHIFT,YSHIFT>] breadth <BREADTH> from XSTART YSTART
1087 % ** to XEND YEND
1088 % ** \setbars [<XSHIFT,YSHIFT>] breadth <BREADTH> baseline at XY = COORD
1089 % ** [baselabels ([B_ORIENTATION_x,B_ORIENTATION_y] <B_XSHIFT,B_YSHIFT>)]
1090 % ** [endlabels ([E_ORIENTATION_x,E_ORIENTATION_y] <E_XSHIFT,E_YSHIFT>)]
1091
1092
1093 % ** \putbar [<XSHIFT,YSHIFT>] breadth <BREADTH> from XSTART YSTART
1094 % ** to XEND YEND
1095 % ** Either XSTART=XEND or YSTART=YEND. Draws a rectangle between
1096 % ** (XSTART,YSTART) & (XEND,YEND). The "depth" of the rectangle
1097 % ** is determined by those two plot positions; its other
1098 % ** dimension "breadth" is specified by the dimension BREADTH.
1099 % ** See Subsection 4.2 of the manual.
1100 \def\putbar#1breadth <#2> from #3 #4 to #5 #6 {%
1101 \!xloc=\!M{#3}\!xunit \!xxloc=\!M{#5}\!xunit%
1102 \!yloc=\!M{#4}\!yunit \!yyloc=\!M{#6}\!yunit%
1103 \!dypos=\!yyloc \advance\!dypos by -\!yloc
1104 \!dimenI=#2
1105 %
1106 \ifdim \!dimenI=\!zpt % ** If 0 breadth
1107 \putrule#1from {#3} {#4} to {#5} {#6} % ** Then draw line
1108 \else % ** Else, put in a rectangle
1109 \let\!MBar=\!M% ** save current c/d mode
1110 \!setdimenmode % ** go into dimension mode
1111 \divide\!dimenI 2
1112 \ifdim \!dypos=\!zpt
1113 \advance \!yloc -\!dimenI % ** Equal y coordinates
1114 \advance \!yyloc \!dimenI
1115 \else
1116 \advance \!xloc -\!dimenI % ** Equal x coordinates
1117 \advance \!xxloc \!dimenI
1118 \fi
1119 \putrectangle#1corners at {\!xloc} {\!yloc} and {\!xxloc} {\!yyloc}
1120 \let\!M=\!MBar % ** restore c/d mode
1121 \fi
1122 \ignorespaces}
1123
1124
1125 % ** \setbars [<XSHIFT,YSHIFT>] breadth <BREADTH> baseline at XY = COORD
1126 % ** [baselabels ([B_ORIENTATION_x,B_ORIENTATION_y] <B_XSHIFT,B_YSHIFT>)]
1127 % ** [endlabels ([E_ORIENTATION_x,E_ORIENTATION_y] <E_XSHIFT,E_YSHIFT>)]
1128 % ** This command puts PiCTeX into the bar graph drawing mode described
1129 % ** in Subsection 4.4 of the manual.
1130 \def\setbars#1breadth <#2> baseline at #3 = #4 {%
1131 \edef\!barshift{#1}%
1132 \edef\!barbreadth{#2}%
1133 \edef\!barorientation{#3}%
1134 \edef\!barbaseline{#4}%
1135 \def\!bardobaselabel{\!bardoendlabel}%
1136 \def\!bardoendlabel{\!barfinish}%
1137 \let\!drawcurve=\!barcurve
1138 \!setbars}
1139 \def\!setbars{%
1140 \futurelet\!nextchar\!!setbars}
1141 \def\!!setbars{%
1142 \if b\!nextchar
1143 \def\!!!setbars{\!setbarsbget}%
1144 \else
1145 \if e\!nextchar
1146 \def\!!!setbars{\!setbarseget}%
1147 \else
1148 \def\!!!setbars{\relax}%
1149 \fi
1150 \fi
1151 \!!!setbars}
1152 \def\!setbarsbget baselabels (#1) {%
1153 \def\!barbaselabelorientation{#1}%
1154 \def\!bardobaselabel{\!!bardobaselabel}%
1155 \!setbars}
1156 \def\!setbarseget endlabels (#1) {%
1157 \edef\!barendlabelorientation{#1}%
1158 \def\!bardoendlabel{\!!bardoendlabel}%
1159 \!setbars}
1160
1161 % ** \!barcurve
1162 % ** Draws a bargraph with preset values of barshift, barbreadth,
1163 % ** barorientation (x or y) and barbaseline (coordinate)
1164 \def\!barcurve #1 #2 {%
1165 \if y\!barorientation
1166 \def\!basexarg{#1}%
1167 \def\!baseyarg{\!barbaseline}%
1168 \else
1169 \def\!basexarg{\!barbaseline}%
1170 \def\!baseyarg{#2}%
1171 \fi
1172 \expandafter\putbar\!barshift breadth <\!barbreadth> from {\!basexarg}
1173 {\!baseyarg} to {#1} {#2}
1174 \def\!endxarg{#1}%
1175 \def\!endyarg{#2}%
1176 \!bardobaselabel}
1177
1178 \def\!!bardobaselabel "#1" {%
1179 \put {#1}\!barbaselabelorientation{} at {\!basexarg} {\!baseyarg}
1180 \!bardoendlabel}
1181
1182 \def\!!bardoendlabel "#1" {%
1183 \put {#1}\!barendlabelorientation{} at {\!endxarg} {\!endyarg}
1184 \!barfinish}
1185
1186 \def\!barfinish{%
1187 \!ifnextchar/{\!finish}{\!barcurve}}
1188
1189
1190 % ********************************
1191 % *** BOXES (Draws rectangles) ***
1192 % ********************************
1193 %
1194 % ** User commands:
1195 % ** \putrectangle [<XSHIFT,YSHIFT>] corners at XCOORD1 YCOORD1
1196 % ** and XCOORD2 YCOORD2
1197 % ** \shaderectangleson
1198 % ** \shaderectanglesoff
1199 % ** \frame [<SEPARATION>] {TEXT}
1200 % ** \rectangle <WIDTH> <HEIGHT>
1201 %
1202 %
1203 % ** \putrectangle [<XSHIFT,YSHIFT>] corners at XCOORD1 YCOORD1
1204 % ** and XCOORD2 YCOORD2
1205 % ** Draws a rectangle with corners at (X1,Y1), (X2,Y1), (X1,Y2), (X2,Y2)
1206 % ** Lines have thickness \linethickness, and overlap at the corners.
1207 % ** The optional field <XSHIFT,YSHIFT> functions as with a \put command.
1208 % ** See Subsection 4.2 of the manual.
1209 \def\putrectangle{%
1210 \!ifnextchar<{\!putrectangle}{\!putrectangle<\!zpt,\!zpt> }}
1211 \def\!putrectangle<#1,#2> corners at #3 #4 and #5 #6 {%
1212 %
1213 % ** get locations
1214 \!xone=\!M{#3}\!xunit \!xtwo=\!M{#5}\!xunit%
1215 \!yone=\!M{#4}\!yunit \!ytwo=\!M{#6}\!yunit%
1216 \ifdim \!xtwo<\!xone
1217 \!dimenI=\!xone \!xone=\!xtwo \!xtwo=\!dimenI
1218 \fi
1219 \ifdim \!ytwo<\!yone
1220 \!dimenI=\!yone \!yone=\!ytwo \!ytwo=\!dimenI
1221 \fi
1222 \!dimenI=#1\relax \advance\!xone\!dimenI \advance\!xtwo\!dimenI
1223 \!dimenI=#2\relax \advance\!yone\!dimenI \advance\!ytwo\!dimenI
1224 \let\!MRect=\!M% ** save current coord/dimen mode
1225 \!setdimenmode
1226 %
1227 % ** shade rectangle if appropriate
1228 \!shaderectangle
1229 %
1230 % ** draw horizontal edges
1231 \!dimenI=.5\linethickness
1232 \advance \!xone -\!dimenI% ** adjust x-location to overlap corners
1233 \advance \!xtwo \!dimenI% ** ditto
1234 \putrule from {\!xone} {\!yone} to {\!xtwo} {\!yone}
1235 \putrule from {\!xone} {\!ytwo} to {\!xtwo} {\!ytwo}
1236 %
1237 % ** draw vertical edges
1238 \advance \!xone \!dimenI% ** restore original x-values
1239 \advance \!xtwo -\!dimenI%
1240 \advance \!yone -\!dimenI% ** adjust y-location to overlap corners
1241 \advance \!ytwo \!dimenI% ** ditto
1242 \putrule from {\!xone} {\!yone} to {\!xone} {\!ytwo}
1243 \putrule from {\!xtwo} {\!yone} to {\!xtwo} {\!ytwo}
1244 %
1245 \let\!M=\!MRect% ** restore coord/dimen mode
1246 \ignorespaces}
1247
1248 % ** \shaderectangleson
1249 % ** Subsequent rectangles will be shaded according to
1250 % ** the current shading pattern. Affects \putrectangle, \putbar,
1251 % ** \frame, \sethistograms, and \setbars. See Subsection 7.5 of the manual.
1252 \def\shaderectangleson{%
1253 \def\!shaderectangle{\!!shaderectangle}%
1254 \ignorespaces}
1255 % ** \shaderectanglesoff
1256 % ** Suppresses \shaderectangleson. The default.
1257 \def\shaderectanglesoff{%
1258 \def\!shaderectangle{}%
1259 \ignorespaces}
1260
1261 \shaderectanglesoff
1262
1263 % ** The following internal routine shades the current rectangle, when
1264 % ** \!shaderectangle = \!!shaderectangle .
1265 \def\!!shaderectangle{%
1266 \!dimenA=\!xtwo \advance \!dimenA -\!xone
1267 \!dimenB=\!ytwo \advance \!dimenB -\!yone
1268 \ifdim \!dimenA<\!dimenB
1269 \!startvshade (\!xone,\!yone,\!ytwo)
1270 \!lshade (\!xtwo,\!yone,\!ytwo)
1271 \else
1272 \!starthshade (\!yone,\!xone,\!xtwo)
1273 \!lshade (\!ytwo,\!xone,\!xtwo)
1274 \fi
1275 \ignorespaces}
1276
1277 % ** \frame [<SEPARATION>] {TEXT}
1278 % ** Draws a frame of thickness linethickness about the box enclosing
1279 % ** TEXT; the frame is separated from the box by a distance of
1280 % ** SEPARATION. The result is an hbox with the same baseline as TEXT.
1281 % ** If <SEPARATION> is omitted, you get the effect of <0pt>.
1282 % ** See Subsection 4.2 of the manual.
1283 \def\frame{%
1284 \!ifnextchar<{\!frame}{\!frame<\!zpt> }}
1285 \long\def\!frame<#1> #2{%
1286 \beginpicture
1287 \setcoordinatesystem units <1pt,1pt> point at 0 0
1288 \put {#2} [Bl] at 0 0
1289 \!dimenA=#1\relax
1290 \!dimenB=\!wd \advance \!dimenB \!dimenA
1291 \!dimenC=\!ht \advance \!dimenC \!dimenA
1292 \!dimenD=\!dp \advance \!dimenD \!dimenA
1293 \let\!MFr=\!M
1294 \!setdimenmode
1295 \putrectangle corners at {-\!dimenA} {-\!dimenD} and {\!dimenB} {\!dimenC}
1296 \!setcoordmode
1297 \let\!M=\!MFr
1298 \endpicture
1299 \ignorespaces}
1300
1301 % ** \rectangle <WIDTH> <HEIGHT>
1302 % ** Constructs a rectangle of width WIDTH and heigth HEIGHT.
1303 % ** See Subsection 4.2 of the manual.
1304 \def\rectangle <#1> <#2> {%
1305 \setbox0=\hbox{}\wd0=#1\ht0=#2\frame {\box0}}
1306
1307
1308 % *********************************************
1309 % *** CURVES (Upper level \plot commands) ***
1310 % *********************************************
1311 %
1312 % ** User commands
1313 % ** \plot DATA /
1314 % ** \plot "FILE NAME"
1315 % ** \setquadratic
1316 % ** \setlinear
1317 % ** \sethistograms
1318 % ** \vshade ...
1319 % ** \hshade ...
1320
1321 % \plot: multi-purpose command. Draws histograms, bar graphs, piecewise-linear
1322 % or piecewise quadratic curves, depending on the setting of \!drawcurve.
1323 % See Subsections 4.3-4.5, 5.1, 5.2 of the manual.
1324 \def\plot{%
1325 \!ifnextchar"{\!plotfromfile}{\!drawcurve}}
1326 \def\!plotfromfile"#1"{%
1327 \expandafter\!drawcurve \input #1 /}
1328
1329 % Command to set piecewise quadratic mode
1330 % See Subsections 5.1, 7.3, and 7.4 of the manual.
1331 \def\setquadratic{%
1332 \let\!drawcurve=\!qcurve
1333 \let\!!Shade=\!!qShade
1334 \let\!!!Shade=\!!!qShade}
1335
1336 % Command to set piecewise linear mode
1337 % See Subsections 5.1, 7.3, and 7.4 of the manual.
1338 \def\setlinear{%
1339 \let\!drawcurve=\!lcurve
1340 \let\!!Shade=\!!lShade
1341 \let\!!!Shade=\!!!lShade}
1342
1343 % Command to set histogram mode
1344 % See Subsection 4.3 of the manual.
1345 \def\sethistograms{%
1346 \let\!drawcurve=\!hcurve}
1347
1348 % Commands to cycle through list of coordinates in piecewise quadratic
1349 % interpolation mode
1350 \def\!qcurve #1 #2 {%
1351 \!start (#1,#2)
1352 \!Qjoin}
1353 \def\!Qjoin#1 #2 #3 #4 {%
1354 \!qjoin (#1,#2) (#3,#4) % \!qjoin is defined in QUADRATIC
1355 \!ifnextchar/{\!finish}{\!Qjoin}}
1356
1357 % Commands to cycle through list of coordinates in piecewise linear
1358 % interpolation mode
1359 \def\!lcurve #1 #2 {%
1360 \!start (#1,#2)
1361 \!Ljoin}
1362 \def\!Ljoin#1 #2 {%
1363 \!ljoin (#1,#2) % \!ljoin is defined in LINEAR
1364 \!ifnextchar/{\!finish}{\!Ljoin}}
1365
1366 \def\!finish/{\ignorespaces}
1367
1368 % Command to cycle through list of coordinates in histogram mode
1369 \def\!hcurve #1 #2 {%
1370 \edef\!hxS{#1}%
1371 \edef\!hyS{#2}%
1372 \!hjoin}
1373 \def\!hjoin#1 #2 {%
1374 \putrectangle corners at {\!hxS} {\!hyS} and {#1} {#2}
1375 \edef\!hxS{#1}%
1376 \!ifnextchar/{\!finish}{\!hjoin}}
1377
1378
1379 % \vshade: See Subsection 7.3 of the manual.
1380 \def\vshade #1 #2 #3 {%
1381 \!startvshade (#1,#2,#3)
1382 \!Shadewhat}
1383
1384 % \hshade: See Subsection 7.4 of the manual.
1385 \def\hshade #1 #2 #3 {%
1386 \!starthshade (#1,#2,#3)
1387 \!Shadewhat}
1388
1389 % Commands to cycle through coordinates and optional "edge effect"
1390 % fields while shading.
1391 \def\!Shadewhat{%
1392 \futurelet\!nextchar\!Shade}
1393 \def\!Shade{%
1394 \if <\!nextchar
1395 \def\!nextShade{\!!Shade}%
1396 \else
1397 \if /\!nextchar
1398 \def\!nextShade{\!finish}%
1399 \else
1400 \def\!nextShade{\!!!Shade}%
1401 \fi
1402 \fi
1403 \!nextShade}
1404 \def\!!lShade<#1> #2 #3 #4 {%
1405 \!lshade <#1> (#2,#3,#4) % \!lshade is defined in SHADING
1406 \!Shadewhat}
1407 \def\!!!lShade#1 #2 #3 {%
1408 \!lshade (#1,#2,#3)
1409 \!Shadewhat}
1410 \def\!!qShade<#1> #2 #3 #4 #5 #6 #7 {%
1411 \!qshade <#1> (#2,#3,#4) (#5,#6,#7) % \!qshade is defined in SHADING
1412 \!Shadewhat}
1413 \def\!!!qShade#1 #2 #3 #4 #5 #6 {%
1414 \!qshade (#1,#2,#3) (#4,#5,#6)
1415 \!Shadewhat}
1416
1417 % ** Set default interpolation mode
1418 \setlinear
1419
1420
1421 % ********************************************
1422 % *** DASHPATTERNS (Sets up dash patterns) ***
1423 % ********************************************
1424
1425 % ** User commands:
1426 % ** \setdashpattern <DIMEN1,DIMEN2,DIMEN3,...>
1427 % ** \setdots <INTRADOT_DISTANCE>
1428 % ** \setdotsnear <INTRADOT_DISTANCE> for <ARC LENGTH>
1429 % ** \setdashes <DASH/SKIP_DISTANCE>
1430 % ** \setdashesnear <DASH/SKIP_DISTANCE> for <ARC LENGTH>
1431 % ** \setsolid
1432 % ** \findlength {CURVE CMDS}
1433
1434 % ** Internal commands:
1435 % ** \!dashingon
1436 % ** \!dashingoff
1437
1438 % ** Dash patterns are specified by a balanced token list whose complete
1439 % ** expansion has the form: DIMEN1,DIMEN2,DIMEN3,DIMEN4,... ; this produces
1440 % ** an arc of length DIMEN1, a skip of length DIMEN2, an arc of length
1441 % ** DIMEN3, a skip of length DIMEN4, ... . Any number of DIMEN values may
1442 % ** be given. The pattern is repeated as many times (perhaps fractional)
1443 % ** as necessary to draw the curve.
1444 % ** A dash pattern remains in effect until it is overridden by a call to
1445 % ** \setdashpattern, or to \setdots, \setdotsnear ... , \setdashes,
1446 % ** \setdashesnear ... , or \setsolid.
1447 % ** Solid lines are the default.
1448
1449
1450 % ** \def\setdashpattern <DIMEN1,DIMEN2,DIMEN3,...>
1451 % ** The following routine converts a balanced list of tokens whose
1452 % ** complete expansion has the form DIMEN1,DIMEN2, ... , DIMENk into
1453 % ** three list macros that are used in drawing dashed rules and curves:
1454 % ** !Flist: \!Rule{DIMEN1}\!Skip{DIMEN2}\!Rule{DIMEN3}\!Skip{DIMEN4} ...
1455 % ** !Blist: ...\!Skip{DIMEN4}\!Rule{DIMEN3}\!Skip{DIMEN2}\!Rule{DIMEN1}
1456 % ** !UDlist: \\{DIMEN1}\\{DIMEN2}\\{DIMEN3}\\{DIMEN4} ...;
1457 % ** calculates \!leaderlength := DIMEN1 + ... + DIMENk; and
1458 % ** sets the curve drawing routines to dash mode.
1459 % ** Those lists are used by the curve drawing routines.
1460 % ** Dimenj ... may be given as an explicit dimension (e.g., 5pt), or
1461 % ** as an expression involving a dimension register (e.g., -2.5\dimen0).
1462 % ** See Subsection 6.2 of the manual
1463 \def\setdashpattern <#1>{%
1464 \def\!Flist{}\def\!Blist{}\def\!UDlist{}%
1465 \!countA=0
1466 \!ecfor\!item:=#1\do{%
1467 \!dimenA=\!item\relax
1468 \expandafter\!rightappend\the\!dimenA\withCS{\\}\to\!UDlist%
1469 \advance\!countA 1
1470 \ifodd\!countA
1471 \expandafter\!rightappend\the\!dimenA\withCS{\!Rule}\to\!Flist%
1472 \expandafter\!leftappend\the\!dimenA\withCS{\!Rule}\to\!Blist%
1473 \else
1474 \expandafter\!rightappend\the\!dimenA\withCS{\!Skip}\to\!Flist%
1475 \expandafter\!leftappend\the\!dimenA\withCS{\!Skip}\to\!Blist%
1476 \fi}%
1477 \!leaderlength=\!zpt
1478 \def\!Rule##1{\advance\!leaderlength ##1}%
1479 \def\!Skip##1{\advance\!leaderlength ##1}%
1480 \!Flist%
1481 \ifdim\!leaderlength>\!zpt
1482 \else
1483 \def\!Flist{\!Skip{24in}}\def\!Blist{\!Skip{24in}}\ignorespaces
1484 \def\!UDlist{\\{\!zpt}\\{24in}}\ignorespaces
1485 \!leaderlength=24in
1486 \fi
1487 \!dashingon}
1488
1489
1490 % ** \!dashingon -- puts the curve drawing routines into dash mode
1491 % ** \!dashingoff -- puts the curve drawing routines into solid mode
1492 % ** These are internal commands, invoked by \setdashpattern and \setsolid
1493 \def\!dashingon{%
1494 \def\!advancedashing{\!!advancedashing}%
1495 \def\!drawlinearsegment{\!lineardashed}%
1496 \def\!puthline{\!putdashedhline}%
1497 \def\!putvline{\!putdashedvline}%
1498 % \def\!putsline{\!putdashedsline}%
1499 \ignorespaces}%
1500 \def\!dashingoff{%
1501 \def\!advancedashing{\relax}%
1502 \def\!drawlinearsegment{\!linearsolid}%
1503 \def\!puthline{\!putsolidhline}%
1504 \def\!putvline{\!putsolidvline}%
1505 % \def\!putsline{\!putsolidsline}%
1506 \ignorespaces}
1507
1508
1509 % ** \setdots <LENGTH> -- sets up a dot/skip pattern where dot (actually
1510 % ** the current plotsymbol) is plunked down once for every LENGTH
1511 % ** traveled along the curve. LENGTH defaults to 5pt.
1512 % ** See Subsection 6.1 of the manual.
1513 \def\setdots{%
1514 \!ifnextchar<{\!setdots}{\!setdots<5pt>}}
1515 \def\!setdots<#1>{%
1516 \!dimenB=#1\advance\!dimenB -\plotsymbolspacing
1517 \ifdim\!dimenB<\!zpt
1518 \!dimenB=\!zpt
1519 \fi
1520 \setdashpattern <\plotsymbolspacing,\!dimenB>}
1521
1522 % ** \setdotsnear <LENGTH> for <ARC LENGTH>
1523 % ** sets up a dot pattern where the dots are approximately LENGTH apart,
1524 % ** the total length of the pattern is ARC LENGTH, and the pattern
1525 % ** begins and ends with a dot. See Subsection 6.3 of the manual.
1526 \def\setdotsnear <#1> for <#2>{%
1527 \!dimenB=#2\relax \advance\!dimenB -.05pt
1528 \!dimenC=#1\relax \!countA=\!dimenC
1529 \!dimenD=\!dimenB \advance\!dimenD .5\!dimenC \!countB=\!dimenD
1530 \divide \!countB \!countA
1531 \ifnum 1>\!countB
1532 \!countB=1
1533 \fi
1534 \divide\!dimenB \!countB
1535 \setdots <\!dimenB>}
1536
1537 % ** \setdashes <LENGTH> -- sets up a dash/skip pattern where the dash
1538 % ** and the skip are each of length LENGTH (the dash is formed by
1539 % ** plunking down the current plotsymbol over an arc of length LENGTH
1540 % ** and so may actually be longer than LENGTH. LENGTH defaults to 5pt.
1541 % ** See Subsection 6.1 of the manual.
1542 \def\setdashes{%
1543 \!ifnextchar<{\!setdashes}{\!setdashes<5pt>}}
1544 \def\!setdashes<#1>{\setdashpattern <#1,#1>}
1545
1546 % ** \setdashesnear ...
1547 % ** Like \setdotsnear; the pattern begins and ends with a dash.
1548 % ** See Subsection 6.3 of the manual.
1549 \def\setdashesnear <#1> for <#2>{%
1550 \!dimenB=#2\relax
1551 \!dimenC=#1\relax \!countA=\!dimenC
1552 \!dimenD=\!dimenB \advance\!dimenD .5\!dimenC \!countB=\!dimenD
1553 \divide \!countB \!countA
1554 \ifodd \!countB
1555 \else
1556 \advance \!countB 1
1557 \fi
1558 \divide\!dimenB \!countB
1559 \setdashes <\!dimenB>}
1560
1561 % ** \setsolid -- puts the curve drawing routines in "solid line" mode,
1562 % ** the default mode. See Subsection 6.1 of the manual.
1563 \def\setsolid{%
1564 \def\!Flist{\!Rule{24in}}\def\!Blist{\!Rule{24in}}%
1565 \def\!UDlist{\\{24in}\\{\!zpt}}%
1566 \!dashingoff}
1567 \setsolid
1568
1569 % ** \findlength {CURVE CMDS}
1570 % ** PiCTeX executes the \start, \ljoin, and \qjoin cmds comprising
1571 % ** CURVE CMDS without plotting anything, but stashes the length
1572 % ** of the phantom curve away in \totalarclength.
1573 % ** See Subsection 6.3 of the manual.
1574 \def\findlength#1{%
1575 \begingroup
1576 \setdashpattern <0pt, \maxdimen>
1577 \setplotsymbol ({})
1578 \dontsavelinesandcurves
1579 #1%
1580 \endgroup
1581 \ignorespaces}
1582
1583
1584 % *************************************************************
1585 % *** DIVISION (Does long division of dimension registers) ***
1586 % *************************************************************
1587
1588 % ** User command:
1589 % ** \Divide {DIVIDEND} by {DIVISOR} forming {RESULT}
1590
1591 % ** Internal command
1592 % ** \!divide{DIVIDEND}{DIVISOR}{RESULT}
1593
1594 % ** \!divide DIVIDEND [by] DIVISOR [to get] ANSWER
1595 % ** Divides the dimension DIVIDEND by the dimension DIVISOR, placing the
1596 % ** quotient in the dimension register ANSWER. Values are understood to
1597 % ** be in points. E.g. 12.5pt/1.4pt=8.92857pt.
1598 % ** Quotient is accurate to 1/65536pt=2**[-16]pt
1599 % ** |DIVISOR| should be < 2048pt (about 28 inches).
1600 \def\!divide#1#2#3{%
1601 \!dimenB=#1% ** dimB holds current remainder (r)
1602 \!dimenC=#2% ** dimC holds divisor (d)
1603 \!dimenD=\!dimenB% ** dimD holds quotient q=r/d for this
1604 \divide \!dimenD \!dimenC% ** step, in units of scaled pts
1605 \!dimenA=\!dimenD% ** dimA eventually holds answer (a)
1606 \multiply\!dimenD \!dimenC% ** r <-- r - dq
1607 \advance\!dimenB -\!dimenD% ** First step complete. Have integer part
1608 % ** of a, and corresponding remainder.
1609 \!dimenD=\!dimenC% ** Temporarily use dimD to hold |d|
1610 \ifdim\!dimenD<\!zpt \!dimenD=-\!dimenD
1611 \fi
1612 \ifdim\!dimenD<64pt% ** Branch on the magnitude of |d|
1613 \!divstep[\!tfs]\!divstep[\!tfs]%
1614 \else
1615 \!!divide
1616 \fi
1617 #3=\!dimenA\ignorespaces}
1618
1619 % ** The following code handles divisors d with
1620 % ** (1) .88in = 64pt <= d < 256pt = 3.54in
1621 % ** (2) 3.54in = 256pt <= d < 2048pt = 28.34in
1622 % ** Anything bigger than that may result in an overflow condition.
1623 % ** For our purposes, we should never even see case (2).
1624 \def\!!divide{%
1625 \ifdim\!dimenD<256pt
1626 \!divstep[64]\!divstep[32]\!divstep[32]%
1627 \else
1628 \!divstep[8]\!divstep[8]\!divstep[8]\!divstep[8]\!divstep[8]%
1629 \!dimenA=2\!dimenA
1630 \fi}
1631
1632
1633 % ** The following macro does the real long division work.
1634 \def\!divstep[#1]{% ** #1 = "B"
1635 \!dimenB=#1\!dimenB% ** r <-- B*r
1636 \!dimenD=\!dimenB% ** dimD holds quotient q=r/d for this
1637 \divide \!dimenD by \!dimenC% ** step, in units of scaled pts
1638 \!dimenA=#1\!dimenA% ** a <-- B*a + q
1639 \advance\!dimenA by \!dimenD%
1640 \multiply\!dimenD by \!dimenC% ** r <-- r - dq
1641 \advance\!dimenB by -\!dimenD}
1642
1643 % ** \Divide: See Subsection 9.3 of the manual.
1644 \def\Divide <#1> by <#2> forming <#3> {%
1645 \!divide{#1}{#2}{#3}}
1646
1647
1648 % *********************************************
1649 % *** ELLIPSES (Draws ellipses and circles) ***
1650 % *********************************************
1651
1652 % ** User commands
1653 % ** \ellipticalarc axes ratio A:B DEGREES degrees from XSTART YSTART
1654 % ** center at XCENTER YCENTER
1655 % ** \circulararc DEGREES degrees from XSTART YSTART
1656 % ** center at XCENTER YCENTER
1657
1658 % ** Internal command
1659 % ** \!sinandcos{32*ANGLE in radians}{32*SIN}{32*COS}
1660
1661
1662 % ** \ellipticalarc axes ratio A:B DEGREES degrees from XSTART YSTART
1663 % ** center at XCENTER YCENTER
1664 % ** Draws a elliptical arc starting at the coordinate point (XSTART,YSTART).
1665 % ** The center of the ellipse of which the arc is a segment is at
1666 % ** (XCENTER,YCENTER).
1667 % ** The arc extends through an angle of DEGREES degrees (may be + or -).
1668 % ** A:B is the ratio of the length of the xaxis to the length of
1669 % ** the yaxis of the ellipse
1670 % ** Sqrt{[(XSTART-XCENTER)/A]**2 + [(YSTART-YCENTER)/B]**2}
1671 % ** must be < 512pt (about 7in).
1672 % ** Doesn't modify the dimensions (ht, dp, wd) of the PiCture under
1673 % ** construction.
1674
1675 % ** \circulararc -- See Subsection 5.3 of the manual.
1676 \def\circulararc{%
1677 \ellipticalarc axes ratio 1:1 }
1678
1679 % ** \ellipticalarc -- See Subsection 5.3 of the manual.
1680 \def\ellipticalarc axes ratio #1:#2 #3 degrees from #4 #5 center at #6 #7 {%
1681 \!angle=#3pt\relax% ** get angle
1682 \ifdim\!angle>\!zpt
1683 \def\!sign{}% ** counterclockwise
1684 \else
1685 \def\!sign{-}\!angle=-\!angle% ** clockwise
1686 \fi
1687 \!xxloc=\!M{#6}\!xunit% ** convert CENTER to dimension
1688 \!yyloc=\!M{#7}\!yunit
1689 \!xxS=\!M{#4}\!xunit% ** get STARTing point on rim of ellipse
1690 \!yyS=\!M{#5}\!yunit
1691 \advance\!xxS -\!xxloc% ** make center of ellipse (0,0)
1692 \advance\!yyS -\!yyloc
1693 \!divide\!xxS{#1pt}\!xxS % ** scale point on ellipse to point on
1694 \!divide\!yyS{#2pt}\!yyS % corresponding circle
1695 %
1696 \let\!MC=\!M% ** save current c/d mode
1697 \!setdimenmode% ** go into dimension mode
1698 %
1699 \!xS=#1\!xxS \advance\!xS\!xxloc
1700 \!yS=#2\!yyS \advance\!yS\!yyloc
1701 \!start (\!xS,\!yS)%
1702 \!loop\ifdim\!angle>14.9999pt% ** draw in major portion of ellipse
1703 \!rotate(\!xxS,\!yyS)by(\!cos,\!sign\!sin)to(\!xxM,\!yyM)
1704 \!rotate(\!xxM,\!yyM)by(\!cos,\!sign\!sin)to(\!xxE,\!yyE)
1705 \!xM=#1\!xxM \advance\!xM\!xxloc \!yM=#2\!yyM \advance\!yM\!yyloc
1706 \!xE=#1\!xxE \advance\!xE\!xxloc \!yE=#2\!yyE \advance\!yE\!yyloc
1707 \!qjoin (\!xM,\!yM) (\!xE,\!yE)
1708 \!xxS=\!xxE \!yyS=\!yyE
1709 \advance \!angle -15pt
1710 \repeat
1711 \ifdim\!angle>\!zpt% ** complete remaining arc, if any
1712 \!angle=100.53096\!angle% ** convert angle to radians, divide
1713 \divide \!angle 360 % ** by 2, and multiply by 32
1714 \!sinandcos\!angle\!!sin\!!cos% ** get 32*sin & 32*cos
1715 \!rotate(\!xxS,\!yyS)by(\!!cos,\!sign\!!sin)to(\!xxM,\!yyM)
1716 \!rotate(\!xxM,\!yyM)by(\!!cos,\!sign\!!sin)to(\!xxE,\!yyE)
1717 \!xM=#1\!xxM \advance\!xM\!xxloc \!yM=#2\!yyM \advance\!yM\!yyloc
1718 \!xE=#1\!xxE \advance\!xE\!xxloc \!yE=#2\!yyE \advance\!yE\!yyloc
1719 \!qjoin (\!xM,\!yM) (\!xE,\!yE)
1720 \fi
1721 %
1722 \let\!M=\!MC% ** restore c/d mode
1723 \ignorespaces}% ** if appropriate
1724
1725
1726 % ** \!rotate(XREG,YREG)by(32cos,32sin)to(XXREG,YYREG)
1727 % ** rotates (XREG,YREG) by angle with specfied scaled cos & sin to
1728 % ** (XXREG,YYREG). Uses \!dimenA & \!dimenB as scratch registers.
1729 \def\!rotate(#1,#2)by(#3,#4)to(#5,#6){%
1730 \!dimenA=#3#1\advance \!dimenA -#4#2% ** Rcos(x+t)=Rcosx*cost - Rsinx*sint
1731 \!dimenB=#3#2\advance \!dimenB #4#1% ** Rsin(x+t)=Rsinx*cost + Rcosx*sint
1732 \divide \!dimenA 32 \divide \!dimenB 32
1733 #5=\!dimenA #6=\!dimenB
1734 \ignorespaces}
1735 \def\!sin{4.17684}% ** 32*sin(pi/24) (pi/24=7.5deg)
1736 \def\!cos{31.72624}% ** 32*cos(pi/24)
1737
1738
1739 % ** \!sinandcos{32*ANGLE in radians}{\SINCS}{\COSCS}
1740 % ** Computes the 32*sine and 32*cosine of a small ANGLE expressed in
1741 % ** radians/32 and puts these values in the replacement texts of
1742 % ** \SINCS and \COSCS
1743 \def\!sinandcos#1#2#3{%
1744 \!dimenD=#1% ** angle is expressed in radians/32: 1pt = 1/32rad
1745 \!dimenA=\!dimenD% ** dimA will eventually contain 32sin(angle)in pts
1746 \!dimenB=32pt% ** dimB will eventually contain 32cos(angle)in pts
1747 \!removept\!dimenD\!value% ** get value of 32*angle, without "pt"
1748 \!dimenC=\!dimenD% ** holds 32*angle**i/i! in pts
1749 \!dimenC=\!value\!dimenC \divide\!dimenC by 64 % ** now 32*angle**2/2
1750 \advance\!dimenB by -\!dimenC% ** 32-32*angle**2/2
1751 \!dimenC=\!value\!dimenC \divide\!dimenC by 96 % ** now 32*angle**3/3!
1752 \advance\!dimenA by -\!dimenC% ** now 32*(angle-angle**3/6)
1753 \!dimenC=\!value\!dimenC \divide\!dimenC by 128 % ** now 32*angle**4/4!
1754 \advance\!dimenB by \!dimenC%
1755 \!removept\!dimenA#2% ** set 32*sin(angle)
1756 \!removept\!dimenB#3% ** set 32*cos(angle)
1757 \ignorespaces}
1758
1759
1760 % *****************************************************************
1761 % *** RULES (Draws rules, i.e., horizontal & vertical lines) ***
1762 % *****************************************************************
1763
1764 % ** User command:
1765 % ** \putrule [<XDIMEN,YDIMEN>] from XCOORD1 YCOORD1
1766 % ** to XCOORD2 YCOORD2
1767
1768 % ** Internal commands:
1769 % ** \!puthline [<XDIMEN,YDIMEN>] (h = horizontal)
1770 % ** Set by dashpat to either: \!putsolidhline or \!putdashedhline
1771 % ** \!putvline [<XDIMEN,YDIMEN>] (v = vertical)
1772 % ** Either: \!putsolidvline or \!putdashedvline
1773
1774
1775 % ** \putrule [<XDIMEN,YDIMEN>] from XCOORD1 YCOORD1
1776 % ** to XCOORD2 YCOORD2
1777 % ** Draws a rule -- dashed or solid depending on the current dash pattern --
1778 % ** from (X1,Y1) to (X2,Y2). Uses TEK's \hrule & \vrule & \leaders
1779 % ** constructions to handle horizontal & vertical lines efficiently both
1780 % ** in terms of execution time and space in the DVI file.
1781 % ** See Subsection 4.1 of the manual.
1782 \def\putrule#1from #2 #3 to #4 #5 {%
1783 \!xloc=\!M{#2}\!xunit \!xxloc=\!M{#4}\!xunit%
1784 \!yloc=\!M{#3}\!yunit \!yyloc=\!M{#5}\!yunit%
1785 \!dxpos=\!xxloc \advance\!dxpos by -\!xloc
1786 \!dypos=\!yyloc \advance\!dypos by -\!yloc
1787 %
1788 \ifdim\!dypos=\!zpt
1789 \def\!!Line{\!puthline{#1}}\ignorespaces
1790 \else
1791 \ifdim\!dxpos=\!zpt
1792 \def\!!Line{\!putvline{#1}}\ignorespaces
1793 \else
1794 \def\!!Line{}
1795 \fi
1796 \fi
1797 \let\!ML=\!M% ** save current coord\dimen mode
1798 \!setdimenmode% ** express locations in dimens
1799 \!!Line%
1800 \let\!M=\!ML% ** restore previous c/d mode
1801 \ignorespaces}
1802
1803
1804 % ** \!putsolidhline [<XDIMEN,YDIMEN>]
1805 % ** Place horizontal solid line
1806 \def\!putsolidhline#1{%
1807 \ifdim\!dxpos>\!zpt
1808 \put{\!hline\!dxpos}#1[l] at {\!xloc} {\!yloc}
1809 \else
1810 \put{\!hline{-\!dxpos}}#1[l] at {\!xxloc} {\!yyloc}
1811 \fi
1812 \ignorespaces}
1813
1814 % ** \!putsolidvline [shifted <XDIMEN,YDIMEN>]
1815 % ** Place vertical solid line
1816 \def\!putsolidvline#1{%
1817 \ifdim\!dypos>\!zpt
1818 \put{\!vline\!dypos}#1[b] at {\!xloc} {\!yloc}
1819 \else
1820 \put{\!vline{-\!dypos}}#1[b] at {\!xxloc} {\!yyloc}
1821 \fi
1822 \ignorespaces}
1823
1824 \def\!hline#1{\hbox to #1{\leaders \hrule height\linethickness\hfill}}
1825 \def\!vline#1{\vbox to #1{\leaders \vrule width\linethickness\vfill}}
1826
1827
1828 % ** \!putdashedhline [<XDIMEN,YDIMEN>]
1829 % ** Place dashed horizontal line
1830 \def\!putdashedhline#1{%
1831 \ifdim\!dxpos>\!zpt
1832 \!DLsetup\!Flist\!dxpos
1833 \put{\hbox to \!totalleaderlength{\!hleaders}\!hpartialpattern\!Rtrunc}
1834 #1[l] at {\!xloc} {\!yloc}
1835 \else
1836 \!DLsetup\!Blist{-\!dxpos}
1837 \put{\!hpartialpattern\!Ltrunc\hbox to \!totalleaderlength{\!hleaders}}
1838 #1[r] at {\!xloc} {\!yloc}
1839 \fi
1840 \ignorespaces}
1841
1842 % ** \!putdashedhline [<XDIMEN,YDIMEN>]
1843 % ** Place dashed vertical line
1844 \def\!putdashedvline#1{%
1845 \!dypos=-\!dypos% ** vertical leaders go from top to bottom
1846 \ifdim\!dypos>\!zpt
1847 \!DLsetup\!Flist\!dypos
1848 \put{\vbox{\vbox to \!totalleaderlength{\!vleaders}
1849 \!vpartialpattern\!Rtrunc}}#1[t] at {\!xloc} {\!yloc}
1850 \else
1851 \!DLsetup\!Blist{-\!dypos}
1852 \put{\vbox{\!vpartialpattern\!Ltrunc
1853 \vbox to \!totalleaderlength{\!vleaders}}}#1[b] at {\!xloc} {\!yloc}
1854 \fi
1855 \ignorespaces}
1856
1857
1858 % ** The rest of the macros in this section are subroutines used by
1859 % ** \!putdashedhline and \!putdashedvline.
1860 \def\!DLsetup#1#2{% ** Dashed-Line set up
1861 \let\!RSlist=#1% ** set !Rule-Skip list
1862 \!countB=#2% ** convert rule length to integer (number of sps)
1863 \!countA=\!leaderlength% ** ditto, leaderlength
1864 \divide\!countB by \!countA% ** number of complete leader units
1865 \!totalleaderlength=\!countB\!leaderlength
1866 \!Rresiduallength=#2%
1867 \advance \!Rresiduallength by -\!totalleaderlength% \** excess length
1868 \!Lresiduallength=\!leaderlength
1869 \advance \!Lresiduallength by -\!Rresiduallength
1870 \ignorespaces}
1871
1872 \def\!hleaders{%
1873 \def\!Rule##1{\vrule height\linethickness width##1}%
1874 \def\!Skip##1{\hskip##1}%
1875 \leaders\hbox{\!RSlist}\hfill}
1876
1877 \def\!hpartialpattern#1{%
1878 \!dimenA=\!zpt \!dimenB=\!zpt
1879 \def\!Rule##1{#1{##1}\vrule height\linethickness width\!dimenD}%
1880 \def\!Skip##1{#1{##1}\hskip\!dimenD}%
1881 \!RSlist}
1882
1883 \def\!vleaders{%
1884 \def\!Rule##1{\hrule width\linethickness height##1}%
1885 \def\!Skip##1{\vskip##1}%
1886 \leaders\vbox{\!RSlist}\vfill}
1887
1888 \def\!vpartialpattern#1{%
1889 \!dimenA=\!zpt \!dimenB=\!zpt
1890 \def\!Rule##1{#1{##1}\hrule width\linethickness height\!dimenD}%
1891 \def\!Skip##1{#1{##1}\vskip\!dimenD}%
1892 \!RSlist}
1893
1894 \def\!Rtrunc#1{\!trunc{#1}>\!Rresiduallength}
1895 \def\!Ltrunc#1{\!trunc{#1}<\!Lresiduallength}
1896
1897 \def\!trunc#1#2#3{%
1898 \!dimenA=\!dimenB
1899 \advance\!dimenB by #1%
1900 \!dimenD=\!dimenB \ifdim\!dimenD#2#3\!dimenD=#3\fi
1901 \!dimenC=\!dimenA \ifdim\!dimenC#2#3\!dimenC=#3\fi
1902 \advance \!dimenD by -\!dimenC}
1903
1904
1905 % ****************************************************************
1906 % *** LINEAR ARC (Draws straight lines -- solid and dashed) ***
1907 % ****************************************************************
1908
1909 % ** User commands
1910 % ** \inboundscheckoff
1911 % ** \inboundscheckon
1912
1913 % ** Internal commands
1914 % ** \!start (XCOORD,YCOORD)
1915 % ** \!ljoin (XCOORD,YCOORD)
1916 % ** \!drawlinearsegment -- set by \dashpat to either
1917 % ** \!linearsolid or \!lineardashed
1918 % ** \!advancedashing -- set by \dashpat to either
1919 % ** \relax or \!!advancedashing
1920 % ** \!plotifinbounds -- set by \inboundscheck off/on to either
1921 % ** \!plot or \!!plotifinbounds
1922 % ** \!initinboundscheck -- set by \inboundscheck off/on to either
1923 % ** \relax or \!!initinboundscheck
1924
1925
1926 % \plotsymbolspacing ** distance between consecutive plot positions
1927 % \!xS ** starting x
1928 % \!yS ** starting y
1929 % \!xE ** ending x
1930 % \!yE ** ending y
1931 % \!xdiff ** x_end - x_start
1932 % \!ydiff ** y_end - y_start
1933 % \!distacross ** how far along curve next point to be plotted is
1934 % \!arclength ** approximate length of arc for current interval
1935 % \!downlength ** remaining length for "pen" to be down
1936 % \!uplength ** length for "pen" to be down
1937 % \!intervalno ** counts segments to curve
1938 % \totalarclength ** cumulative distance along curve
1939 % \!npoints ** approximately (arc length / plotsymbolspacing)
1940
1941 % ** Calls -- \!Pythag, \!divide, \!plot
1942
1943
1944 % ** \!start (XCOORD,YCOORD)
1945 % ** Sets initial point for linearly (or quadratically) interpolated curve
1946 \def\!start (#1,#2){%
1947 \!plotxorigin=\!xorigin \advance \!plotxorigin by \!plotsymbolxshift
1948 \!plotyorigin=\!yorigin \advance \!plotyorigin by \!plotsymbolyshift
1949 \!xS=\!M{#1}\!xunit \!yS=\!M{#2}\!yunit
1950 \!rotateaboutpivot\!xS\!yS
1951 \!copylist\!UDlist\to\!!UDlist% **\!UDlist has the form \\{dimen1}\\{dimen2}..
1952 % ** Routine will draw dashed line with pen
1953 % ** down for dimen1, up for dimen2, ...
1954 \!getnextvalueof\!downlength\from\!!UDlist
1955 \!distacross=\!zpt% ** 1st point goes at start of curve
1956 \!intervalno=0 % ** initialize interval counter
1957 \global\totalarclength=\!zpt% ** initialize distance traveled along curve
1958 \ignorespaces}
1959
1960
1961 % ** \!ljoin (XCOORD,YCOORD)
1962 % ** Draws a straight line starting at the last point specified
1963 % ** by the most recent \!start, \!ljoin, or \!qjoin, and
1964 % ** ending at (XCOORD,YCOORD).
1965 \def\!ljoin (#1,#2){%
1966 \advance\!intervalno by 1
1967 \!xE=\!M{#1}\!xunit \!yE=\!M{#2}\!yunit
1968 \!rotateaboutpivot\!xE\!yE
1969 \!xdiff=\!xE \advance \!xdiff by -\!xS%** xdiff = xE - xS
1970 \!ydiff=\!yE \advance \!ydiff by -\!yS%** ydiff = yE - yS
1971 \!Pythag\!xdiff\!ydiff\!arclength% ** arclength = sqrt(xdiff**2+ydiff**2)
1972 \global\advance \totalarclength by \!arclength%
1973 \!drawlinearsegment% ** set by dashpat to \!linearsolid or \!lineardashed
1974 \!xS=\!xE \!yS=\!yE% ** shift ending points to starting points
1975 \ignorespaces}
1976
1977
1978 % ** The following routine is used to draw a "solid" line between (xS,yS)
1979 % ** and (xE,yE). Points are spaced nearly every \plotsymbolspacing length
1980 % ** along the line.
1981 \def\!linearsolid{%
1982 \!npoints=\!arclength
1983 \!countA=\plotsymbolspacing
1984 \divide\!npoints by \!countA% ** now #pts =. arclength/plotsymbolspacing
1985 \ifnum \!npoints<1
1986 \!npoints=1
1987 \fi
1988 \divide\!xdiff by \!npoints
1989 \divide\!ydiff by \!npoints
1990 \!xpos=\!xS \!ypos=\!yS
1991 %
1992 \loop\ifnum\!npoints>-1
1993 \!plotifinbounds
1994 \advance \!xpos by \!xdiff
1995 \advance \!ypos by \!ydiff
1996 \advance \!npoints by -1
1997 \repeat
1998 \ignorespaces}
1999
2000
2001 % ** The following routine is used to draw a dashed line between (xS,yS)
2002 % ** and (xE,yE). The dash pattern continues from the previous segment.
2003 \def\!lineardashed{%
2004 % **
2005 \ifdim\!distacross>\!arclength
2006 \advance \!distacross by -\!arclength %nothing to plot in this interval
2007 %
2008 \else
2009 %
2010 \loop\ifdim\!distacross<\!arclength
2011 % ** plot point, interpolating linearly in x and y
2012 \!divide\!distacross\!arclength\!dimenA% ** dimA = across/arclength
2013 \!removept\!dimenA\!t% ** \!t holds value in dimA, without the "pt"
2014 \!xpos=\!t\!xdiff \advance \!xpos by \!xS
2015 \!ypos=\!t\!ydiff \advance \!ypos by \!yS
2016 \!plotifinbounds
2017 \advance\!distacross by \plotsymbolspacing
2018 \!advancedashing
2019 \repeat
2020 %
2021 \advance \!distacross by -\!arclength% ** prepare for next interval
2022 \fi
2023 \ignorespaces}
2024
2025
2026 \def\!!advancedashing{%
2027 \advance\!downlength by -\plotsymbolspacing
2028 \ifdim \!downlength>\!zpt
2029 \else
2030 \advance\!distacross by \!downlength
2031 \!getnextvalueof\!uplength\from\!!UDlist
2032 \advance\!distacross by \!uplength
2033 \!getnextvalueof\!downlength\from\!!UDlist
2034 \fi}
2035
2036
2037 % ** \inboundscheckoff & \inboundscheckon: See Subsection 5.5 of the manual.
2038 \def\inboundscheckoff{%
2039 \def\!plotifinbounds{\!plot(\!xpos,\!ypos)}%
2040 \def\!initinboundscheck{\relax}\ignorespaces}
2041 \def\inboundscheckon{%
2042 \def\!plotifinbounds{\!!plotifinbounds}%
2043 \def\!initinboundscheck{\!!initinboundscheck}%
2044 \!initinboundscheck\ignorespaces}
2045 \inboundscheckoff
2046
2047 % ** The following code plots the current point only if it falls in the
2048 % ** current plotarea. It doesn't matter if the coordinate system has
2049 % ** changed since the plotarea was set up. However, shifts of the plot
2050 % ** are ignored (how the plotsymbol stands relative to its plot position is
2051 % ** unknown anyway).
2052 \def\!!plotifinbounds{%
2053 \ifdim \!xpos<\!checkleft
2054 \else
2055 \ifdim \!xpos>\!checkright
2056 \else
2057 \ifdim \!ypos<\!checkbot
2058 \else
2059 \ifdim \!ypos>\!checktop
2060 \else
2061 \!plot(\!xpos,\!ypos)
2062 \fi
2063 \fi
2064 \fi
2065 \fi}
2066
2067
2068 \def\!!initinboundscheck{%
2069 \!checkleft=\!arealloc \advance\!checkleft by \!xorigin
2070 \!checkright=\!arearloc \advance\!checkright by \!xorigin
2071 \!checkbot=\!areabloc \advance\!checkbot by \!yorigin
2072 \!checktop=\!areatloc \advance\!checktop by \!yorigin}
2073
2074
2075 % *********************************
2076 % *** LOGTEN (Log_10 function) ***
2077 % *********************************
2078 %
2079 % ** \!logten{X}
2080 % ** Calculates log_10 of X. X and LOG10(X) are in fixed point notation.
2081 % ** X must be positive; it may have an optional `+' sign; any number
2082 % ** of digits may be specified for X. The absolute error in LOG10(X) is
2083 % ** less than .0001 (probably < .00006). That's about as good as you
2084 % ** hope for, since TEX only operates to 5 figures after the decimal
2085 % ** point anyway.
2086
2087 % \!rootten=3.162278pt **** These are values are set in ALLOCATIONS
2088 % \!tenAe=2.543275pt (=A5)
2089 % \!tenAc=2.773839pt (=A3)
2090 % \!tenAa=8.690286pt (=A1)
2091
2092 \def\!logten#1#2{%
2093 \expandafter\!!logten#1\!nil
2094 \!removept\!dimenF#2%
2095 \ignorespaces}
2096
2097 \def\!!logten#1#2\!nil{%
2098 \if -#1%
2099 \!dimenF=\!zpt
2100 \def\!next{\ignorespaces}%
2101 \else
2102 \if +#1%
2103 \def\!next{\!!logten#2\!nil}%
2104 \else
2105 \if .#1%
2106 \def\!next{\!!logten0.#2\!nil}%
2107 \else
2108 \def\!next{\!!!logten#1#2..\!nil}%
2109 \fi
2110 \fi
2111 \fi
2112 \!next}
2113
2114 \def\!!!logten#1#2.#3.#4\!nil{%
2115 \!dimenF=1pt % ** DimF holds log10 original argument
2116 \if 0#1%
2117 \!!logshift#3pt % ** Argument < 1
2118 \else % ** Argument >= 1
2119 \!logshift#2/% ** Shift decimal pt as many places
2120 \!dimenE=#1.#2#3pt % ** as there are figures in #2
2121 \fi % ** Now dimE holds revised X want log10 of
2122 \ifdim \!dimenE<\!rootten% ** Transform X to XX between sqrt(10)
2123 \multiply \!dimenE 10 % ** and 10*sqrt(10)
2124 \advance \!dimenF -1pt
2125 \fi
2126 \!dimenG=\!dimenE% ** dimG <- (XX + 10)
2127 \advance\!dimenG 10pt
2128 \advance\!dimenE -10pt % ** dimE <- (XX - 10)
2129 \multiply\!dimenE 10 % ** dimE = 10*(XX-10)
2130 \!divide\!dimenE\!dimenG\!dimenE% ** Now dimE=10t==10*(XX-10)/(XX+10)
2131 \!removept\!dimenE\!t% ** !t=10t, with "pt" removed
2132 \!dimenG=\!t\!dimenE% ** dimG=100t**2
2133 \!removept\!dimenG\!tt% ** !tt=100t**2, with "pt" removed
2134 \!dimenH=\!tt\!tenAe% ** dimH=10*a5*(10t)**2 /100
2135 \divide\!dimenH 100
2136 \advance\!dimenH \!tenAc% ** ditto + 10*a3
2137 \!dimenH=\!tt\!dimenH% ** ditto * (10t)**2 /100
2138 \divide\!dimenH 100
2139 \advance\!dimenH \!tenAa% ** ditto + 10*a1
2140 \!dimenH=\!t\!dimenH% ** ditto * 10t / 100
2141 \divide\!dimenH 100 % ** Now dimH = log10(XX) - 1
2142 \advance\!dimenF \!dimenH}% ** dimF = log10(X)
2143
2144 \def\!logshift#1{%
2145 \if #1/%
2146 \def\!next{\ignorespaces}%
2147 \else
2148 \advance\!dimenF 1pt
2149 \def\!next{\!logshift}%
2150 \fi
2151 \!next}
2152
2153 \def\!!logshift#1{%
2154 \advance\!dimenF -1pt
2155 \if 0#1%
2156 \def\!next{\!!logshift}%
2157 \else
2158 \if p#1%
2159 \!dimenF=1pt
2160 \def\!next{\!dimenE=1p}%
2161 \else
2162 \def\!next{\!dimenE=#1.}%
2163 \fi
2164 \fi
2165 \!next}
2166
2167
2168 % ***********************************************************
2169 % *** PICTURES (Basic setups for PiCtures; \put commands) ***
2170 % ***********************************************************
2171
2172 % ** User Commands:
2173 % ** \beginpicture
2174 % ** \endpicture
2175 % ** \endpicturesave <XREG,YREG>
2176 % ** \setcoordinatesystem units <XUNIT,YUNIT> point at XREF YREF
2177 % ** \put {OBJECT} [ORIENTATION] <XSHIFT,YSHIFT> at XCOORD YCOORD
2178 % ** \multiput {OJBECT} [ORIENTATION] <XSHIFT,YSHIFT>) at
2179 % ** XCOORD YCOORD
2180 % ** *NUMBER_OF_TIMES DXCOORD DYCOORD /
2181 % ** \accountingon
2182 % ** \accountingoff
2183 % ** \stack [ORIENTATION] <LEADING> {LIST OF ITEMS}
2184 % ** \lines [ORIENTATION] {LINES}
2185 % ** \Lines [ORIENTATION] {LINES}
2186 % ** \setdimensionmode
2187 % ** \setcoordinatemode
2188 % ** \Xdistance
2189 % ** \Ydistance
2190
2191 % ** Internal commands:
2192 % ** \!setputobject{OBJECT}{[ORIENTATION]<XSHIFT,YSHIFT>}
2193 % ** \!dimenput{OBJECT}[ORIENTATION]<XSHIFT,YSHIFT>(XDIMEN,YDIMEN)
2194 % ** \!setdimenmode
2195 % ** \!setcoordmode
2196 % ** \!ifdimenmode
2197 % ** \!ifcoordmode
2198
2199
2200 % ** \beginpicture
2201 % ** \endpicture
2202 % ** \endpicturesave <XREG,YREG>
2203 % ** \beginpicture ... \endpicture creates an hbox. Objects are
2204 % ** placed in this box using the \put command and the like (see below).
2205 % ** The location of an object is specified in terms of coordinate system(s)
2206 % ** established by \setcoordinatesystem. Each coordinate system (there
2207 % ** might be just one) specifies the length of 1 horizontal unit, the length
2208 % ** of 1 vertical unit, and the coordinates of a "reference point". The
2209 % ** reference points of various coordinate systems will be in the same
2210 % ** physical location. The macros keep track of the size of the objects
2211 % ** and their locations. The resulting hbox is the smallest hbox which
2212 % ** encloses all the objects, and whose TEK reference point is the point
2213 % ** on the left edge of the box closest vertically to the PICTEX reference
2214 % ** point. Using \endpicturesave, you can (globally) save the distance TEK's
2215 % ** reference point is to the right (respectively, up from) PICTEX's
2216 % ** reference point in the dimension register \XREG (respectively \YREG).
2217 % ** You can then \put the picture OBJECT into a larger picture so that its
2218 % ** reference point is at (XCOORD,YCOORD) with the command
2219 % ** \put {picture OBJECT} [Bl] <\XREG, \YREG> at XCOORD YCOORD
2220
2221 % ** \beginpicture : See Subsection 1.1 of the manual.
2222 \def\beginpicture{%
2223 \setbox\!picbox=\hbox\bgroup%
2224 \!xleft=\maxdimen
2225 \!xright=-\maxdimen
2226 \!ybot=\maxdimen
2227 \!ytop=-\maxdimen}
2228
2229 % ** \endpicture : See Subsection 1.1 of the manual.
2230 \def\endpicture{%
2231 \ifdim\!xleft=\maxdimen% ** check if nothing was put in picbox
2232 \!xleft=\!zpt \!xright=\!zpt \!ybot=\!zpt \!ytop=\!zpt
2233 \fi
2234 \global\!Xleft=\!xleft \global\!Xright=\!xright
2235 \global\!Ybot=\!ybot \global\!Ytop=\!ytop
2236 \egroup%
2237 \ht\!picbox=\!Ytop \dp\!picbox=-\!Ybot
2238 \ifdim\!Ybot>\!zpt
2239 \else
2240 \ifdim\!Ytop<\!zpt
2241 \!Ybot=\!Ytop
2242 \else
2243 \!Ybot=\!zpt
2244 \fi
2245 \fi
2246 \hbox{\kern-\!Xleft\lower\!Ybot\box\!picbox\kern\!Xright}}
2247
2248 % ** \endpicturesave : See Subsection 8.4 of the manual.
2249 \def\endpicturesave <#1,#2>{%
2250 \endpicture \global #1=\!Xleft \global #2=\!Ybot \ignorespaces}
2251
2252
2253 % ** \setcoordinatesystem units <XUNIT,YUNIT>
2254 % ** point at XREF YREF
2255 % ** Each of `units <XUNIT,YUNIT>' and `point at XREF YREF'
2256 % ** are optional.
2257 % ** Unit lengths must be given in dimensions (e.g., <10pt,1in>).
2258 % ** Default unit lengths are 1pt, 1pt, or previous unit lengths.
2259 % ** Reference point is specified in current units (e.g., 3 5 ).
2260 % ** Default reference point is 0 0 , or previous reference point.
2261 % ** Unit lengths and reference points obey TEX's scoping rules.
2262 % ** See Subsection 1.2 of the manual.
2263 \def\setcoordinatesystem{%
2264 \!ifnextchar{u}{\!getlengths }
2265 {\!getlengths units <\!xunit,\!yunit>}}
2266 \def\!getlengths units <#1,#2>{%
2267 \!xunit=#1\relax
2268 \!yunit=#2\relax
2269 \!ifcoordmode
2270 \let\!SCnext=\!SCccheckforRP
2271 \else
2272 \let\!SCnext=\!SCdcheckforRP
2273 \fi
2274 \!SCnext}
2275 \def\!SCccheckforRP{%
2276 \!ifnextchar{p}{\!cgetreference }
2277 {\!cgetreference point at {\!xref} {\!yref} }}
2278 \def\!cgetreference point at #1 #2 {%
2279 \edef\!xref{#1}\edef\!yref{#2}%
2280 \!xorigin=\!xref\!xunit \!yorigin=\!yref\!yunit
2281 \!initinboundscheck % ** See linear.tex
2282 \ignorespaces}
2283 \def\!SCdcheckforRP{%
2284 \!ifnextchar{p}{\!dgetreference}%
2285 {\ignorespaces}}
2286 \def\!dgetreference point at #1 #2 {%
2287 \!xorigin=#1\relax \!yorigin=#2\relax
2288 \ignorespaces}
2289
2290
2291 % ** \put {OBJECT} [XY] <XDIMEN,YDIMEN> at (XCOORD,YCOORD)
2292 % ** `[XY]' and `<XDIMEN,YDIMEN>' are optional.
2293 % ** First OBJECT is placed in an hbox (the "objectbox") and then a
2294 % ** "reference point" is assigned to the objectbox as follows:
2295 % ** [1] first, the reference point is taken to be the center of the box;
2296 % ** [2] next, centering is overridden by the specifications
2297 % ** X=l -- reference point along the left edge of the objectbox
2298 % ** X=r -- reference point along the right edge of the objectbox
2299 % ** Y=b -- reference point along the bottom edge of the objectbox
2300 % ** Y=B -- reference point along the Baseline of the objectbox
2301 % ** Y=t -- reference point along the top edge of the objectbox;
2302 % ** [3] finally the reference point is shifted left by XDIMEN, down
2303 % ** by YDIMEN (both default to 0pt).
2304 % ** The objectbox is placed within PICBOX with its reference point at
2305 % ** (XCOORD,YCOORD).
2306 % ** If OBJECT is a saved box, say box0, you have to write
2307 % ** \put{\box0}... or \put{\copy0}...
2308 % ** The objectbox is void after the put.
2309 % ** See Subsection 2.1 of the manual.
2310 \long\def\put#1#2 at #3 #4 {%
2311 \!setputobject{#1}{#2}%
2312 \!xpos=\!M{#3}\!xunit \!ypos=\!M{#4}\!yunit
2313 \!rotateaboutpivot\!xpos\!ypos%
2314 \advance\!xpos -\!xorigin \advance\!xpos -\!xshift
2315 \advance\!ypos -\!yorigin \advance\!ypos -\!yshift
2316 \kern\!xpos\raise\!ypos\box\!putobject\kern-\!xpos%
2317 \!doaccounting\ignorespaces}
2318
2319 % ** \multiput etc. Like \put. The objectbox is not voided until the
2320 % ** termininating /, and is placed repeatedly with:
2321 % ** XCOORD YCOORD -- the objectbox is put down with its reference point
2322 % ** at (XCOORD,YCOORD);
2323 % ** *N DXCOORD DYCOORD -- each of N times the current
2324 % ** (xcoord,ycoord) is incremented by (DXCOORD,DYCOORD), and the
2325 % ** objectbox is put down with its reference point at (xcoord,ycoord)
2326 % ** (This specification has to follow an XCOORD YCOORD pair)
2327 % ** See Subsection 2.2 of the manual.
2328 \long\def\multiput #1#2 at {%
2329 \!setputobject{#1}{#2}%
2330 \!ifnextchar"{\!putfromfile}{\!multiput}}
2331 \def\!putfromfile"#1"{%
2332 \expandafter\!multiput \input #1 /}
2333 \def\!multiput{%
2334 \futurelet\!nextchar\!!multiput}
2335 \def\!!multiput{%
2336 \if *\!nextchar
2337 \def\!nextput{\!alsoby}%
2338 \else
2339 \if /\!nextchar
2340 \def\!nextput{\!finishmultiput}%
2341 \else
2342 \def\!nextput{\!alsoat}%
2343 \fi
2344 \fi
2345 \!nextput}
2346 \def\!finishmultiput/{%
2347 \setbox\!putobject=\hbox{}%
2348 \ignorespaces}
2349
2350 % ** \!alsoat XCOORD YCOORD
2351 % ** The objectbox is put down with reference point at XCOORD,YCOORD
2352 \def\!alsoat#1 #2 {%
2353 \!xpos=\!M{#1}\!xunit \!ypos=\!M{#2}\!yunit
2354 \!rotateaboutpivot\!xpos\!ypos%
2355 \advance\!xpos -\!xorigin \advance\!xpos -\!xshift
2356 \advance\!ypos -\!yorigin \advance\!ypos -\!yshift
2357 \kern\!xpos\raise\!ypos\copy\!putobject\kern-\!xpos%
2358 \!doaccounting
2359 \!multiput}
2360
2361 % ** \!alsoby*N DXCOORD DYCOORD
2362 % ** N times, the current (XCOORD,YCOORD) is advanced by (DXCOORD,DYCOORD),
2363 % ** and the current (shifted, oriented) OBJECT is put down.
2364 \def\!alsoby*#1 #2 #3 {%
2365 \!dxpos=\!M{#2}\!xunit \!dypos=\!M{#3}\!yunit
2366 \!rotateonly\!dxpos\!dypos
2367 \!ntemp=#1%
2368 \!!loop\ifnum\!ntemp>0
2369 \advance\!xpos by \!dxpos \advance\!ypos by \!dypos
2370 \kern\!xpos\raise\!ypos\copy\!putobject\kern-\!xpos%
2371 \advance\!ntemp by -1
2372 \repeat
2373 \!doaccounting
2374 \!multiput}
2375
2376 % ** \accountingoff : Suspends PiCTeX's accounting of the aggregate
2377 % ** size of the picture box.
2378 % ** \accounting on : Reinstates accounting.
2379 % ** See Subsection 8.2 of the manual.
2380 \def\accountingon{\def\!doaccounting{\!!doaccounting}\ignorespaces}
2381 \def\accountingoff{\def\!doaccounting{}\ignorespaces}
2382 \accountingon
2383 \def\!!doaccounting{%
2384 \!xtemp=\!xpos
2385 \!ytemp=\!ypos
2386 \ifdim\!xtemp<\!xleft
2387 \!xleft=\!xtemp
2388 \fi
2389 \advance\!xtemp by \!wd
2390 \ifdim\!xright<\!xtemp
2391 \!xright=\!xtemp
2392 \fi
2393 \advance\!ytemp by -\!dp
2394 \ifdim\!ytemp<\!ybot
2395 \!ybot=\!ytemp
2396 \fi
2397 \advance\!ytemp by \!dp
2398 \advance\!ytemp by \!ht
2399 \ifdim\!ytemp>\!ytop
2400 \!ytop=\!ytemp
2401 \fi}
2402
2403 \long\def\!setputobject#1#2{%
2404 \setbox\!putobject=\hbox{#1}%
2405 \!ht=\ht\!putobject \!dp=\dp\!putobject \!wd=\wd\!putobject
2406 \wd\!putobject=\!zpt
2407 \!xshift=.5\!wd \!yshift=.5\!ht \advance\!yshift by -.5\!dp
2408 \edef\!putorientation{#2}%
2409 \expandafter\!SPOreadA\!putorientation[]\!nil%
2410 \expandafter\!SPOreadB\!putorientation<\!zpt,\!zpt>\!nil\ignorespaces}
2411
2412 \def\!SPOreadA#1[#2]#3\!nil{\!etfor\!orientation:=#2\do\!SPOreviseshift}
2413
2414 \def\!SPOreadB#1<#2,#3>#4\!nil{\advance\!xshift by -#2\advance\!yshift by -#3}
2415
2416 \def\!SPOreviseshift{%
2417 \if l\!orientation
2418 \!xshift=\!zpt
2419 \else
2420 \if r\!orientation
2421 \!xshift=\!wd
2422 \else
2423 \if b\!orientation
2424 \!yshift=-\!dp
2425 \else
2426 \if B\!orientation
2427 \!yshift=\!zpt
2428 \else
2429 \if t\!orientation
2430 \!yshift=\!ht
2431 \fi
2432 \fi
2433 \fi
2434 \fi
2435 \fi}
2436
2437
2438 % ** \!dimenput{OBJECT} <XDIMEN,YDIMEN> [XY] (XLOC,YLOC)
2439 % ** This is an internal put routine, similar to \put, except that
2440 % ** XLOC=distance right from reference point, YLOC=distance up from
2441 % ** reference point. XLOC and YLOC are dimensions, so this routine
2442 % ** is completely independent of the current coordinate system.
2443 % ** This routine does NOT do ROTATIONS.
2444 \long\def\!dimenput#1#2(#3,#4){%
2445 \!setputobject{#1}{#2}%
2446 \!xpos=#3\advance\!xpos by -\!xshift
2447 \!ypos=#4\advance\!ypos by -\!yshift
2448 \kern\!xpos\raise\!ypos\box\!putobject\kern-\!xpos%
2449 \!doaccounting\ignorespaces}
2450
2451
2452 % ** The following macros permit the picture drawing routines to be used
2453 % ** either in the default "coordinate mode", or in "dimension mode".
2454 % ** In coordinate mode \!M(1.5,\!xunit) expands to 1.5\!xunit
2455 % ** In dimension mode \!M(1.5pt,\!xunit) expands to 1.5pt
2456 % ** Dimension mode is useful in coding macros.
2457 % ** Any special purpose picture macro that sets dimension mode should
2458 % ** reset coordinate mode before completion.
2459 % ** See Subsection 9.2 of the manual.
2460 \def\!setdimenmode{%
2461 \let\!M=\!M!!\ignorespaces}
2462 \def\!setcoordmode{%
2463 \let\!M=\!M!\ignorespaces}
2464 \def\!ifcoordmode{%
2465 \ifx \!M \!M!}
2466 \def\!ifdimenmode{%
2467 \ifx \!M \!M!!}
2468 \def\!M!#1#2{#1#2}
2469 \def\!M!!#1#2{#1}
2470 \!setcoordmode
2471 \let\setdimensionmode=\!setdimenmode
2472 \let\setcoordinatemode=\!setcoordmode
2473
2474 % ** \Xdistance{XCOORD}, \Ydistance{YCOORD} are the horizontal and
2475 % ** vertical distances from the origin (0,0) to the point
2476 % ** (XCOORD,YCOORD) in the current coordinate system.
2477 % ** See Subsection 9.2 of the manual.
2478 \def\Xdistance#1{%
2479 \!M{#1}\!xunit
2480 \ignorespaces}
2481 \def\Ydistance#1{%
2482 \!M{#1}\!yunit
2483 \ignorespaces}
2484
2485 % ** The following macros -- \stack, \line, and \Lines -- are useful for
2486 % ** annotating PiCtures. They can be used outside the \beginpicture ...
2487 % ** \endpicture environment.
2488
2489 % ** \stack [POSITIONING] <LEADING> {VALUESLIST}
2490 % ** Builds a vertical stack of the values in VALUESLIST. Values in
2491 % ** VALUESLIST are separated by commas. In the resulting stack, values are
2492 % ** centered by default, and positioned flush left (right) if
2493 % ** POSITIONING = l (r). Values are separated vertically by LEADING,
2494 % ** which defaults to \stackleading.
2495 % ** See Subsection 2.3 of the manual.
2496 \def\stack{%
2497 \!ifnextchar[{\!stack}{\!stack[c]}}
2498 \def\!stack[#1]{%
2499 \let\!lglue=\hfill \let\!rglue=\hfill
2500 \expandafter\let\csname !#1glue\endcsname=\relax
2501 \!ifnextchar<{\!!stack}{\!!stack<\stackleading>}}
2502 \def\!!stack<#1>#2{%
2503 \vbox{\def\!valueslist{}\!ecfor\!value:=#2\do{%
2504 \expandafter\!rightappend\!value\withCS{\\}\to\!valueslist}%
2505 \!lop\!valueslist\to\!value
2506 \let\\=\cr\lineskiplimit=\maxdimen\lineskip=#1%
2507 \baselineskip=-1000pt\halign{\!lglue##\!rglue\cr \!value\!valueslist\cr}}%
2508 \ignorespaces}
2509
2510 % ** \lines [POSITIONING] {LINES}
2511 % ** Builds a vertical array of the lines in LINES. Each line in LINES
2512 % ** is terminated by a \cr. In the resulting array, lines are
2513 % ** centered by default, and positioned flush left (right) if
2514 % ** POSITIONING = l (r). The lines in the array are subject to TeX's
2515 % ** usual spacing rules: in particular the baselines are ordinarily an equal
2516 % ** distance apart. The baseline of the array is the baseline of the
2517 % ** the bottom line.
2518 % ** See Subsection 2.3 of the manual.
2519 \def\lines{%
2520 \!ifnextchar[{\!lines}{\!lines[c]}}
2521 \def\!lines[#1]#2{%
2522 \let\!lglue=\hfill \let\!rglue=\hfill
2523 \expandafter\let\csname !#1glue\endcsname=\relax
2524 \vbox{\halign{\!lglue##\!rglue\cr #2\crcr}}%
2525 \ignorespaces}
2526
2527 % ** \Lines [POSITIONING] {LINES}
2528 % ** Like \lines, but the baseline of the array is the baseline of the
2529 % ** top line. See Subsection 2.3 of the manual.
2530 \def\Lines{%
2531 \!ifnextchar[{\!Lines}{\!Lines[c]}}
2532 \def\!Lines[#1]#2{%
2533 \let\!lglue=\hfill \let\!rglue=\hfill
2534 \expandafter\let\csname !#1glue\endcsname=\relax
2535 \vtop{\halign{\!lglue##\!rglue\cr #2\crcr}}%
2536 \ignorespaces}
2537
2538
2539 % *********************************************
2540 % *** PLOTTING (Things to do with plotting) ***
2541 % *********************************************
2542
2543 % ** User commands
2544 % ** \setplotsymbol ({PLOTSYMBOL} [ORIENTATION] <XSHIFT,YSHIFT>)
2545 % ** \savelinesandcurves on "FILE_NAME"
2546 % ** \dontsavelinesandcurves
2547 % ** \writesavefile {MESSAGE}
2548 % ** \replot {FILE_NAME}
2549
2550 % ** Internal command
2551 % ** \!plot(XDIMEN,YDIMEN)
2552
2553 % ** \setplotsymbol ({PLOTSYMBOL} [ ] < , >)
2554 % ** Save PLOTSYMBOL away in an hbox for use with curve plotting routines
2555 % ** See Subsection 5.2 of the manual.
2556 \def\setplotsymbol(#1#2){%
2557 \!setputobject{#1}{#2}
2558 \setbox\!plotsymbol=\box\!putobject%
2559 \!plotsymbolxshift=\!xshift
2560 \!plotsymbolyshift=\!yshift
2561 \ignorespaces}
2562
2563 \font\fiverm=cmr5
2564 \setplotsymbol({\fiverm .})% ** initialize plotsymbol
2565
2566
2567 % ** \!plot is either \!!plot (when no lines and curves are being saved) or
2568 % ** \!!!plot (when lines and curves are being saved)
2569
2570 % ** \!!plot(XDIMEN,YDIMEN)
2571 % ** Places the current plotsymbol a horizontal distance=XDIMEN-xorigin
2572 % ** and a vertical distance=YDIMEN-yorigin from the current
2573 % ** reference point.
2574 \def\!!plot(#1,#2){%
2575 \!dimenA=-\!plotxorigin \advance \!dimenA by #1% ** over
2576 \!dimenB=-\!plotyorigin \advance \!dimenB by #2% ** up
2577 \kern\!dimenA\raise\!dimenB\copy\!plotsymbol\kern-\!dimenA%
2578 \ignorespaces}
2579
2580 % ** \!!!plot(XDIMEN,YDIMEN)
2581 % ** Like \!!plot, but also saves the plot location in units of
2582 % ** scaled point, on file `replotfile'
2583 \def\!!!plot(#1,#2){%
2584 \!dimenA=-\!plotxorigin \advance \!dimenA by #1% ** over
2585 \!dimenB=-\!plotyorigin \advance \!dimenB by #2% ** up
2586 \kern\!dimenA\raise\!dimenB\copy\!plotsymbol\kern-\!dimenA%
2587 \!countE=\!dimenA
2588 \!countF=\!dimenB
2589 \immediate\write\!replotfile{\the\!countE,\the\!countF.}%
2590 \ignorespaces}
2591
2592
2593 % ** \savelinesandcurves on "FILE_NAME"
2594 % ** Switch to save locations used for plotting lines and curves
2595 % ** (No advantage in saving locations for solid lines; however
2596 % ** replotting curve locations speeds things up by a factor of about 4.
2597 % ** \dontsavelinesandcurves
2598 % ** Terminates \savelinesandcurves. The default.
2599 % ** See Subsection 5.6 of the manual.
2600 \def\savelinesandcurves on "#1" {%
2601 \immediate\closeout\!replotfile
2602 \immediate\openout\!replotfile=#1%
2603 \let\!plot=\!!!plot}
2604
2605 \def\dontsavelinesandcurves {%
2606 \let\!plot=\!!plot}
2607 \dontsavelinesandcurves
2608
2609 % ** \writesavefile {MESSAGE}
2610 % ** The message is preceded by a "%", so that it won't interfere
2611 % ** with replotting.
2612 % ** See Subsection 5.6 of the manual.
2613 {\catcode`\%=11\xdef\!Commentsignal{%}}
2614 \def\writesavefile#1 {%
2615 \immediate\write\!replotfile{\!Commentsignal #1}%
2616 \ignorespaces}
2617
2618 % ** \replot "FILE_NAME"
2619 % ** Replots the locations saved earlier under \savelinesandcurves
2620 % ** on "FILE_NAME"
2621 % ** See Subsection 5.6 of the manual.
2622 \def\replot"#1" {%
2623 \expandafter\!replot\input #1 /}
2624 \def\!replot#1,#2. {%
2625 \!dimenA=#1sp
2626 \kern\!dimenA\raise#2sp\copy\!plotsymbol\kern-\!dimenA
2627 \futurelet\!nextchar\!!replot}
2628 \def\!!replot{%
2629 \if /\!nextchar
2630 \def\!next{\!finish}%
2631 \else
2632 \def\!next{\!replot}%
2633 \fi
2634 \!next}
2635 % **************************************************
2636 % *** PYTHAGORAS (Euclidean distance function) ***
2637 % **************************************************
2638
2639 % ** User command:
2640 % ** \placehypotenuse for <dimension1> and <dimension2> in <register>
2641
2642 % ** Internal command:
2643 % ** \!Pythag{X}{Y}{Z}
2644 % ** Input X,Y are dimensions, or dimension registers.
2645 % ** Output Z == sqrt(X**2+Y**2) must be a dimension register.
2646 % ** Assumes that |X|+|Y| < 2048pt (about 28in).
2647
2648 % ** Without loss of generality, suppose x>0, y>0. Put s = x+y,
2649 % ** z = sqrt(x**2+y**2). Then z = s*f, where f = sqrt(t**2 + (1-t)**2)
2650 % ** = sqrt((1+tau**2)/2), where t = x/s and tau = 2(t-1/2) .
2651
2652 % ** Uses the \!divide macro (which uses registers \!dimenA--\!dimenD.
2653 % ** Uses the \!removept macro (e.g., 123.45pt --> 123.45)
2654 % ** Uses registers \!dimenE--\!dimenI.
2655 \def\!Pythag#1#2#3{%
2656 \!dimenE=#1\relax
2657 \ifdim\!dimenE<\!zpt
2658 \!dimenE=-\!dimenE
2659 \fi% ** dimE = |x|
2660 \!dimenF=#2\relax
2661 \ifdim\!dimenF<\!zpt
2662 \!dimenF=-\!dimenF
2663 \fi% ** dimF = |y|
2664 \advance \!dimenF by \!dimenE% ** dimF = s = |x|+|y|
2665 \ifdim\!dimenF=\!zpt
2666 \!dimenG=\!zpt% ** dimG = z = sqrt(x**2+y**2)
2667 \else
2668 \!divide{8\!dimenE}\!dimenF\!dimenE% ** now dimE = 8t = (8|x|)/s
2669 \advance\!dimenE by -4pt% ** 8tau = (8t-4)*2
2670 \!dimenE=2\!dimenE% ** (tau = 2*t - 1)
2671 \!removept\!dimenE\!!t% ** 8tau, without "pt"
2672 \!dimenE=\!!t\!dimenE% ** (8tau)**2, in pts
2673 \advance\!dimenE by 64pt% ** u = [64 + (8tau)**2]/2
2674 \divide \!dimenE by 2% ** [u = (8f)**2]
2675 \!dimenH=7pt% ** initial guess g at sqrt(u)
2676 \!!Pythag\!!Pythag\!!Pythag% ** 3 iterations give sqrt(u)
2677 \!removept\!dimenH\!!t% ** 8f=sqrt(u), without "pt"
2678 \!dimenG=\!!t\!dimenF% ** z = (8f)*s/8
2679 \divide\!dimenG by 8
2680 \fi
2681 #3=\!dimenG
2682 \ignorespaces}
2683
2684 \def\!!Pythag{% ** Newton-Raphson for sqrt
2685 \!divide\!dimenE\!dimenH\!dimenI% ** v = u/g
2686 \advance\!dimenH by \!dimenI% ** g <-- (g + u/g)/2
2687 \divide\!dimenH by 2}
2688
2689 % ** \placehypotenuse for <XI> and <ETA> in <ZETA>
2690 % ** See Subsection 9.3 of the manual.
2691 \def\placehypotenuse for <#1> and <#2> in <#3> {%
2692 \!Pythag{#1}{#2}{#3}}
2693
2694
2695 % **********************************************
2696 % *** QUADRATIC ARC (Draws a quadratic arc) ***
2697 % **********************************************
2698
2699 % ** Internal command
2700 % ** \!qjoin (XCOORD1,YCOORD1) (XCOORD2,YCOORD2)
2701
2702 % ** \!qjoin (XCOORD1,YCOORD1) (XCOORD2,YCOORD2)
2703 % ** Draws an arc starting at the (last) point specified by the most recent
2704 % ** \!qjoin, or \!ljoin, or \!start and passing through (X_1,Y_1), (X_2,Y_2).
2705 % ** Uses quadratic interpolation in both x and y:
2706 % ** x(t), 0 <= t <= 1, interpolates x_0, x_1, x_2 at t=0, .5, 1
2707 % ** y(t), 0 <= t <= 1, interpolates y_0, y_1, y_2 at t=0, .5, 1
2708
2709 \def\!qjoin (#1,#2) (#3,#4){%
2710 \advance\!intervalno by 1
2711 \!ifcoordmode
2712 \edef\!xmidpt{#1}\edef\!ymidpt{#2}%
2713 \else
2714 \!dimenA=#1\relax \edef\!xmidpt{\the\!dimenA}%
2715 \!dimenA=#2\relax \edef\!ymidpt{\the\!dimenA}%
2716 \fi
2717 \!xM=\!M{#1}\!xunit \!yM=\!M{#2}\!yunit \!rotateaboutpivot\!xM\!yM
2718 \!xE=\!M{#3}\!xunit \!yE=\!M{#4}\!yunit \!rotateaboutpivot\!xE\!yE
2719 %
2720 % ** Find coefficients for x(t)=a_x + b_x*t + c_x*t**2
2721 \!dimenA=\!xM \advance \!dimenA by -\!xS% ** dimA = I = xM - xS
2722 \!dimenB=\!xE \advance \!dimenB by -\!xM% ** dimB = II = xE-xM
2723 \!xB=3\!dimenA \advance \!xB by -\!dimenB% ** b=3I-II
2724 \!xC=2\!dimenB \advance \!xC by -2\!dimenA% ** c=2(II-I)
2725 %
2726 % ** Find coefficients for y(t)=y_x + b_y*t + c_y*t**2
2727 \!dimenA=\!yM \advance \!dimenA by -\!yS%
2728 \!dimenB=\!yE \advance \!dimenB by -\!yM%
2729 \!yB=3\!dimenA \advance \!yB by -\!dimenB%
2730 \!yC=2\!dimenB \advance \!yC by -2\!dimenA%
2731 %
2732 % ** Use Simpson's rule to calculate arc length over [0,1/2]:
2733 % ** arc length = 1/2[1/6 f(0) + 4/6 f(1/4) + 1/6 f(1/2)]
2734 % ** with f(t) = sqrt(x'(t)**2 + y'(t)**2).
2735 \!xprime=\!xB \!yprime=\!yB% ** x'(t) = b + 2ct
2736 \!dxprime=.5\!xC \!dyprime=.5\!yC% ** dt=1/4 ==> dx'(t) = c/2
2737 \!getf \!midarclength=\!dimenA
2738 \!getf \advance \!midarclength by 4\!dimenA
2739 \!getf \advance \!midarclength by \!dimenA
2740 \divide \!midarclength by 12
2741 %
2742 % ** Get arc length over [0,1].
2743 \!arclength=\!dimenA
2744 \!getf \advance \!arclength by 4\!dimenA
2745 \!getf \advance \!arclength by \!dimenA
2746 \divide \!arclength by 12% ** Now have arc length over [1/2,1]
2747 \advance \!arclength by \!midarclength
2748 \global\advance \totalarclength by \!arclength
2749 %
2750 %
2751 % ** Check to see if there's anything to plot in this interval
2752 \ifdim\!distacross>\!arclength
2753 \advance \!distacross by -\!arclength% ** nothing
2754 %
2755 \else
2756 \!initinverseinterp% ** initialize for inverse interpolation on arc length
2757 \loop\ifdim\!distacross<\!arclength% ** loop over points on arc
2758 \!inverseinterp% ** find t such that arc length[0,t] = distacross,
2759 % ** using inverse quadratic interpolation
2760 % ** now evaluate x(t)=(c*t + b)*t + a
2761 \!xpos=\!t\!xC \advance\!xpos by \!xB
2762 \!xpos=\!t\!xpos \advance \!xpos by \!xS
2763 % ** evaluate y(t)
2764 \!ypos=\!t\!yC \advance\!ypos by \!yB
2765 \!ypos=\!t\!ypos \advance \!ypos by \!yS
2766 \!plotifinbounds% ** plot point if in bounds
2767 \advance\!distacross \plotsymbolspacing%** advance arc length for next pt
2768 \!advancedashing% ** see "linear"
2769 \repeat
2770 %
2771 \advance \!distacross by -\!arclength% ** prepare for next interval
2772 \fi
2773 %
2774 \!xS=\!xE% ** shift ending points to starting points
2775 \!yS=\!yE
2776 \ignorespaces}
2777
2778
2779 % ** \!getf -- Calculates sqrt(x'(t)**2 + y'(t)**2) and advances
2780 % ** x'(t) and y'(t)
2781 \def\!getf{\!Pythag\!xprime\!yprime\!dimenA%
2782 \advance\!xprime by \!dxprime
2783 \advance\!yprime by \!dyprime}
2784
2785
2786 % ** \!initinverseinterp -- initializes for inverse quadratic interpolation
2787 % ** of arc length provided 1/3 < midarclength/arclength < 2/3; otherwise
2788 % ** initializes for inverse linear interpolation.
2789 \def\!initinverseinterp{%
2790 \ifdim\!arclength>\!zpt
2791 \!divide{8\!midarclength}\!arclength\!dimenE% ** dimE=8w=8r/s, where r
2792 % ** = midarclength, s=arclength
2793 % ** Test for w out of range: w<1/3 or w>2/3
2794 \ifdim\!dimenE<\!wmin \!setinverselinear
2795 \else
2796 \ifdim\!dimenE>\!wmax \!setinverselinear
2797 \else% ** w in range: initialize
2798 \def\!inverseinterp{\!inversequad}\ignorespaces
2799 %
2800 % ** Calculate the coefficients \!beta and \!gamma of the quadratic
2801 % ** t = \!beta*v + \!gamma*v**2
2802 % ** taking the values t=0, 1/2, 1 at v=0, w==r/s, 1 respectively:
2803 % ** \!beta = (1/2 - w**2)/[w(1-w)]
2804 % ** \!gamma = 1 - beta.
2805 %
2806 \!removept\!dimenE\!Ew% ** 8w, without "pt"
2807 \!dimenF=-\!Ew\!dimenE% ** -(8w)**2
2808 \advance\!dimenF by 32pt% ** 32 - (8w)**2
2809 \!dimenG=8pt
2810 \advance\!dimenG by -\!dimenE% ** 8 - 8w
2811 \!dimenG=\!Ew\!dimenG% ** (8w)*(8-8w)
2812 \!divide\!dimenF\!dimenG\!beta% ** beta = (32-(8w)**2)/(8w(8-8w))
2813 % ** = (1/2 - w**2)/(w(1-w))
2814 \!gamma=1pt
2815 \advance \!gamma by -\!beta% ** gamma = 1-beta
2816 \fi% ** end of the \ifdim\!dimenE>\!wmax
2817 \fi% ** end of the \ifdim\!dimenE<\!wmin
2818 \fi% ** end of the \ifdim\!arclength>\!zpt
2819 \ignorespaces}
2820
2821
2822 % ** For 0 <= t <= 1, let AL(t) = arclength[0,t]/arclength[0,1]; note
2823 % ** AL(0)=0, AL(1/2)=midarclength/arclength, AL(1)=1. This routine
2824 % ** calculates an approximation to AL^{-1}(distance across/arclength),
2825 % ** using the assumption that AL^{-1} is quadratic. Specifically,
2826 % ** it finds t such that
2827 % ** AL^{-1}(v) =. t = v*(\!beta + \!gamma*v)
2828 % ** where \!beta and \!gamma are set by \!initinv, and where
2829 % ** v=distance across/arclength
2830 \def\!inversequad{%
2831 \!divide\!distacross\!arclength\!dimenG% ** dimG = v = distacross/arclength
2832 \!removept\!dimenG\!v% ** v, without "pt"
2833 \!dimenG=\!v\!gamma% ** gamma*v
2834 \advance\!dimenG by \!beta% ** beta + gamma*v
2835 \!dimenG=\!v\!dimenG% ** t = v*(beta + gamma*v)
2836 \!removept\!dimenG\!t}% ** t, without "pt"
2837
2838
2839 % ** When w <= 1/3 or w >= 2/3, the following routine writes (using
2840 % ** plain TEK's \wlog command) a warning message on the user's log file,
2841 % ** and initializes for inverse linear interpolation on arc length.
2842 \def\!setinverselinear{%
2843 \def\!inverseinterp{\!inverselinear}%
2844 \divide\!dimenE by 8 \!removept\!dimenE\!t
2845 \!countC=\!intervalno \multiply \!countC 2
2846 \!countB=\!countC \advance \!countB -1
2847 \!countA=\!countB \advance \!countA -1
2848 \wlog{\the\!countB th point (\!xmidpt,\!ymidpt) being plotted
2849 doesn't lie in the}%
2850 \wlog{ middle third of the arc between the \the\!countA th
2851 and \the\!countC th points:}%
2852 \wlog{ [arc length \the\!countA\space to \the\!countB]/[arc length
2853 \the \!countA\space to \the\!countC]=\!t.}%
2854 \ignorespaces}
2855
2856 % ** Inverse linear interpolation
2857 \def\!inverselinear{%
2858 \!divide\!distacross\!arclength\!dimenG
2859 \!removept\!dimenG\!t}
2860
2861
2862 % **************************************
2863 % ** ROTATIONS (Handles rotations) ***
2864 % **************************************
2865
2866 % ** User commands
2867 % ** \startrotation [by COS_OF_ANGLE SIN_OF_ANGLE] [about XPIVOT YPIVOT]
2868 % ** \stoprotation
2869
2870 % ** \startrotation [by COS_OF_ANGLE SIN_OF_ANGLE] [about XPIVOT YPIVOT]
2871 % ** Future (XCOORD,YCOORD)'s will be rotated about (XPIVOT,YPIVOT)
2872 % ** by the angle with the give COS and SIN. Both fields are optional.
2873 % ** [COS,SIN] defaults to previous value, or (1,0).
2874 % ** (XPIVOT,YPIVOT) defaults to previous value, or (0,0)
2875 % ** You can't change the coordinate system in the scope of a rotation.
2876 % ** See Subsection 9.1 of the manual.
2877 \def\startrotation{%
2878 \let\!rotateaboutpivot=\!!rotateaboutpivot
2879 \let\!rotateonly=\!!rotateonly
2880 \!ifnextchar{b}{\!getsincos }%
2881 {\!getsincos by {\!cosrotationangle} {\!sinrotationangle} }}
2882 \def\!getsincos by #1 #2 {%
2883 \edef\!cosrotationangle{#1}%
2884 \edef\!sinrotationangle{#2}%
2885 \!ifcoordmode
2886 \let\!ROnext=\!ccheckforpivot
2887 \else
2888 \let\!ROnext=\!dcheckforpivot
2889 \fi
2890 \!ROnext}
2891 \def\!ccheckforpivot{%
2892 \!ifnextchar{a}{\!cgetpivot}%
2893 {\!cgetpivot about {\!xpivotcoord} {\!ypivotcoord} }}
2894 \def\!cgetpivot about #1 #2 {%
2895 \edef\!xpivotcoord{#1}%
2896 \edef\!ypivotcoord{#2}%
2897 \!xpivot=#1\!xunit \!ypivot=#2\!yunit
2898 \ignorespaces}
2899 \def\!dcheckforpivot{%
2900 \!ifnextchar{a}{\!dgetpivot}{\ignorespaces}}
2901 \def\!dgetpivot about #1 #2 {%
2902 \!xpivot=#1\relax \!ypivot=#2\relax
2903 \ignorespaces}
2904
2905
2906 % ** Following terminates rotation.
2907 % ** See Subsection 9.1 of the manual.
2908 \def\stoprotation{%
2909 \let\!rotateaboutpivot=\!!!rotateaboutpivot
2910 \let\!rotateonly=\!!!rotateonly
2911 \ignorespaces}
2912
2913 % ** !!rotateaboutpivot{XREG}{YREG}
2914 % ** XREG <-- xpvt + cos(angle)*(XREG-xpvt) - sin(angle)*(YREG-ypvt)
2915 % ** YREG <-- ypvt + cos(angle)*(YREG-ypvt) + sin(angle)*(XREG-xpvt)
2916 % ** XREG,YREG are dimension registers. Can't be \!dimenA to \!dimenD
2917 \def\!!rotateaboutpivot#1#2{%
2918 \!dimenA=#1\relax \advance\!dimenA -\!xpivot
2919 \!dimenB=#2\relax \advance\!dimenB -\!ypivot
2920 \!dimenC=\!cosrotationangle\!dimenA
2921 \advance \!dimenC -\!sinrotationangle\!dimenB
2922 \!dimenD=\!cosrotationangle\!dimenB
2923 \advance \!dimenD \!sinrotationangle\!dimenA
2924 \advance\!dimenC \!xpivot \advance\!dimenD \!ypivot
2925 #1=\!dimenC #2=\!dimenD
2926 \ignorespaces}
2927
2928 % ** \!!rotateonly{XREG}{YREG}
2929 % ** Like \!!rotateaboutpivot, but with a pivot of (0,0)
2930 \def\!!rotateonly#1#2{%
2931 \!dimenA=#1\relax \!dimenB=#2\relax
2932 \!dimenC=\!cosrotationangle\!dimenA
2933 \advance \!dimenC -\!rotsign\!sinrotationangle\!dimenB
2934 \!dimenD=\!cosrotationangle\!dimenB
2935 \advance \!dimenD \!rotsign\!sinrotationangle\!dimenA
2936 #1=\!dimenC #2=\!dimenD
2937 \ignorespaces}
2938 \def\!rotsign{}
2939 \def\!!!rotateaboutpivot#1#2{\relax}
2940 \def\!!!rotateonly#1#2{\relax}
2941 \stoprotation
2942
2943 \def\!reverserotateonly#1#2{%
2944 \def\!rotsign{-}%
2945 \!rotateonly{#1}{#2}%
2946 \def\!rotsign{}%
2947 \ignorespaces}
2948
2949
2950 % **********************************
2951 % *** SHADING (Handles shading) ***
2952 % **********************************
2953
2954 % ** User commands
2955 % ** \setshadegrid [span <SPAN>] [point at XSHADE YSHADE]
2956 % ** \setshadesymbol [<LS, RS, BS, TS>] ({SHADESYMBOL}
2957 % ** <XDIMEN,YDIMEN> [ORIENTATION])
2958
2959 % ** Internal commands:
2960 % ** \!startvshade (xS,ybS,ytS)
2961 % ** \!starthshade (yS,xlS,xrS)
2962 % ** \!lshade [<LS,RS,BS,TS>]
2963 % ** ** when shading vertically:
2964 % ** [the region from (xS,ybS,ytS) to] (xE,ybE,ytE)
2965 % ** ** when shading horizontally:
2966 % ** [the region from (yS,xlS,xrS) to] (yE,xlE,xrE)
2967 % ** \!qshade [<LS,RS,BS,TS>]
2968 % ** ** when shading vertically:
2969 % ** [the region from (xS,ybS,ytS) to] (xM,ybM,ytM) (xE,ybE,ytE)
2970 % ** ** when shading horizontally:
2971 % ** [the region from (yS,xlS,xrS) to] (yM,xlM,xrM) (yE,xlE,xrE)
2972 % ** \!lattice{ANCHOR}{SPAN}{LOCATION}{INDEX}{LATTICE LOCATION}
2973 % ** \!override{NOMINAL DIMEN}{REPLACEMENT DIMEN}{DIMEN}
2974
2975
2976 % ** The shading routine can operate either in a "vertical mode" or a
2977 % ** "horizontal mode". In vertical mode, the region to be shaded is specified
2978 % ** in the form
2979 % ** {(x,y): xl <= x <= xr & yb(x) <= y <= yt(x)}
2980 % ** where yb and yt are functions of x. In horizontal mode, the region
2981 % ** is specified in the form
2982 % ** {(x,y): yb <= y <= yt & xl(y) <= x <= xr(y)}.
2983 % ** The functions yb and yt may be either both linear or both quadratic;
2984 % ** similarly for xl and xr. A region with say, piecewise quadratic bottom
2985 % ** and top boundaries, can be shaded by consecutive (vertical) \!qshades,
2986 % ** proceeding from left to right. Similarly, a region with piecewise
2987 % ** quadratic left and right boundaries can be shaded by consecutive
2988 % ** (horizontal) \!qshades, proceeding from bottom to top. More complex
2989 % ** regions can be shaded by partitioning them into appropriate subregions,
2990 % ** and shading those.
2991
2992 % ** Shading is accomplished by placing a user-selected shading symbol at
2993 % ** those points of a regular grid which fall within the region to be
2994 % ** shaded. This region can be "shrunk" so that a largish shading symbol
2995 % ** will not extend outside it. Shrinking is accomplished by specifying
2996 % ** shrinkages for the left, right, bottom, and top boundaries, in a manner
2997 % ** discussed further below.
2998
2999 % ** \shades and \!joins MUST NOT be intermingled. Finish drawing a curve
3000 % ** before starting to shade a region, and finish shading a region before
3001 % ** starting to draw a curve.
3002
3003
3004 % ** \setshadegrid [span <SPAN>] [point at XSHADE YSHADE]
3005 % ** The shading symbol is placed down on the points of a grid centered
3006 % ** at the coordinate point (XSHADE,YSHADE). The grid points are of the
3007 % ** form (j*SPAN,k*SPAN), with j+k even. SPAN is specified
3008 % ** as a dimension.
3009 % ** (XSHADE,YSHADE) defaults to previous (XSHADE,YSHADE) (or (0,0) if none)
3010 % ** SPAN defaults to previous span (or 5pt if none)
3011 % ** See Subsection 7.2 of the manual.
3012 \def\setshadegrid{%
3013 \!ifnextchar{s}{\!getspan }
3014 {\!getspan span <\!dshade>}}
3015 \def\!getspan span <#1>{%
3016 \!dshade=#1\relax
3017 \!ifcoordmode
3018 \let\!GRnext=\!GRccheckforAP
3019 \else
3020 \let\!GRnext=\!GRdcheckforAP
3021 \fi
3022 \!GRnext}
3023 \def\!GRccheckforAP{%
3024 \!ifnextchar{p}{\!cgetanchor }
3025 {\!cgetanchor point at {\!xshadesave} {\!yshadesave} }}
3026 \def\!cgetanchor point at #1 #2 {%
3027 \edef\!xshadesave{#1}\edef\!yshadesave{#2}%
3028 \!xshade=\!xshadesave\!xunit \!yshade=\!yshadesave\!yunit
3029 \ignorespaces}
3030 \def\!GRdcheckforAP{%
3031 \!ifnextchar{p}{\!dgetanchor}%
3032 {\ignorespaces}}
3033 \def\!dgetanchor point at #1 #2 {%
3034 \!xshade=#1\relax \!yshade=#2\relax
3035 \ignorespaces}
3036
3037 % ** \setshadesymbol [<LS, RS, BS, TS>] ({SHADESYMBOL}
3038 % ** <XDIMEN,YDIMEN> [ORIENTATION])
3039 % ** Saves SHADESYMBOL away in an hbox for use with shading routines.
3040 % ** A shade symbol will not be plotted if its plot position comes within
3041 % ** distance LS of the left boundary, RS of the right boundary, TS of the
3042 % ** top boundary, BS of the bottom boundary. These parameters have
3043 % ** default values that should work in most cases (see below).
3044 % ** To override a default value, specify the replacement value
3045 % ** in the appropriate subfield of the shrinkages field.
3046 % ** 0pt may be coded as "z" (without the quotes). To accept a
3047 % ** default value, leave the field empty. Thus
3048 % ** [,z,,5pt] sets LS=default, RS=0pt, BS=default, TS=5pt .
3049 % ** Skipping the shrinkages field accepts all the defaults.
3050 % ** See Subsection 7.1 of the manual.
3051 \def\setshadesymbol{%
3052 \!ifnextchar<{\!setshadesymbol}{\!setshadesymbol<,,,> }}
3053
3054 \def\!setshadesymbol <#1,#2,#3,#4> (#5#6){%
3055 % ** set the shadesymbol
3056 \!setputobject{#5}{#6}%
3057 \setbox\!shadesymbol=\box\!putobject%
3058 \!shadesymbolxshift=\!xshift \!shadesymbolyshift=\!yshift
3059 %
3060 % ** set the shrinkages
3061 \!dimenA=\!xshift \advance\!dimenA \!smidge% ** default LS = xshift - smidge
3062 \!override\!dimenA{#1}\!lshrinkage%
3063 \!dimenA=\!wd \advance \!dimenA -\!xshift% ** default RS = width - xshift
3064 \advance\!dimenA \!smidge% - smidge
3065 \!override\!dimenA{#2}\!rshrinkage
3066 \!dimenA=\!dp \advance \!dimenA \!yshift% ** default BS = depth + yshift
3067 \advance\!dimenA \!smidge% - smidge
3068 \!override\!dimenA{#3}\!bshrinkage
3069 \!dimenA=\!ht \advance \!dimenA -\!yshift% ** default TS = height - yshift
3070 \advance\!dimenA \!smidge% - smidge
3071 \!override\!dimenA{#4}\!tshrinkage
3072 \ignorespaces}
3073 \def\!smidge{-.2pt}%
3074
3075 % ** \!override{NOMINAL DIMEN}{REPLACEMENT DIMEN}{DIMEN}
3076 % ** Overrides the NOMINAL DIMEN by the REPLACEMENT DIMEN to produce DIMEN,
3077 % ** according to the following rules:
3078 % ** REPLACEMENT DIMEN empty: DIMEN <-- NOMINAL DIMEN
3079 % ** REPLACEMENT DIMEN z: DIMEN <-- 0pt
3080 % ** otherwise: DIMEN <-- REPLACEMENT DIMEN
3081 % ** DIMEN must be a dimension register
3082 \def\!override#1#2#3{%
3083 \edef\!!override{#2}%
3084 \ifx \!!override\empty
3085 #3=#1\relax
3086 \else
3087 \if z\!!override
3088 #3=\!zpt
3089 \else
3090 \ifx \!!override\!blankz
3091 #3=\!zpt
3092 \else
3093 #3=#2\relax
3094 \fi
3095 \fi
3096 \fi
3097 \ignorespaces}
3098 \def\!blankz{ z}
3099
3100 \setshadesymbol ({\fiverm .})% ** initialize plotsymbol
3101 % ** \fivesy ^^B is a small cross
3102
3103
3104 % ** \!startvshade [at] (xS,ybS,ytS)
3105 % ** Initiates vertical shading mode
3106 \def\!startvshade#1(#2,#3,#4){%
3107 \let\!!xunit=\!xunit%
3108 \let\!!yunit=\!yunit%
3109 \let\!!xshade=\!xshade%
3110 \let\!!yshade=\!yshade%
3111 \def\!getshrinkages{\!vgetshrinkages}%
3112 \let\!setshadelocation=\!vsetshadelocation%
3113 \!xS=\!M{#2}\!!xunit
3114 \!ybS=\!M{#3}\!!yunit
3115 \!ytS=\!M{#4}\!!yunit
3116 \!shadexorigin=\!xorigin \advance \!shadexorigin \!shadesymbolxshift
3117 \!shadeyorigin=\!yorigin \advance \!shadeyorigin \!shadesymbolyshift
3118 \ignorespaces}
3119
3120 % ** \!starthshade [at] (yS,xlS,xrS)
3121 % ** Initiates horizontal shading mode
3122 \def\!starthshade#1(#2,#3,#4){%
3123 \let\!!xunit=\!yunit%
3124 \let\!!yunit=\!xunit%
3125 \let\!!xshade=\!yshade%
3126 \let\!!yshade=\!xshade%
3127 \def\!getshrinkages{\!hgetshrinkages}%
3128 \let\!setshadelocation=\!hsetshadelocation%
3129 \!xS=\!M{#2}\!!xunit
3130 \!ybS=\!M{#3}\!!yunit
3131 \!ytS=\!M{#4}\!!yunit
3132 \!shadexorigin=\!xorigin \advance \!shadexorigin \!shadesymbolxshift
3133 \!shadeyorigin=\!yorigin \advance \!shadeyorigin \!shadesymbolyshift
3134 \ignorespaces}
3135
3136
3137 % ** \!lattice{ANCHOR}{SPAN}{LOCATION}{INDEX}{LATTICE LOCATION}
3138 % ** Consider the lattice with points ANCHOR + j*SPAN. This routine determines
3139 % ** the index k of the smallest lattice point >= LOCATION, and sets
3140 % ** LATTICE LOCATION = ANCHOR + k*SPAN.
3141 % ** INDEX is assumed to be a count register, LATTICE LOCATION a dimen reg.
3142 \def\!lattice#1#2#3#4#5{%
3143 \!dimenA=#1% ** dimA = ANCHOR
3144 \!dimenB=#2% ** dimB = SPAN (assumed > 0pt)
3145 \!countB=\!dimenB% ** ctB = SPAN, as a count
3146 %
3147 % ** Determine index of smallest lattice point >= LOCATION
3148 \!dimenC=#3% ** dimC = LOCATION
3149 \advance\!dimenC -\!dimenA% ** now dimC = LOCATION-ANCHOR
3150 \!countA=\!dimenC% ** ctA = above, as a count
3151 \divide\!countA \!countB% ** now ctA = desired index, if dimC <= 0
3152 \ifdim\!dimenC>\!zpt
3153 \!dimenD=\!countA\!dimenB% ** (tentative k)*span
3154 \ifdim\!dimenD<\!dimenC% ** if this is false, ctA = desired index
3155 \advance\!countA 1 % ** if true, have to add 1
3156 \fi
3157 \fi
3158 %
3159 \!dimenC=\!countA\!dimenB% ** lattice location = anchor + ctA*span
3160 \advance\!dimenC \!dimenA
3161 #4=\!countA% ** the desired index
3162 #5=\!dimenC% ** corresponding lattice location
3163 \ignorespaces}
3164
3165
3166 % ** \!qshade [with shrinkages] [[LS,RS,BS,TS]]
3167 % ***** during vertical shading:
3168 % ** [the region from (xS,ybS,ytS) to] (xM,ybM,ytM) [and] (xE,ybE,ytE)
3169 % ** Shades the region {(x,y): xS <= x <= xE, yb(x) <= y <= yt(x)}, where
3170 % ** yb is the quadratic thru (xS,ybS) & (xM,ybM) & (xE,ybE)
3171 % ** yt is the quadratic thru (xS,ytS) & (xM,ybM) & (xE,ytE)
3172 % ** xS,ybS,ytS are either given by \!startvshade or carried over
3173 % ** as the ending values of the immediately preceding \!qshade.
3174 % ** For the interpretation of LS, RS, BS, & TS, see \setshadesymbol. The
3175 % ** values set there can be overridden, for the course of this \!qshade
3176 % ** only, in the same manner as overrides are specified for
3177 % ** \setshadesymbol.
3178 % ***** during horizontal shading:
3179 % ** [the region from (yS,xlS,xrS) to] (yM,xlM,xrM) [and] (yE,xlE,xrE)
3180 \def\!qshade#1(#2,#3,#4)#5(#6,#7,#8){%
3181 \!xM=\!M{#2}\!!xunit
3182 \!ybM=\!M{#3}\!!yunit
3183 \!ytM=\!M{#4}\!!yunit
3184 \!xE=\!M{#6}\!!xunit
3185 \!ybE=\!M{#7}\!!yunit
3186 \!ytE=\!M{#8}\!!yunit
3187 \!getcoeffs\!xS\!ybS\!xM\!ybM\!xE\!ybE\!ybB\!ybC%**Get coefficients B & C for
3188 \!getcoeffs\!xS\!ytS\!xM\!ytM\!xE\!ytE\!ytB\!ytC%**y=y0 + B(x-X0) + C(x-X0)**2
3189 \def\!getylimits{\!qgetylimits}%
3190 \!shade{#1}\ignorespaces}
3191
3192 % ** \!lshade ... (xE,ybE,ytE)
3193 % ** This is like \!qshade, but the top and bottom boundaries are linear,
3194 % ** rather than quadratic.
3195 \def\!lshade#1(#2,#3,#4){%
3196 \!xE=\!M{#2}\!!xunit
3197 \!ybE=\!M{#3}\!!yunit
3198 \!ytE=\!M{#4}\!!yunit
3199 \!dimenE=\!xE \advance \!dimenE -\!xS% ** xE-xS
3200 \!dimenC=\!ytE \advance \!dimenC -\!ytS% ** ytE-ytS
3201 \!divide\!dimenC\!dimenE\!ytB% ** ytB = (ytE-ytS)/(xE-xS)
3202 \!dimenC=\!ybE \advance \!dimenC -\!ybS% ** ybE-ybS
3203 \!divide\!dimenC\!dimenE\!ybB% ** ybB = (ybE-ybS)/(xE-xS)
3204 \def\!getylimits{\!lgetylimits}%
3205 \!shade{#1}\ignorespaces}
3206
3207 % ** \!getcoeffs{X0}{Y0}{X1}{Y1}{X2}{Y2}{B}{C}
3208 % ** Finds B and C such that the quadratic y = Y0 + B(x-X0) + C(x-X0)**2
3209 % ** passes through (X1,Y1) and (X2,Y2): when X0=0=Y0, the formulas are:
3210 % ** B = S1 - X1*C, C = (S2-S1)/X2
3211 % ** with
3212 % ** S1 = Y1/X1, S2 = (Y2-Y1)/(X2-X1).
3213 \def\!getcoeffs#1#2#3#4#5#6#7#8{%
3214 \!dimenC=#4\advance \!dimenC -#2% ** dimC=Y1-Y0
3215 \!dimenE=#3\advance \!dimenE -#1% ** dimE=X1-X0
3216 \!divide\!dimenC\!dimenE\!dimenF% ** dimF=S1
3217 \!dimenC=#6\advance \!dimenC -#4% ** dimC=Y2-Y1
3218 \!dimenH=#5\advance \!dimenH -#3% ** dimH=X2-X1
3219 \!divide\!dimenC\!dimenH\!dimenG% ** dimG=S2
3220 \advance\!dimenG -\!dimenF% ** dimG=S2-S1
3221 \advance \!dimenH \!dimenE% ** dimH=X2-X0
3222 \!divide\!dimenG\!dimenH#8% ** C=(S2-S1)/(X2-X0)
3223 \!removept#8\!t% ** C, without "pt"
3224 #7=-\!t\!dimenE% ** -C*(X1-X0)
3225 \advance #7\!dimenF% ** B=S1-C*(X1-X0)
3226 \ignorespaces}
3227
3228
3229 \def\!shade#1{%
3230 % ** Get LS,RS,BS,TS for this panel
3231 \!getshrinkages#1<,,,>\!nil% % ** now effective LS=dimE, RS=dimF,
3232 % ** BS=dimG, TS=dimH
3233 \advance \!dimenE \!xS% ** now dimE=xS+LS
3234 \!lattice\!!xshade\!dshade\!dimenE% ** set parity=index of left-mst x-lattice
3235 \!parity\!xpos% ** point >= xS+LS, xpos=its location
3236 \!dimenF=-\!dimenF% ** set dimF=xE-RS
3237 \advance\!dimenF \!xE
3238 %
3239 \!loop\!not{\ifdim\!xpos>\!dimenF}% ** loop over x-lattice points <= xE-RS
3240 \!shadecolumn%
3241 \advance\!xpos \!dshade% ** move over to next column
3242 \advance\!parity 1% ** increase index of x-point
3243 \repeat
3244 %
3245 \!xS=\!xE% ** shift ending values to starting values
3246 \!ybS=\!ybE
3247 \!ytS=\!ytE
3248 \ignorespaces}
3249
3250
3251 \def\!vgetshrinkages#1<#2,#3,#4,#5>#6\!nil{%
3252 \!override\!lshrinkage{#2}\!dimenE
3253 \!override\!rshrinkage{#3}\!dimenF
3254 \!override\!bshrinkage{#4}\!dimenG
3255 \!override\!tshrinkage{#5}\!dimenH
3256 \ignorespaces}
3257 \def\!hgetshrinkages#1<#2,#3,#4,#5>#6\!nil{%
3258 \!override\!lshrinkage{#2}\!dimenG
3259 \!override\!rshrinkage{#3}\!dimenH
3260 \!override\!bshrinkage{#4}\!dimenE
3261 \!override\!tshrinkage{#5}\!dimenF
3262 \ignorespaces}
3263
3264
3265 \def\!shadecolumn{%
3266 \!dxpos=\!xpos
3267 \advance\!dxpos -\!xS% ** dx = x - xS
3268 \!removept\!dxpos\!dx% ** ditto, without "pt"
3269 \!getylimits% ** get top and bottom y-values
3270 \advance\!ytpos -\!dimenH% ** less TS
3271 \advance\!ybpos \!dimenG% ** plus BS
3272 \!yloc=\!!yshade% ** get anchor point for this column
3273 \ifodd\!parity
3274 \advance\!yloc \!dshade
3275 \fi
3276 \!lattice\!yloc{2\!dshade}\!ybpos%
3277 \!countA\!ypos% ** ypos=smallest y point for this column
3278 \!dimenA=-\!shadexorigin \advance \!dimenA \!xpos% ** over
3279 \loop\!not{\ifdim\!ypos>\!ytpos}% ** loop over ypos <= yt(t)
3280 \!setshadelocation% ** vmode: xloc=xpos, yloc=ypos
3281 % ** hmode: xloc=ypos, yloc=xpos
3282 \!rotateaboutpivot\!xloc\!yloc%
3283 \!dimenA=-\!shadexorigin \advance \!dimenA \!xloc% ** over
3284 \!dimenB=-\!shadeyorigin \advance \!dimenB \!yloc% ** up
3285 \kern\!dimenA \raise\!dimenB\copy\!shadesymbol \kern-\!dimenA
3286 \advance\!ypos 2\!dshade
3287 \repeat
3288 \ignorespaces}
3289
3290 \def\!qgetylimits{%
3291 \!dimenA=\!dx\!ytC
3292 \advance\!dimenA \!ytB% ** yt(t)=ytS + dx*(Bt + dx*Ct)
3293 \!ytpos=\!dx\!dimenA
3294 \advance\!ytpos \!ytS
3295 \!dimenA=\!dx\!ybC
3296 \advance\!dimenA \!ybB% ** yb(t)=ybS + dx*(Bb + dx*Cb)
3297 \!ybpos=\!dx\!dimenA
3298 \advance\!ybpos \!ybS}
3299
3300 \def\!lgetylimits{%
3301 \!ytpos=\!dx\!ytB% ** yt(t)=ytS + dx*Bt
3302 \advance\!ytpos \!ytS
3303 \!ybpos=\!dx\!ybB% ** yb(t)=ybS + dx*Bb
3304 \advance\!ybpos \!ybS}
3305
3306 \def\!vsetshadelocation{% ** vmode: xloc=xpos, yloc=ypos
3307 \!xloc=\!xpos
3308 \!yloc=\!ypos}
3309 \def\!hsetshadelocation{% ** hmode: xloc=ypos, yloc=xpos
3310 \!xloc=\!ypos
3311 \!yloc=\!xpos}
3312
3313
3314 % **************************************
3315 % *** TICKS (Draws ticks on graphs) ***
3316 % **************************************
3317
3318 % ** User commands
3319 % ** \ticksout
3320 % ** \ticksin
3321 % ** \gridlines
3322 % ** \nogridlines
3323 % ** \loggedticks
3324 % ** \unloggesticks
3325 % ** See Subsection 3.4 of the manual
3326
3327 % ** The following is an option of the \axis command
3328 % ** ticks
3329 % ** [in] [out]
3330 % ** [long] [short] [length <LENGTH>]
3331 % ** [width <WIDTH>]
3332 % ** [andacross] [butnotacross]
3333 % ** [logged] [unlogged]
3334 % ** [unlabeled] [numbered] [withvalues VALUE1 VALUE2 ... VALUEk / ]
3335 % ** [quantity Q] [at LOC1 LOC2 ... LOCk / ] [from LOC1 to LOC2 by
3336 % ** LOC_INCREMENT]
3337 % ** See Subsection 3.2 of the manual for the rules.
3338
3339 % ** The various options of the tick field are processed by the
3340 % ** \!nextkeyword command defined below.
3341 % ** For example, `\!nextkeyword short ' expands to `\!ticksshort',
3342 % ** while `\!nextkeyword withvalues' expands to `\!tickswithvalues'.
3343
3344 \def\!axisticks {%
3345 \def\!nextkeyword##1 {%
3346 \expandafter\ifx\csname !ticks##1\endcsname \relax
3347 \def\!next{\!fixkeyword{##1}}%
3348 \else
3349 \def\!next{\csname !ticks##1\endcsname}%
3350 \fi
3351 \!next}%
3352 \!axissetup
3353 \def\!axissetup{\relax}%
3354 \edef\!ticksinoutsign{\!ticksinoutSign}%
3355 \!ticklength=\longticklength
3356 \!tickwidth=\linethickness
3357 \!gridlinestatus
3358 \!setticktransform
3359 \!maketick
3360 \!tickcase=0
3361 \def\!LTlist{}%
3362 \!nextkeyword}
3363
3364 \def\ticksout{%
3365 \def\!ticksinoutSign{+}}
3366 \def\ticksin{%
3367 \def\!ticksinoutSign{-}}
3368 \ticksout
3369
3370 \def\gridlines{%
3371 \def\!gridlinestatus{\!gridlinestootrue}}
3372 \def\nogridlines{%
3373 \def\!gridlinestatus{\!gridlinestoofalse}}
3374 \nogridlines
3375
3376 \def\loggedticks{%
3377 \def\!setticktransform{\let\!ticktransform=\!logten}}
3378 \def\unloggedticks{%
3379 \def\!setticktransform{\let\!ticktransform=\!donothing}}
3380 \def\!donothing#1#2{\def#2{#1}}
3381 \unloggedticks
3382
3383 % ** \!ticks/ : terminates read of tick options
3384 \expandafter\def\csname !ticks/\endcsname{%
3385 \!not {\ifx \!LTlist\empty}
3386 \!placetickvalues
3387 \fi
3388 \def\!tickvalueslist{}%
3389 \def\!LTlist{}%
3390 \expandafter\csname !axis/\endcsname}
3391
3392 \def\!maketick{%
3393 \setbox\!boxA=\hbox{%
3394 \beginpicture
3395 \!setdimenmode
3396 \setcoordinatesystem point at {\!zpt} {\!zpt}
3397 \linethickness=\!tickwidth
3398 \ifdim\!ticklength>\!zpt
3399 \putrule from {\!zpt} {\!zpt} to
3400 {\!ticksinoutsign\!tickxsign\!ticklength}
3401 {\!ticksinoutsign\!tickysign\!ticklength}
3402 \fi
3403 \if!gridlinestoo
3404 \putrule from {\!zpt} {\!zpt} to
3405 {-\!tickxsign\!xaxislength} {-\!tickysign\!yaxislength}
3406 \fi
3407 \endpicturesave <\!Xsave,\!Ysave>}%
3408 \wd\!boxA=\!zpt}
3409
3410 \def\!ticksin{%
3411 \def\!ticksinoutsign{-}%
3412 \!maketick
3413 \!nextkeyword}
3414
3415 \def\!ticksout{%
3416 \def\!ticksinoutsign{+}%
3417 \!maketick
3418 \!nextkeyword}
3419
3420 \def\!tickslength<#1> {%
3421 \!ticklength=#1\relax
3422 \!maketick
3423 \!nextkeyword}
3424
3425 \def\!tickslong{%
3426 \!tickslength<\longticklength> }
3427
3428 \def\!ticksshort{%
3429 \!tickslength<\shortticklength> }
3430
3431 \def\!tickswidth<#1> {%
3432 \!tickwidth=#1\relax
3433 \!maketick
3434 \!nextkeyword}
3435
3436 \def\!ticksandacross{%
3437 \!gridlinestootrue
3438 \!maketick
3439 \!nextkeyword}
3440
3441 \def\!ticksbutnotacross{%
3442 \!gridlinestoofalse
3443 \!maketick
3444 \!nextkeyword}
3445
3446 \def\!tickslogged{%
3447 \let\!ticktransform=\!logten
3448 \!nextkeyword}
3449
3450 \def\!ticksunlogged{%
3451 \let\!ticktransform=\!donothing
3452 \!nextkeyword}
3453
3454 \def\!ticksunlabeled{%
3455 \!tickcase=0
3456 \!nextkeyword}
3457
3458 \def\!ticksnumbered{%
3459 \!tickcase=1
3460 \!nextkeyword}
3461
3462 \def\!tickswithvalues#1/ {%
3463 \edef\!tickvalueslist{#1! /}%
3464 \!tickcase=2
3465 \!nextkeyword}
3466
3467 \def\!ticksquantity#1 {%
3468 \ifnum #1>1
3469 \!updatetickoffset
3470 \!countA=#1\relax
3471 \advance \!countA -1
3472 \!ticklocationincr=\!axisLength
3473 \divide \!ticklocationincr \!countA
3474 \!ticklocation=\!axisstart
3475 \loop \!not{\ifdim \!ticklocation>\!axisend}
3476 \!placetick\!ticklocation
3477 \ifcase\!tickcase
3478 \relax % Case 0: no labels
3479 \or
3480 \relax % Case 1: numbered -- not available here
3481 \or
3482 \expandafter\!gettickvaluefrom\!tickvalueslist
3483 \edef\!tickfield{{\the\!ticklocation}{\!value}}%
3484 \expandafter\!listaddon\expandafter{\!tickfield}\!LTlist%
3485 \fi
3486 \advance \!ticklocation \!ticklocationincr
3487 \repeat
3488 \fi
3489 \!nextkeyword}
3490
3491 \def\!ticksat#1 {%
3492 \!updatetickoffset
3493 \edef\!Loc{#1}%
3494 \if /\!Loc
3495 \def\next{\!nextkeyword}%
3496 \else
3497 \!ticksincommon
3498 \def\next{\!ticksat}%
3499 \fi
3500 \next}
3501
3502 \def\!ticksfrom#1 to #2 by #3 {%
3503 \!updatetickoffset
3504 \edef\!arg{#3}%
3505 \expandafter\!separate\!arg\!nil
3506 \!scalefactor=1
3507 \expandafter\!countfigures\!arg/
3508 \edef\!arg{#1}%
3509 \!scaleup\!arg by\!scalefactor to\!countE
3510 \edef\!arg{#2}%
3511 \!scaleup\!arg by\!scalefactor to\!countF
3512 \edef\!arg{#3}%
3513 \!scaleup\!arg by\!scalefactor to\!countG
3514 \loop \!not{\ifnum\!countE>\!countF}
3515 \ifnum\!scalefactor=1
3516 \edef\!Loc{\the\!countE}%
3517 \else
3518 \!scaledown\!countE by\!scalefactor to\!Loc
3519 \fi
3520 \!ticksincommon
3521 \advance \!countE \!countG
3522 \repeat
3523 \!nextkeyword}
3524
3525 \def\!updatetickoffset{%
3526 \!dimenA=\!ticksinoutsign\!ticklength
3527 \ifdim \!dimenA>\!offset
3528 \!offset=\!dimenA
3529 \fi}
3530
3531 \def\!placetick#1{%
3532 \if!xswitch
3533 \!xpos=#1\relax
3534 \!ypos=\!axisylevel
3535 \else
3536 \!xpos=\!axisxlevel
3537 \!ypos=#1\relax
3538 \fi
3539 \advance\!xpos \!Xsave
3540 \advance\!ypos \!Ysave
3541 \kern\!xpos\raise\!ypos\copy\!boxA\kern-\!xpos
3542 \ignorespaces}
3543
3544 \def\!gettickvaluefrom#1 #2 /{%
3545 \edef\!value{#1}%
3546 \edef\!tickvalueslist{#2 /}%
3547 \ifx \!tickvalueslist\!endtickvaluelist
3548 \!tickcase=0
3549 \fi}
3550 \def\!endtickvaluelist{! /}
3551
3552 \def\!ticksincommon{%
3553 \!ticktransform\!Loc\!t
3554 \!ticklocation=\!t\!!unit
3555 \advance\!ticklocation -\!!origin
3556 \!placetick\!ticklocation
3557 \ifcase\!tickcase
3558 \relax % Case 0: no labels
3559 \or % Case 1: numbered
3560 \ifdim\!ticklocation<-\!!origin
3561 \edef\!Loc{$\!Loc$}%
3562 \fi
3563 \edef\!tickfield{{\the\!ticklocation}{\!Loc}}%
3564 \expandafter\!listaddon\expandafter{\!tickfield}\!LTlist%
3565 \or % Case 2: labeled
3566 \expandafter\!gettickvaluefrom\!tickvalueslist
3567 \edef\!tickfield{{\the\!ticklocation}{\!value}}%
3568 \expandafter\!listaddon\expandafter{\!tickfield}\!LTlist%
3569 \fi}
3570
3571 \def\!separate#1\!nil{%
3572 \!ifnextchar{-}{\!!separate}{\!!!separate}#1\!nil}
3573 \def\!!separate-#1\!nil{%
3574 \def\!sign{-}%
3575 \!!!!separate#1..\!nil}
3576 \def\!!!separate#1\!nil{%
3577 \def\!sign{+}%
3578 \!!!!separate#1..\!nil}
3579 \def\!!!!separate#1.#2.#3\!nil{%
3580 \def\!arg{#1}%
3581 \ifx\!arg\!empty
3582 \!countA=0
3583 \else
3584 \!countA=\!arg
3585 \fi
3586 \def\!arg{#2}%
3587 \ifx\!arg\!empty
3588 \!countB=0
3589 \else
3590 \!countB=\!arg
3591 \fi}
3592
3593 \def\!countfigures#1{%
3594 \if #1/%
3595 \def\!next{\ignorespaces}%
3596 \else
3597 \multiply\!scalefactor 10
3598 \def\!next{\!countfigures}%
3599 \fi
3600 \!next}
3601
3602 \def\!scaleup#1by#2to#3{%
3603 \expandafter\!separate#1\!nil
3604 \multiply\!countA #2\relax
3605 \advance\!countA \!countB
3606 \if -\!sign
3607 \!countA=-\!countA
3608 \fi
3609 #3=\!countA
3610 \ignorespaces}
3611
3612 \def\!scaledown#1by#2to#3{%
3613 \!countA=#1\relax% ** get original #
3614 \ifnum \!countA<0 % ** take abs value,
3615 \def\!sign{-}% ** remember sign
3616 \!countA=-\!countA
3617 \else
3618 \def\!sign{}%
3619 \fi
3620 \!countB=\!countA% ** copy |#|
3621 \divide\!countB #2\relax% ** integer part (|#|/sf)
3622 \!countC=\!countB% ** get sf * (|#|/sf)
3623 \multiply\!countC #2\relax
3624 \advance \!countA -\!countC% ** ctA is now remainder
3625 \edef#3{\!sign\the\!countB.}% ** +- integerpart.
3626 \!countC=\!countA % ** Tack on proper number
3627 \ifnum\!countC=0 % ** of zeros after .
3628 \!countC=1
3629 \fi
3630 \multiply\!countC 10
3631 \!loop \ifnum #2>\!countC
3632 \edef#3{#3\!zero}%
3633 \multiply\!countC 10
3634 \repeat
3635 \edef#3{#3\the\!countA}% ** Add on rest of remainder
3636 \ignorespaces}
3637
3638 \def\!placetickvalues{%
3639 \advance\!offset \tickstovaluesleading
3640 \if!xswitch
3641 \setbox\!boxA=\hbox{%
3642 \def\\##1##2{%
3643 \!dimenput {##2} [B] (##1,\!axisylevel)}%
3644 \beginpicture
3645 \!LTlist
3646 \endpicturesave <\!Xsave,\!Ysave>}%
3647 \!dimenA=\!axisylevel
3648 \advance\!dimenA -\!Ysave
3649 \advance\!dimenA \!tickysign\!offset
3650 \if -\!tickysign
3651 \advance\!dimenA -\ht\!boxA
3652 \else
3653 \advance\!dimenA \dp\!boxA
3654 \fi
3655 \advance\!offset \ht\!boxA
3656 \advance\!offset \dp\!boxA
3657 \!dimenput {\box\!boxA} [Bl] <\!Xsave,\!Ysave> (\!zpt,\!dimenA)
3658 \else
3659 \setbox\!boxA=\hbox{%
3660 \def\\##1##2{%
3661 \!dimenput {##2} [r] (\!axisxlevel,##1)}%
3662 \beginpicture
3663 \!LTlist
3664 \endpicturesave <\!Xsave,\!Ysave>}%
3665 \!dimenA=\!axisxlevel
3666 \advance\!dimenA -\!Xsave
3667 \advance\!dimenA \!tickxsign\!offset
3668 \if -\!tickxsign
3669 \advance\!dimenA -\wd\!boxA
3670 \fi
3671 \advance\!offset \wd\!boxA
3672 \!dimenput {\box\!boxA} [Bl] <\!Xsave,\!Ysave> (\!dimenA,\!zpt)
3673 \fi}
3674
3675
3676 \normalgraphs
3677 \catcode`!=12 % ***** THIS MUST NEVER BE OMITTED