Skip to content

Commit 567765f

Browse files
committed
Committing all of the public metapost files for the dg book.
1 parent 8d06d53 commit 567765f

File tree

716 files changed

+92773
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

716 files changed

+92773
-0
lines changed

3d1.mp

+45
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
% tex/conc/mp/3d1.mp 2005-3-10 Alan Kennington.
2+
% $Id: tex/conc/mp/3d1.mp 8017ff16b3 2008-06-01 17:11:26Z Alan U. Kennington $
3+
% 3d graphic: x,y,z demo.
4+
5+
input 3dmax.mp
6+
7+
%%%%%%%%%%%%%%%%%%%%%%%%%
8+
% figure 1 %
9+
%%%%%%%%%%%%%%%%%%%%%%%%%
10+
beginfig(1);
11+
12+
numeric A[][]; % The current 4x3 transformation matrix.
13+
numeric p[][], q[][]; % Lists of 3-vectors.
14+
pair w[]; % Coordinate pairs on the drawing canvas.
15+
numeric s; % The screen scale factor.
16+
17+
Z_set(p0)(100, -100, 50); % Position of viewer.
18+
Z_set(q0)(0, 0, 0); % Centre of picture.
19+
20+
A_set_pq(A)(p0)(q0);
21+
% A_print(A);
22+
23+
s := 300;
24+
25+
Z_set(p1)(1cm, 0cm, 0cm); % X axis.
26+
Z_set(p2)(0cm, 1cm, 0cm); % Y axis.
27+
Z_set(p3)(0cm, 0cm, 1cm); % Z axis.
28+
Z_set(p4)(0cm, 0cm, 0cm); % Origin.
29+
30+
A_calc_w(A)(w1)(p1)(s);
31+
A_calc_w(A)(w2)(p2)(s);
32+
A_calc_w(A)(w3)(p3)(s);
33+
A_calc_w(A)(w4)(p4)(s);
34+
35+
% showvariable w;
36+
drawarrow w4--w1;
37+
drawarrow w4--w2;
38+
drawarrow w4--w3;
39+
40+
label.lrt(btex $x$ etex, w1);
41+
label.rt(btex $y$ etex, w2);
42+
label.top(btex $z$ etex, w3);
43+
44+
endfig;
45+
end

3d10.mp

+134
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,134 @@
1+
% tex/conc/mp/3d10.mp 2016-8-31 Alan U. Kennington.
2+
% $Id: tex/conc/mp/3d10.mp 6ca9ae4555 2016-08-31 13:44:02Z Alan U. Kennington $
3+
% 3d graphic: Sphere S^2 in perspective.
4+
5+
input 3dmax
6+
input mapmax
7+
input centmax
8+
9+
%%%%%%%%%%%%%%%%%%%%%%%%%
10+
% figure 1 %
11+
%%%%%%%%%%%%%%%%%%%%%%%%%
12+
beginfig(1);
13+
numeric A[][]; % The current 4x3 transformation matrix.
14+
numeric p[][], q[][]; % Lists of 3-vectors.
15+
pair w[], midpt; % Coordinate pairs on the drawing canvas.
16+
numeric s; % The screen scale factor.
17+
path pat[];
18+
color vcol;
19+
20+
% Multiplier and orientation angles for viewer.
21+
dv := 10; % Distance of camera from centre of sphere.
22+
ph_v := 45; % Angle phi.
23+
th_v := 40; % Angle theta.
24+
Z_set_rpt(p0)(dv, ph_v, th_v); % Position of viewer.
25+
Z_set(q0)(0, 0, 0); % Centre of picture.
26+
A_set_pq(A)(p0)(q0); % Set the perspective matrix.
27+
28+
s := 700; % Some sort of magnification/zoom factor.
29+
R := 1; % Radius of the sphere.
30+
31+
A_calc_w(A)(midpt)(q0)(s);
32+
33+
%- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
34+
% Constant-latitude circles.
35+
nR := 12; % 12 points around the equator.
36+
nlat := 9; % Number for dividing the latitude of 90 degrees.
37+
% nlat := 3; % Number for dividing the latitude of 90 degrees.
38+
39+
% Constant-longitude circles.
40+
mR := 20; % 40 points along the longitude line.
41+
% nlong := 12; % Number for dividing the longitude of 180 degrees.
42+
nlong := 6; % Number for dividing the longitude of 180 degrees.
43+
44+
Z_set(p11)(0,0,0); % Centre of the sphere.
45+
46+
% Draw the sphere.
47+
A_draw_lat_hide(A)(s)(p11)(R, nlat, nR, 0.6pt, 0.9pt)(p0);
48+
A_draw_long_hide(A)(s)(p11)(R, nlong, mR, 0.6pt, 0.9pt)(p0);
49+
50+
% Add some vectors to demonstrate parallel transport.
51+
pickup pencircle scaled 1.4pt;
52+
vlen := 0.35; % Length of vector.
53+
vcol := 0.0white; % Colour of vector.
54+
55+
% Phi = 0 degrees.
56+
A_north_draw(A)(s)(q0)(R, 0, 0, vlen, vcol);
57+
A_north_draw(A)(s)(q0)(R, 0, 30, vlen, vcol);
58+
A_north_draw(A)(s)(q0)(R, 0, 60, vlen, vcol);
59+
A_north_draw(A)(s)(q0)(R, 0, 90, vlen, vcol);
60+
61+
% A_north_draw(A)(s)(q0)(R, 0, 90/4, vlen, vcol);
62+
% A_north_draw(A)(s)(q0)(R, 0, 90/2, vlen, vcol);
63+
% A_north_draw(A)(s)(q0)(R, 0, 3*90/4, vlen, vcol);
64+
65+
% Phi = 90 degrees.
66+
A_north_draw(A)(s)(q0)(R, 90, 0, vlen, vcol);
67+
A_north_draw(A)(s)(q0)(R, 90, 30, vlen, vcol);
68+
A_north_draw(A)(s)(q0)(R, 90, 60, vlen, vcol);
69+
A_north_draw(A)(s)(q0)(R, 90, 90, vlen, vcol);
70+
71+
% Phi = 30, 60 degrees.
72+
A_north_draw(A)(s)(q0)(R, 15, 0, vlen, vcol);
73+
A_north_draw(A)(s)(q0)(R, 30, 0, vlen, vcol);
74+
A_north_draw(A)(s)(q0)(R, 45, 0, vlen, vcol);
75+
A_north_draw(A)(s)(q0)(R, 60, 0, vlen, vcol);
76+
A_north_draw(A)(s)(q0)(R, 75, 0, vlen, vcol);
77+
78+
% End point.
79+
pickup pencircle scaled 1.0pt;
80+
Z_set_rpt(p10)(R,0,90);
81+
A_calc_w(A)(w10)(p10)(s);
82+
w11 := w10 + (4,4)*5;
83+
w10 := w10 + (0.5pt,3pt);
84+
drawarrow w11{dir-170}..{dir-90}w10 withcolor 0.5white;
85+
label.rt(btex Finish here etex, w11);
86+
87+
% Start point.
88+
pickup pencircle scaled 1.0pt;
89+
Z_set_rpt(p10)(R,0,0);
90+
A_calc_w(A)(w10)(p10)(s);
91+
w11 := w10 + (-4,-4)*5;
92+
S_arrowspaces(w11,w10,2pt,2.5pt,1,0.5white);
93+
label.bot(btex Start here etex, w11);
94+
pickup pencircle scaled 3.0pt;
95+
draw w10;
96+
97+
pickup pencircle scaled 1.0pt;
98+
% Draw Muenchen.
99+
alon := 11+34/60;
100+
alat := 48+8/60;
101+
% Draw Bologna.
102+
% alon := 11+20/60;
103+
% alat := 44+29/60;
104+
% Draw Genova.
105+
% alon := 8+57/60;
106+
% alat := 44+25/60;
107+
Z_set_rpt(p10)(R,alon,alat);
108+
A_calc_w(A)(w10)(p10)(s);
109+
w11 := w10 + (-9,-3)*5;
110+
% S_arrowspaces(w11,w10,2pt,4pt,1,0.5white);
111+
S_arrowspaces(w11,w10,2pt,3pt,1,0.5white);
112+
label.lft(btex M\"unchen etex, w11);
113+
% label.lft(btex Bologna etex, w11);
114+
% label.lft(btex Genova etex, w11);
115+
pickup pencircle scaled 3.0pt;
116+
draw w10;
117+
118+
% Draw Hanoi.
119+
pickup pencircle scaled 1.0pt;
120+
alon := 105+51/60;
121+
alat := 21+2/60;
122+
Z_set_rpt(p10)(R,alon,alat);
123+
A_calc_w(A)(w10)(p10)(s);
124+
w11 := w10 + (4,-2)*5;
125+
S_arrowspaces(w11,w10,1.5pt,3pt,1,0.5white);
126+
label.rt(btex H\`a N\d{\^o}i etex, w11);
127+
pickup pencircle scaled 3.0pt;
128+
draw w10;
129+
130+
% Centre the picture bounding box.
131+
C_bbox_centre_set(currentpicture)(midpt);
132+
133+
endfig;
134+
end

3d11.mp

+87
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
% tex/conc/mp/3d11.mp 2006-8-3 Alan Kennington.
2+
% $Id: tex/conc/mp/3d11.mp 8017ff16b3 2008-06-01 17:11:26Z Alan U. Kennington $
3+
% 3d graphic: Sphere S^2 in perspective.
4+
5+
input 3dmax.mp
6+
input mapmax.mp
7+
8+
%%%%%%%%%%%%%%%%%%%%%%%%%
9+
% figure 1 %
10+
%%%%%%%%%%%%%%%%%%%%%%%%%
11+
beginfig(1);
12+
numeric A[][]; % The current 4x3 transformation matrix.
13+
numeric p[][], q[][]; % Lists of 3-vectors.
14+
pair w[]; % Coordinate pairs on the drawing canvas.
15+
numeric s; % The screen scale factor.
16+
path pat[];
17+
18+
% Multiplier and orientation angles for viewer.
19+
dv := 10; % Distance of camera from centre of sphere.
20+
ph_v := -45; % Angle phi.
21+
th_v := 40; % Angle theta.
22+
Z_set_rpt(p0)(dv, ph_v, th_v); % Position of viewer.
23+
Z_set(q0)(0, 0, 0); % Centre of picture.
24+
A_set_pq(A)(p0)(q0); % Set the perspective matrix.
25+
26+
s := 700; % Some sort of magnification/zoom factor.
27+
R := 1; % Radius of the sphere.
28+
29+
%- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
30+
% Constant-latitude circles.
31+
nR := 12; % 12 points around the equator.
32+
nlat := 9; % Number for dividing the latitude of 90 degrees.
33+
% nlat := 3; % Number for dividing the latitude of 90 degrees.
34+
35+
% Constant-longitude circles.
36+
mR := 20; % 40 points along the longitude line.
37+
% nlong := 12; % Number for dividing the longitude of 180 degrees.
38+
nlong := 6; % Number for dividing the longitude of 180 degrees.
39+
40+
Z_set(p11)(0,0,0); % Centre of the sphere.
41+
42+
% Draw the sphere.
43+
A_draw_lat_hide(A)(s)(p11)(R, nlat, nR, 0.6pt, 1.2pt)(p0);
44+
A_draw_long_hide(A)(s)(p11)(R, nlong, mR, 0.6pt, 1.2pt)(p0);
45+
46+
% Save the current picture bounding box.
47+
bbx := bboxmargin;
48+
bboxmargin := 0;
49+
pat1 := bbox currentpicture;
50+
% show pat1;
51+
% pickup pencircle scaled 0.4pt;
52+
% draw pat1;
53+
bboxmargin := bbx;
54+
55+
% Draw Muenchen
56+
pickup pencircle scaled 1.0pt;
57+
alon := 11+34/60;
58+
alat := 48+8/60;
59+
Z_set_rpt(p10)(R,alon,alat);
60+
A_calc_w(A)(w10)(p10)(s);
61+
w11 := w10 + (7,2)*5;
62+
S_arrowspace(w11,w10,4pt,1,0.5white);
63+
label.rt(btex M\"unchen etex, w11);
64+
pickup pencircle scaled 3.0pt;
65+
draw w10;
66+
67+
% Draw Havana.
68+
pickup pencircle scaled 1.0pt;
69+
alon := -(82+22/60);
70+
alat := 23+8/60;
71+
Z_set_rpt(p10)(R,alon,alat);
72+
A_calc_w(A)(w10)(p10)(s);
73+
w11 := w10 + (-7,2)*5;
74+
S_arrowspace(w11,w10,4pt,1,0.5white);
75+
label.lft(btex La Habana etex, w11);
76+
pickup pencircle scaled 3.0pt;
77+
draw w10;
78+
79+
% Lie about the picture edges.
80+
% pat1 := bbox currentpicture;
81+
% show pat1;
82+
setbounds currentpicture to pat1;
83+
% pickup pencircle scaled 0.4pt;
84+
% draw pat1 dashed evenly;
85+
86+
endfig;
87+
end

3d12.mp

+93
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
% tex/conc/mp/3d12.mp 2005-3-10 Alan Kennington.
2+
% $Id: tex/conc/mp/3d12.mp 8017ff16b3 2008-06-01 17:11:26Z Alan U. Kennington $
3+
% 3d graphic: standard injection for tensor product of sets.
4+
5+
input 3dmax.mp
6+
7+
%%%%%%%%%%%%%%%%%%%%%%%%%
8+
% figure 1 %
9+
%%%%%%%%%%%%%%%%%%%%%%%%%
10+
beginfig(1);
11+
12+
numeric A[][]; % The current 4x3 transformation matrix.
13+
numeric p[][], q[][]; % Lists of 3-vectors.
14+
pair w[]; % Coordinate pairs on the drawing canvas.
15+
numeric s; % The screen scale factor.
16+
17+
% Scale factor to make viewer further away and increase zoom proportionately.
18+
ss := 0.5;
19+
Z_set(p0)(25 * ss, -40 * ss, 10 * ss); % Position of viewer.
20+
Z_set(q0)(0, 0, 0); % Centre of picture.
21+
22+
A_set_pq(A)(p0)(q0);
23+
% A_print(A);
24+
25+
s := 800 * ss;
26+
27+
axlength := 5;
28+
yt := 0.5;
29+
Z_set(p1)(axlength, 0, 0); % X axis.
30+
Z_set(p2)(0, axlength + yt, 0); % Y axis.
31+
Z_set(p3)(0, 0, 3/5*axlength); % Z axis.
32+
Z_set(p4)(0, 0, 0); % Origin.
33+
34+
A_calc_w(A)(w1)(p1)(s);
35+
A_calc_w(A)(w2)(p2)(s);
36+
A_calc_w(A)(w3)(p3)(s);
37+
A_calc_w(A)(w4)(p4)(s);
38+
39+
% showvariable w;
40+
drawarrow w4--w1;
41+
drawarrow w4--w2;
42+
drawarrow w4--w3;
43+
44+
np := 4;
45+
nq := 4;
46+
xt := 0.5; % Extension of lines.
47+
for i=-np step 1 until np:
48+
Z_set(p5)(i, -nq - xt, 0);
49+
Z_set(p6)(i, nq + xt, 0);
50+
A_calc_w(A)(w5)(p5)(s);
51+
A_calc_w(A)(w6)(p6)(s);
52+
draw w5--w6;
53+
endfor
54+
55+
for j=-nq step 1 until nq:
56+
Z_set(p5)(-np - xt, j, 0);
57+
Z_set(p6)(np + xt, j, 0);
58+
A_calc_w(A)(w5)(p5)(s);
59+
A_calc_w(A)(w6)(p6)(s);
60+
draw w5--w6;
61+
endfor
62+
63+
pickup pencircle;
64+
for i=-np step 1 until np:
65+
for j=-nq step 1 until nq:
66+
Z_set(p5)(i, j, 0);
67+
A_calc_w(A)(w5)(p5)(s);
68+
draw w5;
69+
endfor
70+
endfor
71+
72+
label.lrt(btex $\mathop{\times}\limits_{\alpha\in A}V_\alpha$ etex, w1+(0,5));
73+
% label.urt(btex $y$ etex, w2);
74+
label.top(btex $K$ etex, w3+(0,2));
75+
76+
% Draw a vector at a particular point.
77+
Z_set(p7)(3, 4, 0);
78+
Z_set(p8)(3, 4, 1);
79+
A_calc_w(A)(w7)(p7)(s);
80+
A_calc_w(A)(w8)(p8)(s);
81+
82+
% Sneeky trick to make the vertical line look more vertical!!
83+
% (I think this is called orthographic projection.)
84+
w8 := w7 + (0, ypart(w8-w7));
85+
86+
pickup pencircle scaled 0.3pt;
87+
draw w7--w8 dashed evenly;
88+
pickup pencircle scaled 4pt;
89+
draw w8;
90+
label.top(btex $(u,1)$ etex, w8 + (0,3));
91+
92+
endfig;
93+
end

0 commit comments

Comments
 (0)