Debian Codegraph @

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

raw
1 % crossingline.mp
2 % L. Nobre G.
3 % 2007
4
5 input featpost3Dplus2D;
6
7 prologues := 1;
8
9 beginfig(3);
10 path foi, mar, foimar;
11 foi=
12 (-2.09207,0)..controls (-0.8113,1.52635) and (0.46948,3.05269)
13 ..(1.75026,4.57904)..controls (16.50494,-7.80182) and (31.25961,-20.18265)
14 ..(46.01431,-32.5635)..controls (47.72202,-30.52838) and (49.42972,-28.49324)
15 ..(51.13742,-26.45813)..controls (36.38272,-14.07727) and (21.62805,-1.69644)
16 ..(6.87337,10.68442)..controls (8.36761,12.46516) and (9.86185,14.2459)
17 ..(11.3561,16.02664)..controls (1.80319,20.141) and (1.80319,20.141)
18 ..(-0.75836,17.0883)..controls (-1.26715,17.51523) and (-1.77594,17.94215)
19 ..(-2.28471,18.36908)..controls (-3.99242,16.33397) and (-5.70012,14.29883)
20 ..(-7.40782,12.2637)..controls (-6.89905,11.83678) and (-6.39026,11.40985)
21 ..(-5.88147,10.98293)..controls (-7.16225,9.45657) and (-8.44302,7.93024)
22 ..(-9.7238,6.40388)..controls (-7.17989,4.26926) and (-4.63599,2.13463)
23 ..cycle;
24 mar =
25 (0,-12.55302)..controls (-0.6404,-11.78986) and (-1.28078,-11.02667)
26 ..(-1.92117,-10.2635)..controls (-7.51778,-14.95969) and (-13.11438,-19.65587)
27 ..(-18.71098,-24.35205)..controls (-17.00328,-26.38718) and (-15.29556,-28.42232)
28 ..(-13.58786,-30.45744)..controls (-12.30708,-31.98378) and (-12.30708,-31.98378)
29 ..(-2.1138,-28.6326)..controls (-3.95111,-27.57187) and (-6.11067,-26.96915)
30 ..(-7.48247,-25.33434)..controls (-3.921,-22.34586) and (-0.35953,-19.35738)
31 ..(3.20195,-16.3689)..controls (28.64638,-44.3316) and (76.49767,8.8977)
32 ..(12.84161,37.23851)..controls (64.17233,7.60352) and (23.4439,-32.40083)
33 ..(3.05269,-9.99147)..controls (2.03513,-10.84532) and (1.01756,-11.69917)
34 ..cycle;
35 foimar = crossingline( mar, foi, 0.001 );
36 draw foimar;
37 show foimar;
38 endfig;
39
40 beginfig(2);
41 numeric u, elhei, elwid, elpos, bawid, bahei, thstp, thdel, i;
42 numeric refang, reft, tfin, tini, spikang;
43 path el, ba, aux, cutel, horns;
44 pair reftpair;
45 color yellow, thered;
46 pen penpoint, pendot;
47 path togetp;
48 yellow = 0.87*(0.95*red+0.7*green);
49 thered = 0.66red;
50 u = 2mm;
51 thdel = 25;
52 thstp = 5;
53 elhei = 30u;
54 elwid = 44u;
55 elpos = 26u;
56 bawid = 27u;
57 bahei = 10u;
58 penpoint = pencircle scaled 0.5u;
59 pendot = pencircle scaled u;
60 el = (elwid,elpos)..for i=thstp step thstp until 360-thstp:
61 (elwid*cosd(i),elpos+elhei*sind(i)).. endfor cycle;
62 ba = (bawid,-bahei){right}..{left}(bawid,0)--
63 (elwid*cosd(90-thdel),elpos+elhei*sind(90-thdel))--
64 (bawid/3.0,0)--(0,elpos+elhei)--(-bawid/3.0,0)--
65 (elwid*cosd(90+thdel),elpos+elhei*sind(90+thdel))--
66 (-bawid,0){left}..{right}(-bawid,-bahei)--cycle;
67 aux = (0,elpos)--
68 1.1[(0,elpos),(elwid*cosd(270+2thdel),elpos+elhei*sind(270+2thdel))];
69 reftpair = el intersectiontimes aux;
70 reft = xpart reftpair;
71 refang = angle( direction reft of el );
72 tfin = directiontime dir(180-refang) of el;
73 tini = directiontime dir(180+refang) of el - length el;
74 cutel = subpath (tini,tfin) of el;
75 spikang = (90-angle((0,elpos+elhei)-(-bawid,0)));
76 horns = cutel{dir(-refang-spikang)}..
77 {left}(0,elpos-elhei+bawid/3.0)..
78 {dir(refang+spikang)}cycle;
79 draw ba;
80 draw horns;
81 drawarrow subpath (0,1) of ba withpen pendot withcolor red;
82 drawarrow subpath (0,1) of horns withpen pendot withcolor red;
83 togetp = crossingline( ba, horns, 0.001 );
84 draw togetp withpen penpoint;
85 show togetp;
86 endfig;
87
88 beginfig(1);
89 numeric u, oray, odev, nl, circrot, i;
90 pair vect;
91 u = 1cm;
92 oray = 1.1u;
93 odev = 0.4*oray;
94 nl = 5;
95 vect = (oray,0);
96 circrot = -90;
97 % circrot = -180/nl;
98 path outerp, innerp, togetp;
99 innerp = fullcircle scaled 2u rotated circrot shifted vect;
100 outerp = for i=0 upto nl-1:
101 (oray-odev)*dir(i*360/nl){dir(i*360/nl+90)}...
102 (oray+odev)*dir((i+0.5)*360/nl){dir((i+0.5)*360/nl+90)}...
103 endfor cycle;
104 togetp = crossingline( outerp, innerp, 0.001 );
105 fill togetp;
106 draw outerp withcolor red withpen pencircle scaled 1.2pt;
107 drawarrow subpath (0,1) of outerp
108 withcolor green withpen pencircle scaled 0.7pt;
109 draw innerp withcolor blue;
110 draw point 0 of innerp withcolor green withpen pencircle scaled 1pt;
111 endfig;
112 end.