Debian Codegraph @

texmf-dist/doc/metapost/featpost/example/buildcyclebug.mp

raw
1 % buildcyclebug.mp
2 % L. Nobre G.
3 % 2006
4
5 beginfig(1);
6 numeric squaregridstep, i, j, rotationanglestep, u, nx, ny;
7 numeric rotationangle, horishift;
8 path leftcirc, righcirc, basecirc;
9 pen markpen;
10 pair shiftvect;
11 markpen = pencircle scaled 3pt;
12 u = 10mm;
13 squaregridstep = 2.1u;
14 rotationanglestep = 5.5;
15
16 nx = floor( 21cm / ( squaregridstep+1 ) );
17 ny = 2*floor( 29cm / ( squaregridstep+1 ) );
18 basecirc = fullcircle scaled u;
19 for i=1 upto nx:
20 horishift := (i/nx)*0.45u;
21 for j=1 upto ny:
22 rotationangle := j*rotationanglestep;
23 shiftvect := squaregridstep*(i,0.5*j);
24 leftcirc := basecirc rotated (2*rotationangle)
25 shifted ( shiftvect+horishift*left );
26 righcirc := basecirc rotated rotationangle
27 shifted ( shiftvect+horishift*right );
28 draw leftcirc withcolor 0.3white;
29 draw righcirc withcolor 0.3white;
30 draw buildcycle( leftcirc, reverse righcirc ) withcolor blue;
31 draw point 0 of leftcirc withpen markpen;
32 draw point 0 of righcirc withpen markpen;
33 endfor;
34 endfor;
35 endfig;
36
37 beginfig(2);
38 path a, b, c;
39 a = (159.49368,290.7048)..controls (159.29092,291.94003)
40 and (158.9775,293.15451)
41 ..(158.55756,294.33372)..controls (158.13393,295.5233)
42 and (157.60364,296.6721)
43 ..(156.97446,297.76695)..controls (156.33871,298.87321)
44 and (155.6046,299.9199)
45 ..(154.78215,300.89539)..controls (153.9502,301.88214)
46 and (153.03125,302.79204)
47 ..(152.03786,303.61603)..controls (151.0325,304.44995)
48 and (149.95486,305.19261)
49 ..(148.81863,305.83694)..controls (147.66982,306.48843)
50 and (146.46558,307.03687)
51 ..(145.22061,307.47765)..controls (143.96362,307.92268)
52 and (142.66995,308.25626)
53 ..(141.3548,308.47633)..controls (140.03023,308.698)
54 and (138.68887,308.8037)
55 ..(137.34593,308.79295)..controls (135.99751,308.78217)
56 and (134.65259,308.65404)
57 ..(133.32639,308.40996)..controls (131.99881,308.16563)
58 and (130.69505,307.80605)
59 ..(129.43005,307.33498)..controls (128.16791,306.86497)
60 and (126.94911,306.28574)
61 ..(125.78854,305.60234)..controls (124.63374,304.92235)
62 and (123.5411,304.14188)
63 ..(122.5243,303.26889)..controls (121.51508,302.4024)
64 and (120.58455,301.44818)
65 ..(119.74568,300.41588)..controls (118.91405,299.39249)
66 and (118.17587,298.29651)
67 ..(117.54193,297.1402)..controls (116.91396,295.99477)
68 and (116.39084,294.79483)
69 ..(115.98134,293.55438)..controls (115.57558,292.32524)
70 and (115.28311,291.06154)
71 ..(115.10854,289.77898)..controls (114.93536,288.5067)
72 and (114.87895,287.22122)
73 ..(114.94107,285.93872)..controls (115.0028,284.66422)
74 and (115.18134,283.39806)
75 ..(115.47398,282.15607)..controls (115.76532,280.91968)
76 and (116.16852,279.71237)
77 ..(116.67828,278.54889)..controls (117.18674,277.38843)
78 and (117.79907,276.27635)
79 ..(118.50629,275.22514)..controls (119.21288,274.17487)
80 and (120.01135,273.18947)
81 ..(120.89124,272.27943)..controls (121.77103,271.3695)
82 and (122.72879,270.53844)
83 ..(123.75226,269.79378)..controls (124.77632,269.04868)
84 and (125.86238,268.39284)
85 ..(126.9978,267.83188)..controls (128.13411,267.27048)
86 and (129.3158,266.80612)
87 ..(130.52983,266.44218)..controls (131.74399,266.07822)
88 and (132.98631,265.81592)
89 ..(134.24382,265.65674)..controls (135.50044,265.49768)
90 and (136.76797,265.44212)
91 ..(138.03372,265.49004)..controls (139.29755,265.53787)
92 and (140.55539,265.68869)
93 ..(141.79463,265.94131)..controls (143.03053,266.19325)
94 and (144.24384,266.54561)
95 ..(145.42241,266.99493)..controls (146.59683,267.44267)
96 and (147.73291,267.98524)
97 ..(148.81863,268.61847)..controls (149.90009,269.24919)
98 and (150.9279,269.96771)
99 ..(151.89061,270.76805)..controls (152.8493,271.56505)
100 and (153.74008,272.44041)
101 ..(154.5525,273.38608)..controls (155.36205,274.32838)
102 and (156.09094,275.33714)
103 ..(156.72955,276.40274)..controls (157.36655,277.46562)
104 and (157.91138,278.58112)
105 ..(158.35652,279.73755)..controls (158.8012,280.89273)
106 and (159.14471,282.08438)
107 ..(159.38153,283.29933)..controls (159.6187,284.51605)
108 and (159.74791,285.75134)
109 ..(159.7672,286.99081)..controls (159.78654,288.23448)
110 and (159.69516,289.47742)
111 ..cycle;
112 b = (164.69388,283.76816)..controls (164.45602,285.2755)
113 and (164.0816,286.75807)
114 ..(163.57579,288.19778)..controls (163.06467,289.6526)
115 and (162.42154,291.05757)
116 ..(161.65623,292.39624)..controls (160.8809,293.75246)
117 and (159.9834,295.03499)
118 ..(158.97679,296.22963)..controls (157.95538,297.44182)
119 and (156.82588,298.55852)
120 ..(155.6046,299.56902)..controls (154.36432,300.59523)
121 and (153.03438,301.50781)
122 ..(151.63235,302.29881)..controls (150.2098,303.1014)
123 and (148.71864,303.77567)
124 ..(147.17755,304.31679)..controls (145.61667,304.86487)
125 and (144.01057,305.27425)
126 ..(142.37828,305.54321)..controls (140.73018,305.81479)
127 and (139.06157,305.9422)
128 ..(137.39133,305.92545)..controls (135.71124,305.9086)
129 and (134.03581,305.74596)
130 ..(132.38377,305.43983)..controls (130.7291,305.13322)
131 and (129.1041,304.68382)
132 ..(127.52728,304.09592)..controls (125.95447,303.5095)
133 and (124.43553,302.7875)
134 ..(122.98894,301.93604)..controls (121.55147,301.08994)
135 and (120.191,300.11926)
136 ..(118.92514,299.03305)..controls (117.6715,297.95732)
137 and (116.51561,296.77249)
138 ..(115.47398,295.49034)..controls (114.44432,294.22292)
139 and (113.53049,292.86551)
140 ..(112.74724,291.43265)..controls (111.97365,290.01747)
141 and (111.3307,288.5346)
142 ..(110.82997,287.0015)..controls (110.33537,285.48715)
143 and (109.98169,283.9303)
144 ..(109.77559,282.35062)..controls (109.5717,280.78786)
145 and (109.51315,279.20952)
146 ..(109.6024,277.63603)..controls (109.69093,276.07535)
147 and (109.9245,274.52629)
148 ..(110.29973,273.0088)..controls (110.67278,271.50015)
149 and (111.18423,270.02914)
150 ..(111.82713,268.61427)..controls (112.46806,267.20374)
151 and (113.23691,265.855)
152 ..(114.12129,264.5829)..controls (115.0049,263.31194)
153 and (116.0003,262.12254)
154 ..(117.09409,261.02722)..controls (118.18842,259.93134)
155 and (119.37697,258.93388)
156 ..(120.64404,258.04337)..controls (121.91309,257.15147)
157 and (123.25624,256.37012)
158 ..(124.65749,255.70496)..controls (126.06084,255.03879)
159 and (127.51752,254.49147)
160 ..(129.01158,254.06616)..controls (130.50682,253.64052)
161 and (132.03445,253.3385)
162 ..(133.57892,253.16093)..controls (135.1232,252.9834)
163 and (136.6793,252.93085)
164 ..(138.23209,253.003)..controls (139.78247,253.07506)
165 and (141.32457,253.27116)
166 ..(142.84367,253.58932)..controls (144.35844,253.90657)
167 and (145.84552,254.34416)
168 ..(147.29047,254.89853)..controls (148.72931,255.45056)
169 and (150.1218,256.11664)
170 ..(151.45383,256.89171)..controls (152.77919,257.66292)
171 and (154.0404,258.53955)
172 ..(155.22351,259.51508)..controls (156.4003,260.4854)
173 and (157.49585,261.55034)
174 ..(158.4969,262.70111)..controls (159.49316,263.84637)
175 and (160.39235,265.07266)
176 ..(161.18283,266.36856)..controls (161.97006,267.65913)
177 and (162.64664,269.01411)
178 ..(163.20195,270.42015)..controls (163.75612,271.82329)
179 and (164.18744,273.27196)
180 ..(164.48865,274.75021)..controls (164.7901,276.22968)
181 and (164.96005,277.73294)
182 ..(164.99524,279.2424)..controls (165.03055,280.75697)
183 and (164.93001,282.27168)
184 ..cycle;
185 draw a;
186 draw b;
187 c = buildcycle( b, a );
188 show c;
189 draw c withcolor green;
190
191 pair sh, si;
192 numeric sc;
193 sh = (-150,-285);
194 si = (-150,-290);
195 sc = 10;
196 draw a shifted sh scaled sc;
197 draw b shifted si scaled sc;
198 c := buildcycle( a shifted sh scaled sc, b shifted si scaled sc );
199 draw c withcolor green;
200 endfig;
201
202 end.
203