How to fill a hexagon with vertices obtained from intersecting lines?

This is in the case you do not want to compute things by yourself and let TikZ find the contour.

\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}

enter image description here


The shapes library can easily make hexagons:

\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}

enter image description here


Can be simplified with some \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}

enter image description here

and a shorter version without intersections:

\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} 

Tags:

Pstricks