summaryrefslogtreecommitdiff
path: root/info/drawing-with-metapost/src/curves-spiral-gnomon-trig.mp
blob: 5bf37d00b701aac90f38d247f5aa39683d8d603d (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
\documentclass{standalone}
\usepackage{luamplib}
\begin{document}
\mplibtextextlabel{enable}
\begin{mplibcode}
beginfig(1);
    path t[], base; pair apex;
    base = (left--right) scaled 100;
    apex = whatever * dir +72 shifted point 0 of base 
         = whatever * dir -72 shifted point 1 of base;
    t0 = (base -- apex -- cycle);
    transform S; 
    r = arclength subpath (0, 1) of t0 / arclength subpath (2, 3) of t0;
    point 0 of t0 transformed S = (r*r)[point 0 of t0, point 2 of t0];
    point 1 of t0 transformed S = point 0 of t0;
    point 2 of t0 transformed S = point 1 of t0;

    n = 16;
    for i=1 upto n:
        t[i] = t[i-1] transformed S;
        draw subpath (2,3) of t[i] withpen pencircle scaled 1/4;
    endfor
    draw point 0 of t0 -- point 3/2 of t0 withpen pencircle scaled 1/8 withcolor blue;
    draw point 0 of t1 -- point 3/2 of t1 withpen pencircle scaled 1/8 withcolor blue;
    draw t0;
    drawarrow point 2 of t[n] for i=n-1 downto 0: .. point 2 of t[i] endfor withcolor 2/3 red;

    z0 = whatever[point 0 of t0, point 3/2 of t0]
       = whatever[point 0 of t1, point 3/2 of t1];
    numeric a; a = angle (point 2 of t0 - z0);
    drawoptions(withcolor 1/2 green);
    label.lft(TEX("$a$") rotated a, point 5/2 of t0);
    label.bot(TEX("$b$") rotated a, point 1/2 of t0);
    label.rt(TEX("$x$") rotated a, point 1/2 of t1);
    drawoptions();
    currentpicture := currentpicture rotated -a;
endfig;
\end{mplibcode}
\end{document}