将实数右端绕在三角圆上 (Metapost)

将实数右端绕在三角圆上 (Metapost)

我试图重现这个数字,但我的印象是 alpha 与 p 的路径子路径 (0,1.3) 的长度不对应,并且值 -pi/2 不正确。

  \documentclass[border=5mm]{standalone}
  \usepackage{luatex85}
  \usepackage{luamplib}
  \begin{document}
  \mplibtextextlabel{enable}
  \begin{mplibcode}

  beginfig(1);

  numeric u, pi;
  u = 10mm;
  pi = 3.141592654;

  path C, T, xx, yy;

  C = fullcircle scaled 5u;

  xx = (point 4 of C -- point 0 of C) scaled 1.1;
  yy = (point 6 of C -- point 2 of C) scaled 1.1;

  T = ((xpart point 0 of C,200) -- (xpart point 0 of C,-200));

  numeric l;
  l = length subpath(0,1.3) of C;

  draw xx;
  draw yy;
  draw C withpen pencircle scaled 3/4;
  draw origin -- (point 1.2 of C) withcolor blue;
  draw  subpath(0,1.2) of C withcolor blue;
  draw T withcolor red;

 label.urt(btex $\pi$ etex,(xpart point 0 of C,u*(pi)));
 label.urt(btex $1$ etex,(xpart point 0 of C,u*1));
 label.urt(btex $2\pi$ etex,(xpart point 0 of C,u*(2pi)));
 label.urt(btex $\frac{\pi}{2}$ etex,(xpart point 0 of C,u*(pi/2)));
 label.urt(btex $-\frac{\pi}{2}$ etex,(xpart point 0 of C,u*(-pi/2)));
 label.urt("$M$", point 1.3 of C);
 label.llft("$O$", origin);
 label.lrt("$I$", point 0 of C);
 label.ulft("$J$", point 2 of C);
 label.urt(btex $\frac{\pi}{2}$ etex, point 2 of C);

 fill fullcircle scaled dotlabeldiam
 shifted (xpart point 1.2 of C, ypart point 1.2 of C)
 withcolor blue;

 endfig;
 \end{mplibcode}
 \end{document}

在此处输入图片描述

答案1

只是为了比较(或者更诚实地说只是为了我自己的娱乐),这里是另一个版本,您可能会觉得有启发。

在此处输入图片描述

来源

用 编译lualatex

\documentclass[border=5mm]{standalone}
\usepackage{luatex85}
\usepackage{luamplib}
\begin{document}
\mplibtextextlabel{enable}
\begin{mplibcode}
beginfig(1);
    numeric u, pi, alpha;
    u = 42;
    pi = 3.141592653589793;
    alpha = 1.2;

    % you might not want this grid
    numeric minx, miny, maxx, maxy;
    minx = -7/2; maxx = 1; miny = -2; maxy = 13/2;
    for x=minx step 1/2 until maxx:
        draw ((x, miny) -- (x, maxy)) scaled u withcolor 3/4 white;
    endfor
    for y=miny step 1/2 until maxy:
        draw ((minx, y) -- (maxx, y)) scaled u withcolor 3/4 white;
    endfor

    path C, ii, jj;
    C = fullcircle scaled 2u shifted (-u,0);
    ii = (point 4 of C -- point 0 of C) shifted - center C scaled 1.15 shifted center C;
    jj = (point 6 of C -- point 2 of C) shifted - center C scaled 1.15 shifted center C;

    path negative_d, positive_d;
    positive_d = origin -- (0, maxy) scaled u;
    negative_d = origin -- (0, miny) scaled u;

    draw negative_d withcolor 2/3 red;
    draw positive_d withcolor 1/2 green;
    label.lft("$\cal D$", 3/2 pi * u * up) withcolor 1/2 green;

    vardef mark_y_axis(expr value, name, shade) = 
        save p; pair p; p = value * u * up;
        draw (left--right) scaled 2 shifted p withcolor shade;
        label.rt(name, p shifted 2 right);
    enddef;

    mark_y_axis(1,      "$1$",      1/2 green);
    mark_y_axis(alpha,  "$\alpha$", 1/2 green);
    mark_y_axis(1/2 pi, "$\pi/2$",  1/2 green);
    mark_y_axis(pi,     "$\pi$",    1/2 green);
    mark_y_axis(2pi,    "$2\pi$",   1/2 green);
    mark_y_axis(-1/2 pi, "$-\pi/2$",  2/3 red);

    z.M = point alpha * 4 / pi of C;

    path trajet; 
    trajet = subpath (0, alpha * 4 / pi) of C .. {left} (minx, 4/3)*u;

    numeric a; pair p;
    a = arctime pi*u of trajet;
    p = point a of trajet;
    draw (down--up) scaled 2 rotated angle direction a of trajet shifted p withcolor 1/2 green;
    label.ulft("$\pi$", p);

    draw ii withpen pencircle scaled 1/4;
    draw jj withpen pencircle scaled 1/4;
    draw C;
    draw trajet withcolor 1/2 green;

    draw center C -- z.M withcolor 1/4 blue;
    label("$M$", z.M + (-2,8)); filldraw fullcircle scaled dotlabeldiam shifted z.M;

    vardef show_mapping(expr a, b) = 
        interim ahangle := 30;
        drawarrow a {left} .. b {dir 240}
            cutbefore fullcircle scaled 8 shifted a
            cutafter  fullcircle scaled 8 shifted b
            withcolor 3/4 blue;
    enddef;

    show_mapping(pi * u * up, p);
    show_mapping(alpha * u * up, z.M);

    label.llft("$O$", center C); 
    label.lrt("$I$", point 0 of C);
    label.llft("$J$", point 2 of C);

endfig;
\end{mplibcode}
\end{document}

一些注释

  • 您可以u调整整个内容的大小(字体大小除外)

  • 但改变变量的值可能不是一个好主意pi。MP 中没有内置常量,所以我只是在这里定义它,使用恰好内置在我的编辑器中的值。如果你不信任我的常量,你可以尝试这样写,pi = 1/4 arclength (quartercircle scaled 16);这也有效...

  • 如果你不想要网格,你可以直接移除它

  • 我已将点alpha和对应点M放在数学上正确的位置。为了从标量值alpha到圆周上的正确点,我使用了point alpha * 4 / pi of C。这是因为半圆的长度是 4 个 MP 时间单位和 pi 长度单位。

  • 您可以在符号中使用任意后缀z,因此z.M其工作原理与 相同。如果后缀是字母,则z0需要.将 与 分开。z

  • arctime x of pt找到沿路径的“时间” ,p使得length(subpath(0, t) of p) = x,这正是我们想要pi在弯曲路径上找到单位的点。

  • 该定义展示了一种使用和show_mapping来缩短路径的方法(并展示了漂亮的细箭头)。cutbeforecutafter

答案2

对于轴上的标签y,可以使用

label.urt(btex $\pi$ etex,(xpart point 0 of C,u*(pi)));
label.urt(btex $1$ etex,(xpart point 0 of C,u*1));
label.urt(btex $2\pi$ etex,(xpart point 0 of C,u*(2pi)));
label.urt(btex $\frac{\pi}{2}$ etex,(xpart point 0 of C,u*(pi/2)));
label.urt(btex $-\frac{\pi}{2}$ etex,(xpart point 0 of C,u*(-pi/2)));
label.urt("$M$", point 1.3 of C);`

首先,这有很多重复,这使得很难调整,所以让我们将其移到宏中:

vardef labeled (expr t, y) =
  save p; pair p;
  p = (xpart point 0 of C, y*u);
  label.urt(t, p);
enddef;

labeled(btex $\pi$ etex,pi);
labeled(btex $1$ etex,1);
labeled(btex $2\pi$ etex,2pi);
labeled(btex $\frac{\pi}{2}$ etex,pi/2);
labeled(btex $-\frac{\pi}{2}$ etex,-pi/2);

现在我们可以添加小红线来指示准确的位置:添加

draw p shifted (-0.5mm, 0) -- p shifted (0.5mm, 0)  withcolor red;

labeled。这给出 在此处输入图片描述

现在我们明白了为什么 -pi/2 似乎处于一个奇怪的位置,并且不与 pi/2 对称: label.urt将标签放在胡椒r位置,因此会将所有标签稍微上移。我们可以使用label.rtin 来labeled避免这种情况: 在此处输入图片描述

现在轴看起来仍然很奇怪:该图似乎说明了圆弧长度与弧度角之间的对应关系,因此只有当圆的半径为 1 个单位时它才有效。所以我们改为C = fullcircle scaled 5u;C = fullcircle scaled 2u;直径应该是2u)这会使整个图变得非常小,所以我们也可以增加u。我们的新图形是 在此处输入图片描述

现在我们要添加alpha。首先,我们通过询问您感兴趣的路径的alpha弧长 ( ) 来计算(我使用 1.2 而不是因为这是您在代码中实际使用的路径):arclength1.3

alpha*u = arclength subpath(0,1.2) of C;

然后我们可以添加

labeled(btex $\alpha$ etex, alpha);

在此处输入图片描述

事实证明,这条弧的长度略小于 1,因此让我们使用subpath(0, 1.4)它来使它看起来更像原始弧: 在此处输入图片描述

现在,我们可以将所有内容放大一些,并对标签进行一些对齐,以获得:

\documentclass[border=5mm]{standalone}
\usepackage{luatex85}
\usepackage{luamplib}
\begin{document}
\mplibtextextlabel{enable}
\begin{mplibcode}

beginfig(1);

numeric u, pi;
u = 20mm;
pi = 3.141592654;

path C, T, xx, yy;

C = fullcircle scaled 2u;

xx = (point 4 of C -- point 0 of C) scaled 1.1;
yy = (point 6 of C -- point 2 of C) scaled 1.1;

T = ((xpart point 0 of C,6.5u) -- (xpart point 0 of C,-2u));

alpha*u = arclength subpath(0,1.4) of C;

draw xx;
draw yy;
draw C withpen pencircle scaled 3/4;
draw origin -- (point 1.4 of C) withcolor blue;
draw subpath(0,1.4) of C withcolor blue;
draw T withcolor red;

vardef labeled (expr t, y) =
  save p; pair p;
  p = (xpart point 0 of C, y*u);
  label.rt(t, p);
  draw p shifted (-0.5mm, 0) -- p shifted (0.5mm, 0)  withcolor red;
enddef;

labeled(btex $\alpha$ etex,alpha);
labeled(btex \hbox to 1.5em{\hfill$\pi$} etex,pi);
labeled(btex \hbox to 1.5em{\hfill$1$} etex,1);
labeled(btex \hbox to 1.5em{\hfill$2\pi$} etex,2pi);
labeled(btex \hbox to 1.5em{\hfill$\frac{\pi}{2}$} etex,pi/2);
labeled(btex \hbox to 1.5em{\hfill$-\frac{\pi}{2}$} etex,-pi/2);
label.urt("$M$", point 1.4 of C);
label.llft("$O$", origin);
label.lrt("$I$", point 0 of C);
label.ulft("$J$", point 2 of C);
label.urt(btex $\frac{\pi}{2}$ etex, point 2 of C);

fill fullcircle scaled dotlabeldiam
shifted point 1.4 of C
withcolor blue;

endfig;
\end{mplibcode}
\end{document}

在此处输入图片描述

相关内容