如何利用相交线获得的顶点填充六边形?

如何利用相交线获得的顶点填充六边形?
\documentclass[12pt,border=15pt]{standalone}
\usepackage{pst-poly,pst-eucl} 
\begin{document}
\begin{pspicture}(-4,-3.5)(4,3.5)
\psset{unit=3.5cm,PstPicture=false,dotsize=.03}
\PstHexagon[PolyName=A]
\pspolygon(A1)(A3)(A5)
\pspolygon(A2)(A4)(A6)
\foreach \m/\n/\p/\q in 
{3/2/1/90,2/1/2/45,1/6/3/-45,6/5/4/-90,5/4/5/-135,4/3/6/135}{%
\pstMiddleAB[PosAngle=\q]{A\m}{A\n}{M_\p}}
\foreach \m/\n/\p in {0/1/3,70/2/2,110/3/1,180/4/6,-110/5/5,-70/6/4} 
{\uput[\m](A\n){$A_\p$}}
\foreach \m/\n/\p/\q/\t/\r in {1/3/4/2/90/1,2/6/1/3/45/2,1/5/2/6/-45/3,1/5/4/6/-90/4,3/5/4/6/-135/5,2/4/3/5/135/6}{\pstInterLL[PosAngle=\t]{A\m}{A\n}{A\p}{A\q}{C_\r}}
\foreach \m/\n in {1/3,2/4,3/5,4/6,5/1,6/2}{\ncLine{M_\m}{C_\n}}
\foreach \i in {1,...,6}{\psdot(A\i)}
\end{pspicture}
\end{document}

在此处输入图片描述

我不想使用很多\pstInterLL调用来填充上面的绿色区域。

\documentclass[12pt,border=15pt]{standalone}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}
\def\r{3}
\pgfmathsetmacro{\rm}{\r *sqrt(3)/2}
\pgfmathsetmacro{\rc}{\rm *2/3}
\foreach \i in {1,...,6}{
    \draw (180-60*\i:\r) coordinate[label=$A_{\i}$] (a\i) --(120-60*\i:\r);
    \draw (180-60*\i:\r)--(60-60*\i:\r);
    \draw (150-60*\i:\rm) coordinate[label=$M_{\i}$] (m\i) --(30-60*\i:\rc);
    \draw (150-60*\i:\rc) coordinate[label=$C_{\i}$] (c\i) --(90-60*\i:\rc);
    \fill[black] (a\i) circle (0.05);
    \fill[black] (m\i) circle (0.05);
    \fill[black] (c\i) circle (0.05);
}
\end{tikzpicture}
\end{document}

在此处输入图片描述

太棒了...TikZ 代码很宁静。

\documentclass[12pt,border=15pt]{standalone}
\usepackage{pst-poly,pst-eucl} 
\begin{document}
\begin{pspicture}(-4,-3.5)(4,3.5)
\psset{unit=3.5cm,PstPicture=false,dotsize=.03}
\PstHexagon[PolyName=A]
\pspolygon(A1)(A3)(A5)
\pspolygon(A2)(A4)(A6)
\foreach \m/\n/\p/\q in 
{3/2/1/90,2/1/2/45,1/6/3/-45,6/5/4/-90,5/4/5/-135,4/3/6/135}{%
\pstMiddleAB[PosAngle=\q]{A\m}{A\n}{M\p}}
\foreach \m/\n/\p in {0/1/3,70/2/2,110/3/1,180/4/6,-110/5/5,-70/6/4} 
{\uput[\m](A\n){$A_\p$}}
\foreach \m/\n/\p/\q/\t/\r in {1/3/4/2/90/1,2/6/1/3/45/2,1/5/2/6/-45/3,1/5/4/6/-90/4,3/5/4/6/-135/5,2/4/3/5/135/6}{\pstInterLL[PosAngle=\t]{A\m}{A\n}{A\p}{A\q}{C\r}}
\foreach \m/\n/\p/\q/\r in 
{1/3/6/2/1,1/3/2/4/2,3/5/2/4/3,3/5/4/6/4,5/1/4/6/5,5/1/6/2/6} 
{\pstInterLL[PointName=none,PointSymbol=none]{M\m}{C\n}{M\p}{C\q}{i\r}}
\pspolygon*[linecolor=green](i1)(i2)(i3)(i4)(i5)(i6)
\foreach \m/\n in {1/3,2/4,3/5,4/6,5/1,6/2}{\ncLine{M\m}{C\n}}
\foreach \i in {1,...,6}{\psdot(A\i)}
\end{pspicture}
\end{document}

在此处输入图片描述

答案1

为了好玩,故意忽略了一些琐碎的台词。

\documentclass[pstricks,border=1cm,12pt]{standalone}
\usepackage{pst-eucl}

\begin{document}
\pspicture(-5,-5)(5,5)
    \foreach \i in {1,...,6}{%
        \pstGeonode[PointName=A_\i,PosAngle=\the\numexpr(-\i+1)*60+120](!5 \pscalculate{(-\i+1)*60+120} PtoC){A\the\numexpr\i-1}
        \pstGeonode[PointName=M_\i,PosAngle=\the\numexpr(-\i+1)*60+90](!5 60 sin mul \pscalculate{(-\i+1)*60+90} PtoC){M\the\numexpr\i-1}
        \pstGeonode[PointName=C_\i,PosAngle=\the\numexpr(-\i+1)*60+90](!3 \pscalculate{(-\i+1)*60+90} PtoC){C\the\numexpr\i-1}
        }
    \psnpolygon(0,5){A}
    \psnpolygon(0,5){C}
    \psset{PointName=none,PointSymbol=none}
    \pstInterLL{C0}{M4}{C1}{M5}{N0}
    \pnode(0,0){O}
    \foreach \i in {1,...,5}{\pstRotation[RotAngle=\the\numexpr60*\i]{O}{N0}[N\i]}
    \psnpolygon[fillstyle=solid,fillcolor=yellow](0,5){N}
\endpspicture
\end{document}

在此处输入图片描述

答案2

这是在你不想自己计算的情况下,让 TiZ 找到轮廓。

\documentclass[12pt,border=15pt]{standalone}
\usepackage{tikz}
\usetikzlibrary{intersections,backgrounds}
\begin{document}
\begin{tikzpicture}
\def\r{3}
\pgfmathsetmacro{\rm}{\r *sqrt(3)/2}
\pgfmathsetmacro{\rc}{\rm *2/3}
\foreach \i in {1,...,6}{
    \draw (180-60*\i:\r) coordinate[label=180-60*\i:$A_{\i}$] (a\i) --(120-60*\i:\r);
    \draw (180-60*\i:\r)--(60-60*\i:\r);
    \draw[name path global=\i-path] (150-60*\i:\rm) coordinate[label=150-60*\i:$M_{\i}$] (m\i) --(30-60*\i:\rc);
    \draw (150-60*\i:\rc) coordinate[label=150-60*\i:$C_{\i}$] (c\i) --(90-60*\i:\rc);
    \fill[black] (a\i) circle (0.05);
    \fill[black] (m\i) circle (0.05);
    \fill[black] (c\i) circle (0.05);
}
\foreach \i [remember=\i as \j (initially 6)] in {1,...,6}
{
\path[name intersections={of=\i-path and \j-path,by=i-\i}];
}
\begin{scope}[on background layer]
\fill[blue] plot[variable=\i,samples=6,domain=1:6] (i-\i);
\end{scope}
\end{tikzpicture}
\end{document}

在此处输入图片描述

答案3

形状库可以轻松制作六边形:

\documentclass[12pt,border=15pt]{standalone}
\usepackage{tikz}
\usetikzlibrary{shapes}
\begin{document}
\begin{tikzpicture}
\node[fill=green!50!black,regular polygon, regular polygon sides=6,
inner sep=0.73cm,rotate=-7] at (0,0) {};
\def\r{3}
\pgfmathsetmacro{\rm}{\r *sqrt(3)/2}
\pgfmathsetmacro{\rc}{\rm *2/3}
\foreach \i in {1,...,6}{
    \draw (180-60*\i:\r) coordinate[label=$A_{\i}$] (a\i) --(120-60*\i:\r);
    \draw (180-60*\i:\r)--(60-60*\i:\r);
    \draw (150-60*\i:\rm) coordinate[label=$M_{\i}$] (m\i) --(30-60*\i:\rc);
    \draw (150-60*\i:\rc) coordinate[label=$C_{\i}$] (c\i) --(90-60*\i:\rc);
    \fill[black] (a\i) circle (0.05);
    \fill[black] (m\i) circle (0.05);
    \fill[black] (c\i) circle (0.05);
}
\end{tikzpicture}
\end{document}

在此处输入图片描述

答案4

可以简化一些\psforeach

\documentclass[12pt,border=15pt]{standalone}
\usepackage{pst-eucl} 
\begin{document}
    \begin{pspicture}(-4,-3.5)(4,3.5)
    \degrees[6]
    \multido{\iA=1+1}{6}{\pnode(3;\iA){A\iA}\uput[\iA]{0}(A\iA){$A_\iA$}}
    \multido{\iA=1+1,\iB=2+1}{5}{\psLNode(A\iA)(A\iB){0.5}{M\iA}\uput[\iA]{0}(M\iA){$M_\iA$}}
    \psLNode(A6)(A1){0.5}{M6}\uput[6]{0}(M6){$M_6$}
    \pspolygon[linejoin=2](A1)(A3)(A5)(A6)(A2)(A4)(A6)(A5)(A4)(A3)(A2)(A1)(A5)(A6)
    \multido{\iA=1+1,\iB=3+1}{4}{%
      \psLNode(A\iA)(A\iB){0.333}{C\iA}\qdisk(C\iA){2pt}%
      \uput[\iA]{0}(C\iA){$C_\iA$}}
    \psLNode(A5)(A1){0.333}{C5}\qdisk(C5){2pt}\uput[5]{0}(C5){$C_5$}
    \psLNode(A6)(A2){0.333}{C6}\qdisk(C6){2pt}\uput[6]{0}(C6){$C_6$}
    \multido{\iA=3+1,\iB=1+1}{4}{\psline(M\iA)(C\iB)}
    \psline(M1)(C5)\psline(M2)(C6)
     \psset{PointName=none,PointSymbol=none}
     \pstInterLL{M1}{C5}{M2}{C6}{i1}     \pstInterLL{M2}{C6}{M3}{C1}{i2}
     \pstInterLL{M3}{C1}{M4}{C2}{i3}     \pstInterLL{M4}{C2}{M5}{C3}{i4}
     \pstInterLL{M5}{C3}{M6}{C4}{i5}     \pstInterLL{M6}{C4}{M1}{C5}{i6}
    \pspolygon*[linecolor=blue](i1)(i2)(i3)(i4)(i5)(i6)
\end{pspicture}

\end{document}

在此处输入图片描述

还有一个没有交集的较短版本:

\begin{pspicture}(-4,-3.5)(4,3.5)
    \degrees[6]
    \multido{\iA=1+1}{6}{\pnode(3;\iA){A\iA}\uput[\iA]{0}(A\iA){$A_\iA$}}
    \multido{\iA=1+1,\iB=2+1}{5}{\psLNode(A\iA)(A\iB){0.5}{M\iA}\uput[\iA]{0}(M\iA){$M_\iA$}}
    \psLNode(A6)(A1){0.5}{M6}\uput[6]{0}(M6){$M_6$}
    \pspolygon(A1)(A2)(A3)(A4)(A5)(A6)\pspolygon(A1)(A3)(A5)\pspolygon(A2)(A4)(A6)
    \multido{\iA=1+1,\iB=3+1}{4}{%
        \psLNode(A\iA)(A\iB){0.333}{C\iA}\qdisk(C\iA){2pt}%
        \uput[\iA]{0}(C\iA){$C_\iA$}}
    \psLNode(A5)(A1){0.333}{C5}\qdisk(C5){2pt}\uput[5]{0}(C5){$C_5$}
    \psLNode(A6)(A2){0.333}{C6}\qdisk(C6){2pt}\uput[6]{0}(C6){$C_6$}
    \multido{\iA=3+1,\iB=1+1}{4}{\psline(M\iA)(C\iB)}
    \psline(M1)(C5)\psline(M2)(C6)
    \pspolygon*[linecolor=red!40]%
      (1.19;0.9)(1.19;1.9)(1.19;2.9)(1.19;3.9)(1.19;4.9)(1.19;5.9)
\end{pspicture} 

相关内容