如何提取正多边形某边的一部分?

如何提取正多边形某边的一部分?

有没有更好的方法可以绘制下图中没有 ab 段的图?我使用了以下代码

\documentclass[tikz,border=5]{standalone}
\usetikzlibrary{shapes.geometric}
\begin{document}
\begin{tikzpicture}[scale=5.5]
    \node[regular polygon, regular polygon sides=6, minimum size=10cm, rounded corners, draw] at (0,0) {};
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Erase ab segment
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    \draw[ultra thick, white](-.377,.787025) -- (.377,.787025);
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
   \draw(.377,.787025)arc(276:90:.06);
  \draw(-.377,.787025)arc(-96:90:.06);
   \def\mypath{(-.06,-.98) -- (-.06,-.95) arc (180:0:.06cm) -- (.06,-.98)}
    \foreach \t in {0,120,240} {\draw   [rotate=\t] \mypath;}
\def\mypath{(0,.98) -- (0,.98) arc (90:55.5:.98cm)}% -- (0,0)}
\draw   [rotate=56.5] \mypath;
\def\mypath{(0,.98) -- (0,.98) arc (90:55.5:.98cm)}% -- (0,0)}
\draw   [rotate=-22] \mypath;
\def\mypath{(0,.98) -- (0,.98) arc (90:-23:.98cm)}% -- (0,0)}
\draw   [rotate=176.5] \mypath;
\def\mypath{(0,.98) -- (0,.98) arc (90:-23:.98cm)}% -- (0,0)}
\draw   [rotate=296.5] \mypath;
\end{tikzpicture}
\end{document}

在此处输入图片描述

答案1

只需用适当的路径替换节点即可。您知道六边形外接圆的直径未缩放为 10cm(因为使用该scale选项时节点未缩放)。因此,六边形外接圆的缩放半径为 5cm / 5.5。

您还知道顶部两个半圆的起始和终止坐标。因此,您可以使用\draw极坐标轻松重新创建节点形状的轮廓。

在下面的代码示例中,我稍微简化了代码并将其更新为当前语法。

\documentclass[tikz,border=5]{standalone}
%\usetikzlibrary{shapes.geometric}

\begin{document}
\begin{tikzpicture}[scale=5.5]
    % \node[regular polygon, regular polygon sides=6, minimum size=10cm, rounded corners, draw] at (0,0) {};
    \draw[rounded corners] (-.377,.787025) -- (120:{5/5.5}) -- (180:{5/5.5}) -- (240:{5/5.5}) -- (300:{5/5.5}) -- (360:{5/5.5}) -- (60:{5/5.5}) -- (.377,.787025);
    %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    % Erase ab segment
    %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    % \draw[ultra thick, white](-.377,.787025) -- (.377,.787025);
    %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    \draw(.377,.787025) arc[start angle=276, end angle=90, radius=.06];
    \draw(-.377,.787025) arc[start angle=-96, end angle=90, radius=.06];
    \def\mypath{(-.06,-.98) -- (-.06,-.95) %
        arc[start angle=180, end angle=0, radius=.06] -- (.06,-.98)}
    \foreach \t in {0,120,240} {
        \draw[rotate=\t] \mypath;
    }
    \def\mypath{(0,.98) -- (0,.98) arc[start angle=90, end angle=55.5, radius=.98]}
    \draw[rotate=56.5] \mypath;
    \draw[rotate=-22] \mypath;
    \def\mypath{(0,.98) -- (0,.98) arc[start angle=90, end angle=-23, radius=.98cm]}
    \draw[rotate=176.5] \mypath;
    \draw[rotate=296.5] \mypath;
\end{tikzpicture}
\end{document}

在此处输入图片描述

相关内容