答案1
钛钾Z 没有 3D 引擎,所以我们需要按正确的顺序绘制元素。对于飞机的情况,已经开发了一些工具,我在这里使用。你需要3dtools 库来编译这个。
\documentclass[tikz,border=3mm]{standalone}
\usepackage{tikz-3dplot}
\usetikzlibrary{3dtools}
\begin{document}
% define a command for the projections (to become a part of the library)
\makeatletter
\newcommand\GetProj[2]{\begingroup
\pgfutil@tempcnta=0%
\edef\pgfutil@tmpa{0}%
\pgfutil@for\my@item:={#1}\do{%
\pgfmathsetmacro\mycoord{TD("\my@item")}%
\advance\pgfutil@tempcnta by1\relax
\pgfmathsetmacro{\pgfutil@tmpa}{\pgfutil@tmpa-screendepth(\mycoord)}%
}%
\pgfmathsetmacro{#2}{\pgfutil@tmpa/\pgfutil@tempcnta}%
\pgfmathsmuggle#2\endgroup}
\makeatother
% counter for 3d ordering
\newcounter{tdorder}
% set a sufficient number of layers (for more complex scenarios you need more)
\foreach \X in {1,...,40}
{\pgfdeclarelayer{layer\X}
\ifnum\X=1
\xdef\LstLayers{layer\X}
\else
\xdef\LstLayers{\LstLayers,layer\X}
\fi}
\pgfsetlayers\LstLayers
\tikzset{closed polygon/.style={insert path={foreach \Coord [count=\nCoord] in {#1}
{\ifnum\nCoord=1
\Coord
\else
-- \Coord
\fi} -- cycle}},polygon/.style={insert path={foreach \Coord [count=\nCoord] in {#1}
{\ifnum\nCoord=1
\Coord
\else
-- \Coord
\fi}}},
vertex poly/.style={insert path={foreach \Coord [count=\nCoord] in {#1}
{\ifnum\nCoord=1
\Coord node[vertex,vname=\Coord]{}
\else
-- \Coord node[vertex,vname=\Coord]{}
\fi}}},vertex/.style={circle,draw,fill=white,inner sep=2pt},
vname/.code={\def\vnameadd(##1){\edef\myvname{v-##1}}%
\expandafter\vnameadd#1\relax
\tikzset{alias=\myvname}%
}}
% main code
\foreach \X in {5,15,...,355}
{\tdplotsetmaincoords{90+30*sin(\X)}{\X}
\begin{tikzpicture}[tdplot_main_coords,scale=pi,
font=\sffamily,fill opacity=1,
declare function={phi=(1+sqrt(5))/2;},
line join=round,line cap=round]
\path[tdplot_screen_coords,use as bounding box] (-2,-2) rectangle (2,2);
% define the vertices (there are certainly superior naming conventions)
\path (0,0,0) coordinate (O)
(phi/2,1/2,0) coordinate (xypp) (phi/2,0,0) coordinate (xyp0)
(phi/2,-1/2,0) coordinate (xypm) (0,1/2,0) coordinate (xy0p)
(-phi/2,-1/2,0) coordinate (xymm) (-phi/2,0,0) coordinate (xym0)
(-phi/2,1/2,0) coordinate (xymp) (0,-1/2,0) coordinate (xy0m)
(0,phi/2,1/2) coordinate (yzpp) (0,phi/2,0) coordinate (yzp0)
(0,phi/2,-1/2) coordinate (yzpm) (0,0,1/2) coordinate (yz0p)
(0,-phi/2,-1/2) coordinate (yzmm) (0,-phi/2,0) coordinate (yzm0)
(0,-phi/2,1/2) coordinate (yzmp) (0,0,-1/2) coordinate (yz0m)
(1/2,0,phi/2) coordinate (xzpp) (0,0,phi/2) coordinate (xzp0)
(-1/2,0,phi/2) coordinate (xzpm) (1/2,0,0) coordinate (xz0p)
(-1/2,0,-phi/2) coordinate (xzmm) (0,0,-phi/2) coordinate (xzm0)
(1/2,0,-phi/2) coordinate (xzmp) (-1/2,0,0) coordinate (xz0m) ;
% define the plane data as a list of <drawing options>/<shape>/<vertices>
\def\PlaneData{%
{draw=none,fill=red}/closed polygon/{(xypp),(xyp0),(O),(xy0p)},%
{draw=none,fill=red}/closed polygon/{(xypm),(xyp0),(O),(xy0m)},%
{draw=none,fill=red}/closed polygon/{(xymp),(xym0),(O),(xy0p)},%
{draw=none,fill=red}/closed polygon/{(xymm),(xym0),(O),(xy0m)},%
{draw=none,fill=blue}/closed polygon/{(yzpp),(yzp0),(O),(yz0p)},%
{draw=none,fill=blue}/closed polygon/{(yzpm),(yzp0),(O),(yz0m)},%
{draw=none,fill=blue}/closed polygon/{(yzmp),(yzm0),(O),(yz0p)},%
{draw=none,fill=blue}/closed polygon/{(yzmm),(yzm0),(O),(yz0m)},%
{draw=none,fill=green!70!black}/closed polygon/{(xzpp),(xzp0),(O),(xz0p)},%
{draw=none,fill=green!70!black}/closed polygon/{(xzpm),(xzp0),(O),(xz0m)},%
{draw=none,fill=green!70!black}/closed polygon/{(xzmp),(xzm0),(O),(xz0p)},%
{draw=none,fill=green!70!black}/closed polygon/{(xzmm),(xzm0),(O),(xz0m)},%
{draw,thick}/vertex poly/{(xypp),(xzpp)},%
{draw,thick}/vertex poly/{(xypm),(xzpp)},%
{draw,thick}/vertex poly/{(xypp),(yzpp)},%
{draw,thick}/vertex poly/{(xymp),(yzpp)},%
{draw,thick}/vertex poly/{(xypm),(yzmp)},%
{draw,thick}/vertex poly/{(xymm),(yzmp)},%
{draw,thick}/vertex poly/{(xymp),(xzpm)},%
{draw,thick}/vertex poly/{(yzmp),(xzpm)},%
{draw,thick}/vertex poly/{(yzpp),(xzpm)},%
{draw,thick}/vertex poly/{(yzmp),(xzpp)},%
{draw,thick}/vertex poly/{(yzpp),(xzpp)},%
{draw,thick}/vertex poly/{(yzmm),(xzmm)},%
{draw,thick}/vertex poly/{(yzpm),(xzmm)},%
{draw,thick}/vertex poly/{(yzmm),(xzmp)},%
{draw,thick}/vertex poly/{(yzpm),(xzmp)},%
{draw,thick}/vertex poly/{(xymm),(xzmm)},%
{draw,thick}/vertex poly/{(xzpp),(xzpm)},%
{draw,thick}/vertex poly/{(xypp),(xzmp)},%
{draw,thick}/vertex poly/{(xypm),(xzmp)},%
{draw,thick}/vertex poly/{(xypp),(yzpm)},%
{draw,thick}/vertex poly/{(xymp),(yzpm)},%
{draw,thick}/vertex poly/{(xypm),(yzmm)},%
{draw,thick}/vertex poly/{(xymm),(yzmm)},%
{draw,thick}/vertex poly/{(xymm),(xzmm)},%
{draw,thick}/vertex poly/{(xymp),(xzmm)}}
% normal of screen (last row of the rotation matrix)
\path[overlay] ({sin(\tdplotmaintheta)*sin(\tdplotmainphi)},
{-1*sin(\tdplotmaintheta)*cos(\tdplotmainphi)},
{cos(\tdplotmaintheta)}) coordinate (n);
% build up the list of projections
\foreach \Style/\Poly/\CoordLst [count=\nC] in \PlaneData
{%
\GetProj{\CoordLst}{\currproj}
\ifnum\nC=1
\xdef\LstProj{\currproj}
\else
\xdef\LstProj{\LstProj,\currproj}
\fi}
% draw the planes in appropriate layers
\foreach \Style/\Poly/\CoordLst [count=\nC] in \PlaneData
{%
\GetProj{\CoordLst}{\currproj}
\setcounter{tdorder}{1}
\foreach \Proj in \LstProj
{\pgfmathtruncatemacro{\itest}{ifthenelse(\Proj<\currproj,1,0)}
\ifnum\itest=1
\stepcounter{tdorder}
\fi}
\begin{pgfonlayer}{layer\number\value{tdorder}}
\edef\temp{\noexpand\path[\Style,\Poly={\CoordLst}];}
\temp
\end{pgfonlayer}
}
\end{tikzpicture}}
\end{document}