如何绘制具有三角形面的二十面体

如何绘制具有三角形面的二十面体

我想用 TikZ 画出类似的东西。在这里我找到了几个关于如何绘制这种柏拉图立体的答案,但没有人像这样划分面。我并不真正关心颜色。对我来说真正重要的是画出像下图这样的折纸二十面体。这里我找到了一种绘制二十面体的方法,但无需对面进行细分。

我能怎么做?

谢谢!

在此处输入图片描述

答案1

你可以用库找到每个三角形中需要的点calc:它们是每个边的中点和三角形的质心。然后你可以编写一个宏来用这些划分绘制三角形。

像这样:

\documentclass[tikz,border=2mm]{standalone}
\usetikzlibrary{calc,perspective}

\definecolor{color1}{HTML}{1A5960}
\definecolor{color2}{HTML}{B7DAB9}
\definecolor{color3}{HTML}{AE5689}

\newcommand{\mytriangle}[4] % 3 poiints, 'shadow' opacity
{
  \coordinate (center) at ($1/3*(#1)+1/3*(#2)+1/3*(#3)$);
  \coordinate (m12)    at ($(#1)!0.5!(#2)$);
  \coordinate (m13)    at ($(#1)!0.5!(#3)$);
  \coordinate (m23)    at ($(#2)!0.5!(#3)$);
  \draw[fill=color1] (center) -- (m12) -- (#1) -- (m13) -- cycle;
  \draw[fill=color2] (center) -- (m12) -- (#2) -- (m23) -- cycle;
  \draw[fill=color3] (center) -- (m13) -- (#3) -- (m23) -- cycle;
  \draw[thick,fill=black,fill opacity=#4]  (#1) -- (#2)  -- (#3) -- cycle;
}

\begin{document}
\begin{tikzpicture}[line cap=round,line join=round,3d view={40}{35}]
% Dimensiones
\pgfmathsetmacro\ph{(1+sqrt(5))/2} % golden ratio
\pgfmathsetmacro\ed{3}             % edge   (half)
\pgfmathsetmacro\hh{\ed*\ph}       % height (half)
% Vértices
\coordinate (A1) at ( \hh,-\ed,  0);
\coordinate (B1) at ( \hh, \ed,  0);
\coordinate (C1) at (-\hh, \ed,  0);
\coordinate (D1) at (-\hh,-\ed,  0);
\coordinate (A2) at ( \ed,  0,-\hh);
\coordinate (B2) at (-\ed,  0,-\hh);
\coordinate (C2) at (-\ed,  0, \hh);
\coordinate (D2) at ( \ed,  0, \hh);
\coordinate (A3) at (  0, \hh,-\ed);
\coordinate (B3) at (  0, \hh, \ed);
\coordinate (C3) at (  0,-\hh, \ed);
\coordinate (D3) at (  0,-\hh,-\ed);
% Faces
\mytriangle{A2}{A1}{D3}{0.4};
\mytriangle{A1}{B1}{A2}{0.5};
\mytriangle{D1}{C3}{D3}{0.2};
\mytriangle{A1}{D3}{C3}{0.3};
\mytriangle{C3}{D2}{A1}{0.0};
\mytriangle{B1}{A1}{D2}{0.1};
\mytriangle{D2}{B3}{B1}{0.3};
\mytriangle{C2}{D1}{C3}{0.2};
\mytriangle{D2}{C3}{C2}{0.1};
\mytriangle{B3}{C2}{D2}{0.2};
\end{tikzpicture}
\end{document}

在此处输入图片描述

相关内容