tikz 与 tkz-euclide:使用 \tkzFillAngle 填充间隙

tikz 与 tkz-euclide:使用 \tkzFillAngle 填充间隙

我一直在使用tikztkz-euclide绘制三角形网格一部分的二维图。

v0我已绘制了如下 MWE 中的节点、边和角。问题是其中一个角的填充未覆盖两个边之间的整个区域。请注意红色填充与节点和之间的边之间可见的空白v5

我尝试了本网站上发布的许多关于如何使用tikz和/或标记角度的建议tkz-euclide。如果填充正确,此代码几乎完全符合我的要求。

\documentclass[]{article}
\usepackage{tikz, tkz-euclide}
\usetikzlibrary{calc,intersections}
\usetkzobj{all}
\tikzstyle{vertex}=[circle, color=black, fill=black, draw, inner sep=0pt, minimum size=6pt]
\tikzstyle{redVertex}=[circle, color=red!100, fill=red!50, draw, inner sep=0pt, minimum size=6pt]

\begin{document}
    \begin{tikzpicture}[x=3cm, y=3cm]
        \node (v0) at (1,1) [redVertex, label={[yshift=+0.3cm]right:$x_i$}] {};
        \node (v1) at (0,1) [vertex, label=left:$x_{k1}$] {};
        \node (v2) at (0,2) [vertex] {};
        \node (v3) at (1,2) [vertex] {};
        \node (v4) at (2,1) [vertex] {};
        \node (v5) at (2,0) [vertex, label=below:$x_{k2}$] {};
        \node (v6) at (1,0) [redVertex, label=below:$x_j$] {};

        \path[thick]
            (v1) edge [dashed] (v2) 
            (v1) edge (v0)
            (v1) edge (v6)
            (v2) edge [dashed] (v3)
            (v2) edge [dashed] (v0)
            (v3) edge [dashed] (v0)
            (v3) edge [dashed] (v4)
            (v0) edge [dashed] (v4)
            (v0) edge (v6)
            (v0) edge (v5)
            (v4) edge [dashed] (v5)
            (v6) edge (v5)
        ;

        \tkzMarkAngle[size=.3](v6,v1,v0)
                \tkzLabelAngle[pos=.15](v6,v1,v0){$\alpha_{ij}$}
        \tkzMarkAngle[size=.3](v0,v5,v6)
                \tkzLabelAngle[pos=.15](v0,v5,v6){$\beta_{ij}$}
        \tkzMarkAngle[size=.25](v1,v0,v6)
            \tkzLabelAngle[pos=-.20](v1,v0,v6){$\theta_{1}$}
        \tkzFillAngle[fill=red!50, size=.30](v6,v0,v5)
                \tkzLabelAngle[pos=.19](v6,v0,v5){$\theta_{2}$}
    \end{tikzpicture}
\end{document}

其结果为:

在此处输入图片描述

答案1

它看起来像一个锚点问题,但tkz-euclide似乎使用了与不同的抽象tikz,并且不允许您轻松访问锚点。

作为一种解决方法,将节点与其显示分开,并将显示推迟到绘制角度之后,我得到了以下结果:

输出

为了保持一致性,您可能希望对所有节点执行相同的操作。可能有一种更规范的方法来实现这一点,即使用tkz-euclidePoint抽象。

\documentclass[]{article}
\usepackage{tikz, tkz-euclide}
\usetikzlibrary{calc,intersections}
\usetkzobj{all}
\tikzstyle{vertex}=[circle, color=black, fill=black, draw, inner sep=0pt, minimum size=6pt]
\tikzstyle{redVertex}=[circle, color=red!100, fill=red!50, draw, inner sep=0pt, minimum size=6pt]

\begin{document}
\begin{tikzpicture}[x=3cm, y=3cm]
  \coordinate (v0) at (1,1) {};

  \node (v1) at (0,1) [vertex, label=left:$x_{k1}$] {};
  \node (v2) at (0,2) [vertex] {};
  \node (v3) at (1,2) [vertex] {};
  \node (v4) at (2,1) [vertex] {};
  \node (v5) at (2,0) [vertex, label=below:$x_{k2}$] {};
  \node (v6) at (1,0) [redVertex, label=below:$x_j$] {};

  \path[thick]
  (v1) edge [dashed] (v2) 
  (v1) edge (v0)
  (v1) edge (v6)
  (v2) edge [dashed] (v3)
  (v2) edge [dashed] (v0)
  (v3) edge [dashed] (v0)
  (v3) edge [dashed] (v4)
  (v0) edge [dashed] (v4)
  (v0) edge (v6)
  (v0) edge (v5)
  (v4) edge [dashed] (v5)
  (v6) edge (v5)
  ;

  \tkzMarkAngle[size=.3](v6,v1,v0)
  \tkzLabelAngle[pos=.15](v6,v1,v0){$\alpha_{ij}$}
  \tkzMarkAngle[size=.3](v0,v5,v6)
  \tkzLabelAngle[pos=.15](v0,v5,v6){$\beta_{ij}$}
  \tkzMarkAngle[size=.25](v1,v0,v6)
  \tkzLabelAngle[pos=-.20](v1,v0,v6){$\theta_{1}$}
  \tkzFillAngle[fill=red!50, size=.30](v6,v0,v5)
  \tkzLabelAngle[pos=.19](v6,v0,v5){$\theta_{2}$}

  \node (xi) at (v0) [redVertex, label={[yshift=+0.3cm]right:$x_i$}] {};
\end{tikzpicture}
\end{document}

答案2

平原元帖子解决方案,展示如何标记角度并整齐地定位标签。

在此处输入图片描述

prologues := 3;
outputtemplate := "%j%c.eps";

am_size := 1cm;
vardef angle_arc_path(expr a,b,c) = 
  fullcircle scaled 2am_size rotated angle (a-b) shifted b cutafter (b--c) 
  enddef;

vardef angle_label_pos(expr a,b,c) =  % unitvector helps avoid rounding errors
  right scaled 3/5 am_size rotated angle(unitvector(a-b)+unitvector(c-b)) shifted b
  enddef;

beginfig(1);

4cm = y2 = y3 = -y5 = -y6 = -x1 = -x2 = x4 = x5;
0   = y0 = y1 = y4 = x0 = x3 = x6;

color s_fill,s_line; s_fill = (.97,.47,.47); s_line = (.6,.1,.1);
pen thin; thin = pencircle scaled 0.25;

draw angle_arc_path(z6,z1,z0) withpen thin;
draw angle_arc_path(z0,z5,z6) withpen thin;
draw angle_arc_path(z1,z0,z6) withpen thin;

label(btex $\alpha_{ij}$ etex, angle_label_pos(z6,z1,z0));
label(btex $\beta_{ij}$  etex, angle_label_pos(z0,z5,z6));
label(btex $\theta_1$    etex, angle_label_pos(z1,z0,z6));

am_size := 1.2cm;
fill z0 -- angle_arc_path(z6,z0,z5) -- cycle withcolor s_fill;
draw       angle_arc_path(z6,z0,z5)          withcolor s_line withpen thin;
label(btex $\theta_2$    etex, angle_label_pos(z6,z0,z5));

drawoptions(dashed evenly);
draw z1 -- z2 -- z3 -- z4 -- z5; 
draw z0 -- z2; 
draw z0 -- z3;
draw z0 -- z4;
drawoptions();
draw z1 -- z6 -- z5;
draw z0 -- z1; 
draw z0 -- z5; 
draw z0 -- z6; 

forsuffixes $=1,2,3,4,5: fill fullcircle scaled 4 shifted z$; endfor
forsuffixes $=0,6: 
 fill fullcircle scaled 4 shifted z$ withcolor s_fill; 
 draw fullcircle scaled 4 shifted z$ withcolor s_line; 
 endfor

label.lft(btex $x_{k1}$ etex,z1);
label.bot(btex $x_{k2}$ etex,z5);
label.urt(btex $x_i$    etex,z0);
label.bot(btex $x_j$    etex,z6);

endfig;
end.

相关内容