Debian Codegraph @

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

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