Debian Codegraph @

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

raw
1 % ellipticthing.mp
2 % L. Nobre G.
3 % 2011
4
5 prologues := 1;
6
7 beginfig(1);
8 numeric u, a, b, i, n, astep;
9 u = 1cm;
10 a = 5u;
11 b = 3u;
12 n = 24;
13 astep = 360/n;
14 path elli, arcb;
15 elli = (a,0) for i=1 upto (n-1):
16 ..(a*cosd(i*astep),b*sind(i*astep))
17 endfor ..cycle;
18 draw elli;
19 draw fullcircle scaled (2*b);
20 draw fullcircle scaled (a-b) shifted (0.5*(a+b),0);
21 draw fullcircle scaled (a-b) shifted (-0.5*(a+b),0);
22 pair refpoint, refslope, centerpo, focus;
23 refpoint = (a,b)/sqrt(2);
24 refslope = unitvector(b,a);
25 centerpo = refpoint + whatever*refslope;
26 xpart centerpo = 0;
27 draw centerpo--refpoint;
28 draw centerpo--(-xpart refpoint,ypart refpoint);
29 numeric len, ang, lenb, angb;
30 len = abs(refpoint-centerpo);
31 ang = angle(refpoint-centerpo);
32 draw refpoint for i=1 upto n:
33 ..(centerpo+len*dir(2*i*(90-ang)/n+ang))
34 endfor;
35 focus = (4u,0);
36 lenb = abs(focus-centerpo);
37 angb = angle(focus-centerpo);
38 arcb = focus for i=1 upto n:
39 ..(centerpo+lenb*dir(2*i*(90-angb)/n+angb))
40 endfor;
41 draw arcb;
42 draw arcb rotated 180;
43 draw centerpo--focus;
44 draw centerpo--(-xpart focus,ypart focus);
45 endfig;
46
47 end.