使用 Metapost 填充角度

使用 Metapost 填充角度

如何使用交点和交点时间基元填充角度?

 \documentclass[border=5mm]{standalone}
 \usepackage{luamplib}
 \begin{document}
 \mplibtextextlabel{enable}
 \begin{mplibcode}
  beginfig(1);
   u  = 2cm;
   z0 = (0,0);
   z1 = (0,3u);
   z2 = (-3u,3u);

   path r;
   r = z0 -- z1 -- z2 --cycle;
   draw r;

   path c;
   c = fullcircle scaled 0.5u shifted z2;
   draw c cutbefore (z0 -- z2);

   pair A, B, C, D;
   A = c intersectiontimes r;
   C = c intersectionpoint (z1 -- z2);
   D = c intersectionpoint (z0 -- z2);

   numeric s, t;
   s = arctime xpart A of c;
   t = arctime ypart A of c;

   path b;
   b = C -- z2 -- D -- subpath(s, t) of c  -- cycle;
   fill b withcolor green;


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

在此处输入图片描述

答案1

c cutbefore (z0 -- z2)我认为您在填充时也可以使用。

\startMPpage[offset=1dk]

   u  = 2cm;
   z0 = (0,0);
   z1 = (0,3u);
   z2 = (-3u,3u);

   path r;
   r = z0 -- z1 -- z2 --cycle;

   path c;
   c = fullcircle  scaled 0.5u shifted z2;

   path b;
   b = c cutbefore (z0 -- z2)  -- z2 -- cycle ;

   fill b withcolor green;
   draw c cutbefore (z0 -- z2);
   draw r;

\stopMPpage

还要注意绘图的顺序,您可能希望先填充,然后再绘图。

有角的三角形

相关内容