summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/doc/metapost/featpost/example/ellipticthing.mp
blob: d681c99fe4ddbcc8fe340fe40e4545e069d3e819 (plain)
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
% ellipticthing.mp
% L. Nobre G.
% 2011

prologues := 1;

beginfig(1);
  numeric u, a, b, i, n, astep;
  u = 1cm;
  a = 5u;
  b = 3u;
  n = 24;
  astep = 360/n;
  path elli, arcb;
  elli = (a,0) for i=1 upto (n-1):
      ..(a*cosd(i*astep),b*sind(i*astep))
  endfor ..cycle;
  draw elli;
  draw fullcircle scaled (2*b);
  draw fullcircle scaled (a-b) shifted (0.5*(a+b),0);
  draw fullcircle scaled (a-b) shifted (-0.5*(a+b),0);
  pair refpoint, refslope, centerpo, focus;
  refpoint = (a,b)/sqrt(2);
  refslope = unitvector(b,a);
  centerpo = refpoint + whatever*refslope;
  xpart centerpo = 0;
  draw centerpo--refpoint;
  draw centerpo--(-xpart refpoint,ypart refpoint);
  numeric len, ang, lenb, angb;
  len = abs(refpoint-centerpo);
  ang = angle(refpoint-centerpo);
  draw refpoint for i=1 upto n:
      ..(centerpo+len*dir(2*i*(90-ang)/n+ang))
  endfor;
  focus = (4u,0);
  lenb = abs(focus-centerpo);
  angb = angle(focus-centerpo);
  arcb = focus for i=1 upto n:
      ..(centerpo+lenb*dir(2*i*(90-angb)/n+angb))
  endfor;
  draw arcb;
  draw arcb rotated 180;
  draw centerpo--focus;
  draw centerpo--(-xpart focus,ypart focus);
endfig;

end.