如何擷取正多邊形邊的一部分?

如何擷取正多邊形邊的一部分?

有沒有更好的方法來繪製沒有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

只需將節點替換為正確的路徑即可。您知道六邊形外接圓的直徑是未縮放的 10 公分(因為使用該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}

在此輸入影像描述

相關內容