1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
|
% Figures for MetaPost manual, by John Hobby. Public domain.
filenametemplate "%j-%c.mps";
%%% This redefinition of dotlabel draws dots as a closed path
%%% which are rendered more smoothly in Adobe Reader.
vardef dotlabel@#(expr s,z) text t_ =
label@#(s,z) t_;
addto currentpicture
contour (makepath pencircle scaled dotlabeldiam) shifted z t_;
enddef;
%%% TeX macro \place is only used in figure 0.
verbatimtex
\input texnames.sty
\def\place#1{\vphantom{FiMP}\smash{#1}}
etex
%%% The boxes package is only used in figure 0.
input boxes
beginfig(0);
ba.dy = bb.dy = d.dy = 12bp;
d.dx = 100bp;
boxit.aa(btex \place{Figures in MetaPost} etex);
boxit.ab(btex \place{\TeX\ Document} etex);
boxit.ba(btex \hbox to 75bp {\hfil\place{MetaPost}\hfil} etex);
boxit.bb.(btex \hbox to 75bp {\hfil\place{\TeX\ or \LaTeX}\hfil} etex);
boxit.ca(btex \place{Figures in PostScript} etex);
boxit.cb(btex \place{{\tt dvi} file} etex);
boxit.d(btex \place{\tt dvips} etex);
boxit.e(btex PostScript etex);
boxit.f(btex \vbox{
\hbox to 50bp {\hfil\hbox{bounding}\hfil}
\hbox to 50bp {\hfil\hbox{box}\hfil}
} etex scaled .8);
ba.n - aa.s = ca.n - ba.s
= bb.n - ab.s = cb.n - bb.s
= e.n - d.s = down * 25bp;
ypart cb.s - ypart d.n = 25bp;
e.s = origin;
ypart ca.s = ypart cb.s;
xpart aa.n = xpart 0.1[d.nw,d.ne];
xpart ab.n = xpart 0.9[d.nw,d.ne];
drawunboxed(aa,ab,ca,cb,e);
drawboxed(ba,bb,d);
drawarrow aa.s -- top ba.n; drawarrow ab.s -- top bb.n;
drawarrow ba.s -- top ca.n; drawarrow bb.s -- top cb.n;
drawarrow ca.s -- top 0.1[d.nw,d.ne];
drawarrow cb.s -- top 0.9[d.nw,d.ne];
drawarrow d.s -- top e.n;
path p;
p = ca.e{right} .. {right}bb.w;
f.c = point .5 of p;
drawunboxed(f);
draw p cutafter bpath f dashed evenly;
drawarrow p cutbefore subpath (1,3) of bpath f dashed evenly;
endfig;
beginfig(1);
draw (20,20)--(0,0)--(0,30)--(30,0)--(0,0);
endfig;
beginfig(2); numeric u;
u=1cm;
draw (2u,2u)--(0,0)--(0,3u)--(3u,0)--(0,0);
pickup pencircle scaled 4pt;
for i=0 upto 2:
for j=0 upto 2:
drawdot (i*u,j*u);
endfor
endfor
endfig;
beginfig(3);
z0 = (0,0); z1 = (60,40);
z2 = (40,90); z3 = (10,70);
z4 = (30,50);
draw z0..z1..z2..z3..z4;
dotlabels.top(0,2,4);
dotlabels.lft(3);
dotlabels.lrt(1);
endfig;
beginfig(104);
z0 = (0,0); z1 = (60,40);
z2 = (40,90); z3 = (10,70);
z4 = (30,50);
draw z0..z1..z2..z3..z4..cycle;
dotlabels.top(2,4);
dotlabels.lft(0,3);
dotlabels.lrt(1);
endfig;
beginfig(204);
z0 = (0,0); z1 = (60,40);
z2 = (40,90); z3 = (10,70);
z4 = (30,50);
draw z0..z1..z2..z3--z4--cycle;
dotlabels.top(2,4);
dotlabels.lft(0,3);
dotlabels.lrt(1);
endfig;
beginfig(5);
z0 = (0,0); z1 = (60,40);
z2 = (40,90); z3 = (10,70);
z4 = (30,50);
path p; p = z0..z1..z2..z3..z4;
draw p;
for t=0 upto 3:
draw point t of p--postcontrol t of p
--precontrol t+1 of p--point t+1 of p
dashed (evenly scaled .5);
endfor
dotlabels.top(0,2,4);
dotlabels.lft(3);
dotlabels.lrt(1);
endfig;
beginfig(6);
z0 = (0,0); z1 = (60,40);
z2 = (40,90); z3 = (10,70);
z4 = (30,50);
draw z0..z1{up}..z2{left}..z3..z4;
dotlabels.top(0,2,4);
dotlabels.lft(3);
dotlabels.lrt(1);
endfig;
beginfig(7)
for a=0 upto 9:
draw (0,0){dir 45}..{dir -10a}(6cm,0);
endfor
endfig;
beginfig(8)
for a=0 upto 7:
draw (0,0){dir 45}..{dir 10a}(6cm,0);
endfor
endfig;
beginfig(109);
z2=-z0=(1in,0); z1=(0,.2in);
draw z0{up}..z1{right}..z2{down};
dotlabels.bot(0,1,2);
endfig;
beginfig(209);
z2=-z0=(1in,0); z1=(0,.2in);
draw z0{up}...z1{right}...z2{down};
dotlabels.bot(0,1,2);
endfig;
beginfig(110);
numeric u; 10u=1.5in;
-z0=z3=(5u,0);
(-x1,y1)=z2=(3u,2u);
draw z0..z1..z2..z3;
dotlabels.bot(0,1,2,3);
endfig;
beginfig(210);
numeric u; 10u=1.5in;
-z0=z3=(5u,0);
(-x1,y1)=z2=(3u,2u);
draw z0..z1..tension 1.3..z2..z3;
dotlabels.bot(0,1,2,3);
endfig;
beginfig(310);
numeric u; 10u=1.5in;
-z0=z3=(5u,0);
(-x1,y1)=z2=(3u,2u);
draw z0..z1..tension 1.5 and 1..z2..z3;
dotlabels.bot(0,1,2,3);
endfig;
beginfig(111);
numeric u, c; 10u=1.4in; c=0;
z1=(0,0); (x0,-y0)=z2=(2u,5u);
draw z0{curl c}..z1..{curl c}z2;
dotlabels.rt(0,1,2);
endfig;
beginfig(211);
numeric u, c; 10u=1.4in; c=1;
z1=(0,0); (x0,-y0)=z2=(2u,5u);
draw z0{curl c}..z1..{curl c}z2;
dotlabels.rt(0,1,2);
endfig;
beginfig(311);
numeric u, c; 10u=1.4in; c=2;
z1=(0,0); (x0,-y0)=z2=(2u,5u);
draw z0{curl c}..z1..{curl c}z2;
dotlabels.rt(0,1,2);
endfig;
beginfig(411);
numeric u, c; 10u=1.4in; c=infinity;
z1=(0,0); (x0,-y0)=z2=(2u,5u);
draw z0{curl c}..z1..{curl c}z2;
dotlabels.rt(0,1,2);
endfig;
beginfig(13);
z1=-z2=(.2in,0);
x3=-x6=.3in;
x3+y3=x6+y6=1.1in;
z4=1/3[z3,z6];
z5=2/3[z3,z6];
z20=whatever[z1,z3]=whatever[z2,z4];
z30=whatever[z1,z4]=whatever[z2,z5];
z40=whatever[z1,z5]=whatever[z2,z6];
draw z1--z20--z2--z30--z1--z40--z2;
pickup pencircle scaled 1pt;
draw z1--z2;
draw z3--z6;
%
dotlabels.bot(1,2);
dotlabels.rt(3);
dotlabels.lft(6);
dotlabels.top(20,30,40);
endfig;
vardef llet(expr c) =
c infont defaultfont scaled magstep3
enddef;
primarydef p centered h =
(p shifted (h - xpart .5[llcorner p,lrcorner p], 0))
enddef;
beginfig(14);
string s; s = "abcde";
numeric u,n, ytop, ybot;
n = 5;
ytop = 3bp + ypart urcorner llet(s);
ybot = -3bp + ypart llcorner llet(s);
ytop - ybot = u;
draw (n*u,ybot)--(0,ybot)--(0,ytop)--(n*u,ytop);
for i=1 upto n:
draw (i*u,ybot)..(i*u,ytop);
draw llet(substring (i-1,i) of s) centered ((i-.5)*u);
label.bot(decimal i, (i*u,ybot));
endfor
picture llab; llab = btex \llap{$x={}$}0 etex;
z0 = urcorner llab;
draw llab shifted (-.5*x0, ybot-labeloffset-y0);
endfig;
beginfig(17);
a=.7in; b=.5in;
z0=(0,0);
z1=-z3=(a,0);
z2=-z4=(0,b);
draw z1..z2..z3..z4..cycle;
draw z1--z0--z2;
label.top("a", .5[z0,z1]);
label.lft("b", .5[z0,z2]);
dotlabel.bot("(0,0)", z0);
endfig;
beginfig(18);
numeric u;
u = 1cm;
draw (0,2u)--(0,0)--(4u,0);
pickup pencircle scaled 1pt;
draw (0,0){up}
for i=1 upto 8: ..(i/2,sqrt(i/2))*u endfor;
label.lrt(btex $\sqrt x$ etex, (3,sqrt 3)*u);
label.bot(btex $x$ etex, (2u,0));
label.lft(btex $y$ etex, (0,u));
endfig;
beginfig(19);
numeric ux, uy;
120ux=1.2in; 4uy=2.4in;
draw (0,4uy)--(0,0)--(120ux,0);
pickup pencircle scaled 1pt;
draw (0,uy){right}
for ix=1 upto 8:
..(15ix*ux, uy*2/(1+cosd 15ix))
endfor;
label.bot(btex $x$ axis etex, (60ux,0));
label.lft(btex $y$ axis etex rotated 90,
(0,2uy));
label.lft(
btex $\displaystyle y={2\over1+\cos x}$ etex,
(120ux, 4uy));
endfig;
beginfig(20);
picture p;
p = "testing" infont "ptmr8r" scaled 7;
draw p;
draw llcorner p--lrcorner p--urcorner p--ulcorner p--cycle;
dotlabel.lft(btex \tt llcorner etex, llcorner p);
dotlabel.rt(btex \tt lrcorner etex, lrcorner p);
dotlabel.lft(btex \tt ulcorner etex, ulcorner p);
dotlabel.rt(btex \tt urcorner etex, urcorner p);
endfig;
beginfig(21);
path p;
p = (-1cm,0)..(0,-1cm)..(1cm,0);
fill p{up}..(0,0){-1,-2}..{up}cycle;
draw p..(0,1cm)..cycle;
endfig;
beginfig(22);
path a, b, aa, ab;
a = fullcircle scaled 2cm;
b = a shifted (0,1cm);
aa = halfcircle scaled 2cm;
ab = buildcycle(aa, b);
picture pa, pb;
pa = thelabel(btex $A$ etex, (0,-.5cm));
pb = thelabel(btex $B$ etex, (0,1.5cm));
fill a withcolor .7white;
fill b withcolor .7white;
fill ab withcolor .4white;
unfill bbox pa;
draw pa;
unfill bbox pb;
draw pb;
label.lft(btex $U$ etex, (-1cm,.5cm));
draw bbox currentpicture;
endfig;
beginfig(123);
path aa, b;
b = a shifted (0,1cm);
aa = halfcircle scaled 2cm;
draw aa;
draw b dashed evenly;
z1 = aa intersectionpoint reverse b;
z2 = reverse aa intersectionpoint b;
dotlabel.rt(btex 1 etex, z1);
dotlabel.lft(btex 2 etex, z2);
label.bot(btex \tt aa etex, point 0 of aa);
label.bot(btex \tt b etex, point 2 of b);
endfig;
beginfig(223);
path aa, b;
b = a shifted (0,1cm);
aa = halfcircle scaled 2cm;
numeric t[], tt[];
(t1,8-tt1) = aa intersectiontimes reverse b;
(4-t2,tt2) = reverse aa intersectiontimes b;
pickup(pencircle scaled .3);
draw aa;
draw b;
pickup(pencircle scaled .8);
draw subpath (t1,t2) of aa;
draw subpath (tt2,tt1) of b;
dotlabel.rt(btex 1 etex, point t1 of aa);
dotlabel.lft(btex 2 etex, point t2 of aa);
label.bot(btex \tt aa etex, point 0 of aa);
label.bot(btex \tt b etex, point 2 of b);
endfig;
beginfig(24);
h=2in; w=2.7in;
path p[], q[], pp;
for i=2 upto 4: ii:=i**2;
p[i] = (w/ii,h){1,-ii}...(w/i,h/i)...(w,h/ii){ii,-1};
endfor
q0.5 = (0,0)--(w,0.5h);
q1.5 = (0,0)--(w/1.5,h);
pp = buildcycle(q0.5, p2, q1.5, p4);
fill pp withcolor .7white;
z0=center pp;
picture lab; lab=thelabel(btex $f>0$ etex, z0);
unfill bbox lab; draw lab;
draw q0.5; draw p2; draw q1.5; draw p4;
dotlabel.top(btex $P$ etex, p2 intersectionpoint q0.5);
dotlabel.rt(btex $Q$ etex, p2 intersectionpoint q1.5);
dotlabel.lft(btex $R$ etex, p4 intersectionpoint q1.5);
dotlabel.bot(btex $S$ etex, p4 intersectionpoint q0.5);
endfig;
beginfig(25);
numeric u;
u = .2in;
path a, b;
a = (0,0){up}..(4u,0)..(8u,0)..(8u,4u);
b = (10u,3u)..(5u,u)..(-u,u);
numeric t; t=0;
forsuffixes $=bot, llft, lrt, lft:
dotlabel$(decimal t, point t of a);
t:=t+1;
endfor
for i=0 upto 2:
dotlabel.top(decimal i, point i of b);
endfor
pickup(pencircle scaled .3);
draw a;
pickup(pencircle scaled .8);
draw b;
% intersections (atime, btime):
% (0.2501,1.77225)
% (2.58316,0.23619)
% (0.75288,1.40094)
endfig;
beginfig(26);
numeric scf, #, t[];
3.2scf = 2.4in;
path fun;
# = .1; % Keep the function single-valued
fun = ((0,-1#)..(1,.5#){right}..(1.9,.2#){right}..{curl .1}(3.2,2#))
yscaled(1/#) scaled scf;
x1 = 2.5scf;
for i=1 upto 2:
(t[i],whatever) =
fun intersectiontimes ((x[i],-infinity)--(x[i],infinity));
z[i] = point t[i] of fun;
z[i]-(x[i+1],0) = whatever*direction t[i] of fun;
draw (x[i],0)--z[i]--(x[i+1],0);
fill fullcircle scaled 3bp shifted z[i];
endfor
label.bot(btex $x_1$ etex, (x1,0));
label.bot(btex $x_2$ etex, (x2,0));
label.bot(btex $x_3$ etex, (x3,0));
draw (0,0)--(3.2scf,0);
pickup pencircle scaled 1pt;
draw fun;
endfig;
beginfig(28);
path p[];
p1 = fullcircle scaled .6in;
z1=(.75in,0)=-z3;
z2=directionpoint left of p1=-z4;
p2 = z1..z2..{curl1}z3..z4..{curl 1}cycle;
fill p2 withcolor .4[white,black];
unfill p1;
draw p1;
transform T;
z1 transformed T = z2;
z3 transformed T = z4;
xxpart T=yypart T; yxpart T=-xypart T;
picture pic;
pic = currentpicture;
for i=1 upto 2:
pic:=pic transformed T;
draw pic;
endfor
dotlabels.top(1,2,3); dotlabels.bot(4);
endfig;
beginfig(29);
if unknown withdots: % So this works w/o MetaPost version 0.5
picture withdots; withdots=dashpattern(off 2.5 on 0 off 2.5);
fi
z0 = (0,0);
z1 = (2in-2bp,0);
for i=1 upto 4:
z[2i]-z[2i-2] = z[2i+1]-z[2i-1] = (0,14pt);
endfor
draw z0..z1 dashed evenly;
label.rt(btex \tt dashed evenly etex, z1);
draw z2..z3 dashed evenly scaled 2;
label.rt(btex \tt dashed evenly scaled 2 etex, z3);
draw z4..z5 dashed evenly scaled 4;
label.rt(btex \tt dashed evenly scaled 4 etex, z5);
draw z6..z7 dashed withdots;
label.rt(btex \tt dashed withdots etex, z7);
draw z8..z9 dashed withdots scaled 2;
label.rt(btex \tt dashed withdots scaled 2 etex, z9);
endfig;
beginfig(30);
picture e[]; e4=evenly scaled 4;
z0 = (0,0);
z1 = (2in,0);
for i=1 upto 3:
z[2i]-z[2i-2] = z[2i+1]-z[2i-1] = (0,14pt);
endfor
dotlabels.lft(0,2,4,6);
draw z0..z1 dashed e4;
dotlabel.rt(btex 1 \tt\ draw z0..z1 dashed e4 etex, z1);
draw z2..z3 dashed e4 shifted (6bp,0);
dotlabel.rt(btex 3 \tt\ draw z2..z3 dashed e4 shifted (6bp,0) etex, z3);
draw z4..z5 dashed e4 shifted (12bp,0);
dotlabel.rt(btex 5 \tt\ draw z4..z5 dashed e4 shifted (12bp,0) etex, z5);
draw z6..z7 dashed e4 shifted (18bp,0);
dotlabel.rt(btex 7 \tt\ draw z6..z7 dashed e4 shifted (18bp,0) etex, z7);
endfig;
beginfig(31);
picture d; d = dashpattern(on 6bp off 12bp on 6bp);
draw d;
endfig;
beginfig(32);
draw dashpattern(on 15bp off 15bp) dashed evenly;
picture p;
p=currentpicture;
currentpicture:=nullpicture;
draw fullcircle scaled 1cm xscaled 3 dashed p;
endfig;
beginfig(33);
for i=0 upto 2:
z[i]=(0,-40i); z[i+3]-z[i]=(100,30);
endfor
pickup pencircle scaled 18;
draw z0..z3 withcolor .8white;
linecap:=butt;
draw z1..z4 withcolor .8white;
linecap:=squared;
draw z2..z5 withcolor .8white;
dotlabels.top(0,1,2,3,4,5);
endfig; linecap:=rounded;
beginfig(34);
for i=0 upto 2:
z[i]=(0,-50i); z[i+3]-z[i]=(60,40);
z[i+6]-z[i]=(120,0);
endfor
pickup pencircle scaled 24;
draw z0--z3--z6 withcolor .8white;
linejoin:=mitered;
draw z1..z4--z7 withcolor .8white;
linejoin:=beveled;
draw z2..z5--z8 withcolor .8white;
dotlabels.bot(0,1,2,3,4,5,6,7,8);
endfig; linejoin:=rounded;
beginfig(35);
z2a=(0,0);
(-x1a,y1a) = -z3a = .5in*unitvector(6,1);
z1b - z1a = .75*z1a rotated -90;
z2b - z1b = whatever*(z2a-z1a);
z3b - z2b = whatever*(z3a-z2a);
y2b = 0;
z3b - z3a = whatever*(z3a rotated 90);
z0b-z1b = z0a-z1a = z1a;
x4a=x2a; x4b=x2b;
y4a = y4b = 1.3*y3b;
fill z1a--z2a--z3a--z3b--z2b--z1b--cycle withcolor .8 white;
for p= z2a--z4a, z2b--z4b, z0a--z1a, z0b--z1b:
draw p dashed evenly;
endfor
drawdblarrow z4a--z4b;
drawdblarrow z0a--z0b;
label.bot(btex miter length etex, .5[z4a,z4b]);
label.ulft(btex line width etex, .5[z0a,z0b]);
endfig;
beginfig(36);
z[-1]=(0,0); z0=(1in,0);
for i=1 upto 6:
z[i]-z[i-2] = (0,-15pt);
if x[i]=0: label.lft(decimal i, z[i]);
fi
endfor
drawarrow z1..z2;
drawarrow reverse(z3..z4);
drawdblarrow z5..z6;
label.rt(btex 2 \tt\ drawarrow z1..z2 etex, z2);
label.rt(btex 4 \tt\ drawarrow reverse(z3..z4) etex, z4);
label.rt(btex 6 \tt\ drawdblarrow z5..z6 etex, z6);
endfig;
beginfig(37);
path p, q, r;
ahlength := 1.5cm;
pickup pencircle scaled .2cm;
p = (0,0)..{right}(2.5cm,2cm);
q = counterclockwise arrowhead p;
z0 = directionpoint up of q;
z.a = directionpoint right of q;
z.b = directionpoint (-1,-1) of q;
drawarrow p withcolor .4white;
pickup defaultpen;
undraw p;
undraw q;
ahlength:=4bp;
z.a1-z0 = .3cm*unitvector(z.a-z0) rotated 90;
z.a1-z.a2 = z0-z.a;
z.b1-z0 = .3cm*unitvector(z.b-z0) rotated -90;
z.b1-z.b2 = z0-z.b;
z.ab = whatever[z.a1,z.a2] = whatever[z.b1,z.b2];
z.a0-z.ab = .4cm*unitvector(z.a1-z.a2);
z.b0-z.ab = .4cm*unitvector(z.b1-z.b2);
drawdblarrow z.a1..z.a2;
label.lrt(btex \tt ahlength etex, .9[z.a1,z.a2]);
draw z.a1..z.a0 dashed evenly;
drawdblarrow z.b1..z.b2;
label.urt(btex \tt ahlength etex, .9[z.b1,z.b2]);
draw z.b1..z.b0 dashed evenly;
r = z.a0{(z.a2-z.a0) rotated 90}..{(z.b2-z.b0)rotated 90}z.b0;
draw r;
label.rt(btex \tt ahangle etex, point .5 of r);
endfig;
beginfig(38);
pickup pencircle scaled .2in yscaled .08 rotated 30;
x0=x3=x4;
z1-z0 = .45in*dir 30;
z2-z3 = whatever*(z1-z0);
z6-z5 = whatever*(z1-z0);
z1-z6 = 1.2*(z3-z0);
rt x3 = lft x2;
x5 = .55[x4,x6];
y4 = y6;
lft x3 = bot y5 = 0;
top y2 = .9in;
draw z0--z1--z2--z3--z4--z5--z6 withcolor .7white;
dotlabels.top(0,1,2,3,4,5,6);
endfig;
beginfig(40);
path p[];
p1 = (0,0){curl 0}..(5pt,-3pt)..{curl 0}(10pt,0);
p2 = p1..(p1 yscaled-1 shifted(10pt,0));
p0 = p2;
for i=1 upto 3: p0:=p0.. p2 shifted (i*20pt,0);
endfor
for j=0 upto 8: draw p0 shifted (0,j*10pt);
endfor
p3 = fullcircle shifted (.5,.5) scaled 72pt;
clip currentpicture to p3;
draw p3;
endfig;
marksize=4pt;
angle_radius=8pt;
def draw_mark(expr p, a) =
begingroup
save t, dm; pair dm;
t = arctime a of p;
dm = marksize*unitvector direction t of p
rotated 90;
draw (-.5dm.. .5dm) shifted point t of p;
endgroup
enddef;
def draw_marked(expr p, n) =
begingroup
save amid;
amid = .5*arclength p;
for i=-(n-1)/2 upto (n-1)/2:
draw_mark(p, amid+.6marksize*i);
endfor
draw p;
endgroup
enddef;
def mark_angle(expr a, b, c, n) =
begingroup
save s, p; path p;
p = unitvector(a-b){(a-b)rotated 90}..unitvector(c-b);
s = .9marksize/length(point 1 of p - point 0 of p);
if s<angle_radius: s:=angle_radius; fi
draw_marked(p scaled s shifted b, n);
endgroup
enddef;
def mark_rt_angle(expr a, b, c) =
draw ((1,0)--(1,1)--(0,1))
zscaled (angle_radius*unitvector(a-b)) shifted b
enddef;
beginfig(42);
pair a,b,c,d;
b=(0,0); c=(1.5in,0); a=(0,.6in);
d-c = (a-b) rotated 25;
dotlabel.lft("a",a);
dotlabel.lft("b",b);
dotlabel.bot("c",c);
dotlabel.llft("d",d);
z0=.5[a,d];
z1=.5[b,c];
(z.p-z0) dotprod (d-a) = 0;
(z.p-z1) dotprod (c-b) = 0;
draw a--d;
draw b--c;
draw z0--z.p--z1;
draw_marked(a--b, 1);
draw_marked(c--d, 1);
draw_marked(a--z.p, 2);
draw_marked(d--z.p, 2);
draw_marked(b--z.p, 3);
draw_marked(c--z.p, 3);
mark_angle(z.p, b, a, 1);
mark_angle(z.p, c, d, 1);
mark_angle(z.p, c, b, 2);
mark_angle(c, b, z.p, 2);
mark_rt_angle(z.p, z0, a);
mark_rt_angle(z.p, z1, b);
endfig;
def getmid(suffix p) =
pair p.mid[], p.off[], p.dir[];
for i=0 upto 36:
p.dir[i] = dir(5*i);
p.mid[i]+p.off[i] = directionpoint p.dir[i] of p;
p.mid[i]-p.off[i] = directionpoint -p.dir[i] of p;
endfor
enddef;
def joinup(suffix pt, d)(expr n) =
begingroup
save res, g; path res;
res = pt[0]{d[0]};
for i=1 upto n:
g:= if (pt[i]-pt[i-1]) dotprod d[i] <0: - fi 1;
res := res{g*d[i-1]}...{g*d[i]}pt[i];
endfor
res
endgroup
enddef;
beginfig(45)
path p, q;
p = ((5,2)...(3,4)...(1,3)...(-2,-3)...(0,-5)...(3,-4)
...(5,-3)...cycle) scaled .3cm shifted (0,5cm);
getmid(p);
draw p;
draw joinup(p.mid, p.dir, 36)..cycle;
q = joinup(p.off, p.dir, 36);
draw q..(q rotated 180)..cycle;
drawoptions(dashed evenly);
for i=0 upto 3:
draw p.mid[9i]-p.off[9i]..p.mid[9i]+p.off[9i];
draw -p.off[9i]..p.off[9i];
endfor
endfig;
input boxes
\beginfig(48);
fill unitsquare xscaled 1.1in yscaled .7in withcolor .9white;
boxit(currentpicture);
dx = dy = .25in;
clearit; drawboxed();
forsuffixes $=n,c: makelabel.top(str $, $); endfor
makelabel.bot("s",s);
forsuffixes $=ne,e,se: makelabel.rt(str $, $); endfor
forsuffixes $=nw,w,sw: makelabel.lft(str $, $); endfor
pickup pencircle scaled .3bp;
vardef larrow@#(expr a, da, s) =
drawdblarrow a..a+da; label@#(s,a+.5da); enddef;
larrow.rt(n, (0,-dy), "dy");
larrow.rt(s, (0,dy), "dy");
larrow.top(e, (-dx,0), "dx");
larrow.top(w, (dx,0), "dx");
endfig;
beginfig(49);
boxjoin(a.se=b.sw; a.ne=b.nw);
boxit.a(btex\strut$\cdots$ etex); boxit.ni(btex\strut$n_i$ etex);
boxit.di(btex\strut$d_i$ etex); boxit.ni1(btex\strut$n_{i+1}$ etex);
boxit.di1(btex\strut$d_{i+1}$ etex); boxit.aa(btex\strut$\cdots$ etex);
boxit.nk(btex\strut$n_k$ etex); boxit.dk(btex\strut$d_k$ etex);
drawboxed(di,a,ni,ni1,di1,aa,nk,dk); label.lft("ndtable:", a.w);
interim defaultdy:=7bp;
boxjoin(a.sw=b.nw; a.se=b.ne);
boxit.ba(); boxit.bb(); boxit.bc();
boxit.bd(btex $\vdots$ etex); boxit.be(); boxit.bf();
bd.dx=8bp; ba.ne=a.sw-(15bp,10bp);
drawboxed(ba,bb,bc,bd,be,bf); label.lft("hashtab:",ba.w);
vardef ndblock suffix $ =
boxjoin(a.sw=b.nw; a.se=b.ne);
forsuffixes $$=$1,$2,$3: boxit$$(); ($$dx,$$dy)=(5.5bp,4bp);
endfor; enddef;
ndblock nda; ndblock ndb; ndblock ndc;
nda1.c-bb.c = ndb1.c-nda3.c = (whatever,0);
xpart ndb3.se = xpart ndc1.ne = xpart di.c;
ndc1.c - be.c = (whatever,0);
drawboxed(nda1,nda2,nda3, ndb1,ndb2,ndb3, ndc1,ndc2,ndc3);
drawarrow bb.c -- nda1.w;
drawarrow be.c -- ndc1.w;
drawarrow nda3.c -- ndb1.w;
drawarrow nda1.c{right}..{curl0}ni.c cutafter bpath ni;
drawarrow nda2.c{right}..{curl0}di.c cutafter bpath di;
drawarrow ndc1.c{right}..{curl0}ni1.c cutafter bpath ni1;
drawarrow ndc2.c{right}..{curl0}di1.c cutafter bpath di1;
drawarrow ndb1.c{right}..nk.c cutafter bpath nk;
drawarrow ndb2.c{right}..dk.c cutafter bpath dk;
x.ptr=xpart aa.c; y.ptr=ypart ndc1.ne;
drawarrow subpath (0,.7) of (z.ptr..{left}ndc3.c) dashed evenly;
label.rt(btex \strut ndblock etex, z.ptr); endfig;
\beginfig(50)
interim circmargin := .07in;
fill unitsquare xscaled 1.1in yscaled .7in withcolor .9white;
circleit(currentpicture);
dx = dy;
clearit; drawboxed();
forsuffixes $=n,c: makelabel.top(str $, $); endfor
makelabel.bot("s",s);
makelabel.rt("e", e);
makelabel.lft("w", w);
pickup pencircle scaled .3bp;
vardef larrow@#(expr a, da, s) =
drawdblarrow a..a+da; label@#(s,a+.5da); enddef;
larrow.rt(n, (0,-dy), "dy");
larrow.rt(s, (0,dy), "dy");
larrow.top(e, (-dx,0), "dx");
larrow.top(w, (dx,0), "dx");
endfig;
vardef drawshadowed(text t) =
fixsize(t);
forsuffixes s=t:
fill bpath.s shifted (1pt,-1pt);
unfill bpath.s;
drawboxed(s);
endfor
enddef;
beginfig(51)
circleit.a(btex Box 1 etex);
circleit.b(btex Box 2 etex);
b.n = a.s - (0,20pt);
drawshadowed(a,b);
drawarrow a.s -- b.n;
endfig;
vardef cuta(suffix a,b) expr p =
drawarrow p cutbefore bpath.a cutafter bpath.b;
point .5*length p of p
enddef;
vardef self@# expr p =
cuta(@#,@#) @#.c{curl0}..@#.c+p..{curl0}@#.c enddef;
beginfig(52);
verbatimtex \def\stk#1#2{$\displaystyle{\matrix{#1\cr#2\cr}}$} etex
circleit.aa(btex\strut Start etex); aa.dx=aa.dy;
circleit.bb(btex \stk B{(a|b)^*a} etex);
circleit.cc(btex \stk C{b^*} etex);
circleit.dd(btex \stk D{(a|b)^*ab} etex);
circleit.ee(btex\strut Stop etex); ee.dx=ee.dy;
numeric hsep;
bb.c-aa.c = dd.c-bb.c = ee.c-dd.c = (hsep,0);
cc.c-bb.c = (0,.8hsep);
xpart(ee.e - aa.w) = 3.8in;
drawboxed(aa,bb,cc,dd,ee);
label.ulft(btex$b$etex, cuta(aa,cc) aa.c{dir50}..cc.c);
label.top(btex$b$etex, self.cc(0,30pt));
label.rt(btex$a$etex, cuta(cc,bb) cc.c..bb.c);
label.top(btex$a$etex, cuta(aa,bb) aa.c..bb.c);
label.llft(btex$a$etex, self.bb(-20pt,-35pt));
label.top(btex$b$etex, cuta(bb,dd) bb.c..dd.c);
label.top(btex$b$etex, cuta(dd,ee) dd.c..ee.c);
label.lrt(btex$a$etex, cuta(dd,bb) dd.c..{dir140}bb.c);
label.bot(btex$a$etex, cuta(ee,bb) ee.c..tension1.3 ..{dir115}bb.c);
label.urt(btex$b$etex, cuta(ee,cc) ee.c{(cc.c-ee.c)rotated-15}..cc.c);
endfig;
beginfig(55)
picture wheel, car;
path body;
u := 5bp;
% Use a calligraphic pen.
pickup pencircle scaled .1u yscaled .6 rotated 30;
% Define a wheel object.
wheel := image(
draw fullcircle scaled 2u xscaled .8 rotated 30;
draw fullcircle scaled .1u xscaled .8 rotated 30
withpen currentpen scaled .5;
);
% Construct path for car body.
body := (3.2u,0){right}..(4.5u,1.5u){up}..(1.5u,2.5u){dir(-170)}
..(1.5u,4.25u){up}...(0,5u){left};
body := body .. reverse body reflectedabout (origin, (0,u));
% Define a car object.
car := image(
draw wheel shifted (2u, 0);% Draw two wheels.
draw wheel shifted (-2u, 0);
draw (-.8u,0){dir(5)}..(.8u,0);% Draw connection betweeen wheels.
draw body;% Draw body.
% Draw speed indicators.
for i=1.5, 2, 2.5:
draw (5u, u*i){right}..{dir(-10)}(6.5u,u*i*.95);
endfor
) shifted (0, u) slanted -.2 rotated 1;% Introduce asymmetries.
% Draw two cars and a faster one.
draw car shifted (5u,0);
draw car shifted (20u,0);
draw car slanted -.25 shifted (45u,0);
% Draw motorway.
draw (-5u,-u)...(25u,-.5u)...(60u,-u)
withpen currentpen scaled 4 withcolor .7white;
endfig;
%%% Title page rule.
beginfig(60);
pickup pencircle scaled 1.1bp;
linecap := rounded;
draw origin--(4.38in,0);
endfig;
end
|