TikZ-3dplot 中的截角二十面体

TikZ-3dplot 中的截角二十面体

我想画一个截角二十面体:

截角二十面体

我找到了@Symbol 1 的代码

\documentclass[border=9,tikz]{standalone}

\usepackage{tikz-3dplot}

\begin{document}

    \tdplotsetmaincoords{2.71828+\s}{2.71828+\s*2}
    \tikz[tdplot_main_coords,scale=.1]{
        \path(-150cm,-150cm)(150cm,150cm);
        \draw
            (20.1774,0,-97.9432)--(40.3548,-32.6477,-85.4729)--(73.0026,-20.1774,-65.2955)--(73.0026,20.1774,-65.2955)--(40.3548,32.6477,-85.4729)--cycle
            (20.1774,0,97.9432)--(40.3548,32.6477,85.4729)--(73.0026,20.1774,65.2955)--(73.0026,-20.1774,65.2955)--(40.3548,-32.6477,85.4729)--cycle
            (-20.1774,0,97.9432)--(-40.3548,-32.6477,85.4729)--(-73.0026,-20.1774,65.2955)--(-73.0026,20.1774,65.2955)--(-40.3548,32.6477,85.4729)--cycle
            (-20.1774,0,-97.9432)--(-40.3548,32.6477,-85.4729)--(-73.0026,20.1774,-65.2955)--(-73.0026,-20.1774,-65.2955)--(-40.3548,-32.6477,-85.4729)--cycle
            (97.9432,20.1774,0)--(85.4729,40.3548,32.6477)--(65.2955,73.0026,20.1774)--(65.2955,73.0026,-20.1774)--(85.4729,40.3548,-32.6477)--cycle
            (0,97.9432,20.1774)--(32.6477,85.4729,40.3548)--(20.1774,65.2955,73.0026)--(-20.1774,65.2955,73.0026)--(-32.6477,85.4729,40.3548)--cycle
            (-97.9432,20.1774,0)--(-85.4729,40.3548,-32.6477)--(-65.2955,73.0026,-20.1774)--(-65.2955,73.0026,20.1774)--(-85.4729,40.3548,32.6477)--cycle
            (0,97.9432,-20.1774)--(-32.6477,85.4729,-40.3548)--(-20.1774,65.2955,-73.0026)--(20.1774,65.2955,-73.0026)--(32.6477,85.4729,-40.3548)--cycle
            (-97.9432,-20.1774,0)--(-85.4729,-40.3548,32.6477)--(-65.2955,-73.0026,20.1774)--(-65.2955,-73.0026,-20.1774)--(-85.4729,-40.3548,-32.6477)--cycle
            (0,-97.9432,-20.1774)--(32.6477,-85.4729,-40.3548)--(20.1774,-65.2955,-73.0026)--(-20.1774,-65.2955,-73.0026)--(-32.6477,-85.4729,-40.3548)--cycle
            (97.9432,-20.1774,0)--(85.4729,-40.3548,-32.6477)--(65.2955,-73.0026,-20.1774)--(65.2955,-73.0026,20.1774)--(85.4729,-40.3548,32.6477)--cycle
            (0,-97.9432,20.1774)--(-32.6477,-85.4729,40.3548)--(-20.1774,-65.2955,73.0026)--(20.1774,-65.2955,73.0026)--(32.6477,-85.4729,40.3548)--cycle
            (85.4729,40.3548,-32.6477)--(97.9432,20.1774,0)--(97.9432,-20.1774,0)--(85.4729,-40.3548,-32.6477)--(73.0026,-20.1774,-65.2955)--(73.0026,20.1774,-65.2955)--cycle
            (85.4729,-40.3548,32.6477)--(97.9432,-20.1774,0)--(97.9432,20.1774,0)--(85.4729,40.3548,32.6477)--(73.0026,20.1774,65.2955)--(73.0026,-20.1774,65.2955)--cycle
            (-85.4729,40.3548,32.6477)--(-97.9432,20.1774,0)--(-97.9432,-20.1774,0)--(-85.4729,-40.3548,32.6477)--(-73.0026,-20.1774,65.2955)--(-73.0026,20.1774,65.2955)--cycle
            (-85.4729,-40.3548,-32.6477)--(-97.9432,-20.1774,0)--(-97.9432,20.1774,0)--(-85.4729,40.3548,-32.6477)--(-73.0026,20.1774,-65.2955)--(-73.0026,-20.1774,-65.2955)--cycle
            (40.3548,32.6477,-85.4729)--(20.1774,0,-97.9432)--(-20.1774,0,-97.9432)--(-40.3548,32.6477,-85.4729)--(-20.1774,65.2955,-73.0026)--(20.1774,65.2955,-73.0026)--cycle
            (-40.3548,-32.6477,-85.4729)--(-20.1774,0,-97.9432)--(20.1774,0,-97.9432)--(40.3548,-32.6477,-85.4729)--(20.1774,-65.2955,-73.0026)--(-20.1774,-65.2955,-73.0026)--cycle
            (40.3548,-32.6477,85.4729)--(20.1774,0,97.9432)--(-20.1774,0,97.9432)--(-40.3548,-32.6477,85.4729)--(-20.1774,-65.2955,73.0026)--(20.1774,-65.2955,73.0026)--cycle
            (-40.3548,32.6477,85.4729)--(-20.1774,0,97.9432)--(20.1774,0,97.9432)--(40.3548,32.6477,85.4729)--(20.1774,65.2955,73.0026)--(-20.1774,65.2955,73.0026)--cycle
            (32.6477,85.4729,-40.3548)--(0,97.9432,-20.1774)--(0,97.9432,20.1774)--(32.6477,85.4729,40.3548)--(65.2955,73.0026,20.1774)--(65.2955,73.0026,-20.1774)--cycle
            (-32.6477,85.4729,40.3548)--(0,97.9432,20.1774)--(0,97.9432,-20.1774)--(-32.6477,85.4729,-40.3548)--(-65.2955,73.0026,-20.1774)--(-65.2955,73.0026,20.1774)--cycle
            (-32.6477,-85.4729,-40.3548)--(0,-97.9432,-20.1774)--(0,-97.9432,20.1774)--(-32.6477,-85.4729,40.3548)--(-65.2955,-73.0026,20.1774)--(-65.2955,-73.0026,-20.1774)--cycle
            (32.6477,-85.4729,40.3548)--(0,-97.9432,20.1774)--(0,-97.9432,-20.1774)--(32.6477,-85.4729,-40.3548)--(65.2955,-73.0026,-20.1774)--(65.2955,-73.0026,20.1774)--cycle
            (20.1774,65.2955,-73.0026)--(32.6477,85.4729,-40.3548)--(65.2955,73.0026,-20.1774)--(85.4729,40.3548,-32.6477)--(73.0026,20.1774,-65.2955)--(40.3548,32.6477,-85.4729)--cycle
            (85.4729,40.3548,32.6477)--(73.0026,20.1774,65.2955)--(40.3548,32.6477,85.4729)--(20.1774,65.2955,73.0026)--(32.6477,85.4729,40.3548)--(65.2955,73.0026,20.1774)--cycle
            (-73.0026,20.1774,65.2955)--(-40.3548,32.6477,85.4729)--(-20.1774,65.2955,73.0026)--(-32.6477,85.4729,40.3548)--(-65.2955,73.0026,20.1774)--(-85.4729,40.3548,32.6477)--cycle
            (-85.4729,40.3548,-32.6477)--(-65.2955,73.0026,-20.1774)--(-32.6477,85.4729,-40.3548)--(-20.1774,65.2955,-73.0026)--(-40.3548,32.6477,-85.4729)--(-73.0026,20.1774,-65.2955)--cycle
            (-85.4729,-40.3548,32.6477)--(-65.2955,-73.0026,20.1774)--(-32.6477,-85.4729,40.3548)--(-20.1774,-65.2955,73.0026)--(-40.3548,-32.6477,85.4729)--(-73.0026,-20.1774,65.2955)--cycle
            (-20.1774,-65.2955,-73.0026)--(-32.6477,-85.4729,-40.3548)--(-65.2955,-73.0026,-20.1774)--(-85.4729,-40.3548,-32.6477)--(-73.0026,-20.1774,-65.2955)--(-40.3548,-32.6477,-85.4729)--cycle
            (85.4729,-40.3548,-32.6477)--(65.2955,-73.0026,-20.1774)--(32.6477,-85.4729,-40.3548)--(20.1774,-65.2955,-73.0026)--(40.3548,-32.6477,-85.4729)--(73.0026,-20.1774,-65.2955)--cycle
            (20.1774,-65.2955,73.0026)--(32.6477,-85.4729,40.3548)--(65.2955,-73.0026,20.1774)--(85.4729,-40.3548,32.6477)--(73.0026,-20.1774,65.2955)--(40.3548,-32.6477,85.4729)--cycle;
    }

\end{document}

特克斯福特

我只需要像第一个那样给脸部上色。

答案1

幸运的是,这个问题与绘制富勒烯。也就是说,大自然似乎是从足球中获得了对分子选择的灵感。;-) 所以答案是肯定的。

为了运行以下代码,您需要tikzlibrary3dtools.code.tex从以下位置下载这个存储库,并将该文件放在 LaTeX 可以找到的地方,例如包含以下代码的文件所在的目录。

\documentclass[tikz,border=3mm]{standalone}
\usepackage{tikz-3dplot}
\usetikzlibrary{backgrounds,3dtools}
\makeatletter
% slightly improved (?) version of dim from pgfmathfunctions.misc.code.tex
% at least in this application dim does not give the right results
\pgfmathdeclarefunction{mdim}{1}{%
  \begingroup
    \pgfmath@count=0\relax
    \expandafter\pgfmath@mdim@i#1\pgfmath@token@stop
    \edef\pgfmathresult{\the\pgfmath@count}%
    \pgfmath@smuggleone\pgfmathresult%
  \endgroup}
\def\pgfmath@mdim@i#1{%
    \ifx\pgfmath@token@stop#1%
    \else
      \advance\pgfmath@count by 1\relax
      \expandafter\pgfmath@mdim@i
    \fi}  
%membership test    
\pgfmathdeclarefunction{memberQ}{2}{%
  \begingroup%
    \edef\pgfutil@tmpb{0}%memberQ({\lstPast},\inow)
    \edef\pgfutil@tmpa{#2}%
    \expandafter\pgfmath@member@i#1\pgfmath@token@stop
    \edef\pgfmathresult{\pgfutil@tmpb}%
    \pgfmath@smuggleone\pgfmathresult%
  \endgroup}
\def\pgfmath@member@i#1{%
    \ifx\pgfmath@token@stop#1%
    \else
      \edef\pgfutil@tmpc{#1}%
      \ifx\pgfutil@tmpc\pgfutil@tmpa\relax%
      \gdef\pgfutil@tmpb{1}%
      \fi%
      \expandafter\pgfmath@member@i
    \fi}        
\makeatother    
% 
\begin{document}
\tdplotsetmaincoords{70}{0}
\begin{tikzpicture}[tdplot_main_coords,line cap=round,line join=round]
\path foreach \Coord [count=\X] in {(-0.16246,-2.11803,1.27598),
 (-0.16246,2.11803,1.27598),(0.16246,-2.11803,-1.27598),(0.16246,2.11803,-1.27598),
 (-0.262866,-0.809017,-2.32744),(-0.262866,-2.42705,-0.425325),(-0.262866,0.809017,-2.32744),
 (-0.262866,2.42705,-0.425325),(0.262866,-0.809017,2.32744),(0.262866,-2.42705,0.425325),
 (0.262866,0.809017,2.32744),(0.262866,2.42705,0.425325),(0.688191,-0.5,-2.32744),
 (0.688191,0.5,-2.32744),(1.21392,-2.11803,0.425325),(1.21392,2.11803,0.425325),
 (-2.06457,-0.5,1.27598),(-2.06457,0.5,1.27598),(-1.37638,-1.,1.80171),
 (-1.37638,1.,1.80171),(-1.37638,-1.61803,-1.27598),(-1.37638,1.61803,-1.27598),
 (-0.688191,-0.5,2.32744),(-0.688191,0.5,2.32744),(1.37638,-1.,-1.80171),
 (1.37638,1.,-1.80171),(1.37638,-1.61803,1.27598),(1.37638,1.61803,1.27598),
 (-1.7013,0.,-1.80171),(1.7013,0.,1.80171),(-1.21392,-2.11803,-0.425325),
 (-1.21392,2.11803,-0.425325),(-1.96417,-0.809017,-1.27598),(-1.96417,0.809017,-1.27598),
 (2.06457,-0.5,-1.27598),(2.06457,0.5,-1.27598),(2.22703,-1.,-0.425325),
 (2.22703,1.,-0.425325),(2.38949,-0.5,0.425325),(2.38949,0.5,0.425325),
 (-1.11352,-1.80902,1.27598),(-1.11352,1.80902,1.27598),(1.11352,-1.80902,-1.27598),
 (1.11352,1.80902,-1.27598),(-2.38949,-0.5,-0.425325),(-2.38949,0.5,-0.425325),
 (-1.63925,-1.80902,0.425325),(-1.63925,1.80902,0.425325),(1.63925,-1.80902,-0.425325),
 (1.63925,1.80902,-0.425325),(1.96417,-0.809017,1.27598),(1.96417,0.809017,1.27598),
 (0.850651,0.,2.32744),(-2.22703,-1.,0.425325),(-2.22703,1.,0.425325),
 (-0.850651,0.,-2.32744),(-0.525731,-1.61803,-1.80171),(-0.525731,1.61803,-1.80171),
 (0.525731,-1.61803,1.80171),(0.525731,1.61803,1.80171)}
  {\Coord coordinate (p\X) \pgfextra{\xdef\NumVertices{\X}}};
 %\message{number of vertices is \NumVertices^^J} 
 % normal of screen 
 \path[overlay] ({sin(\tdplotmaintheta)*sin(\tdplotmainphi)},
    {-1*sin(\tdplotmaintheta)*cos(\tdplotmainphi)},
    {cos(\tdplotmaintheta)}) coordinate (n)
    (1,1,1)  coordinate (L); 
 \edef\lstPast{0}
 \foreach \poly in 
 {{53, 11, 24, 23, 9}, {51, 39, 40, 52, 30}, {60, 28, 16, 12, 2}, {20, 
  42, 48, 55, 18}, {19, 17, 54, 47, 41}, {1, 10, 15, 27, 59}, {36, 26,
   44, 50, 38}, {4, 58, 22, 32, 8}, {34, 29, 33, 45, 46}, {21, 57, 3, 
  6, 31}, {37, 49, 43, 25, 35}, {13, 5, 56, 7, 14}, {9, 59, 27, 51, 
  30, 53}, {53, 30, 52, 28, 60, 11}, {11, 60, 2, 42, 20, 24}, {24, 20,
   18, 17, 19, 23}, {23, 19, 41, 1, 59, 9}, {13, 25, 43, 3, 57, 
  5}, {5, 57, 21, 33, 29, 56}, {56, 29, 34, 22, 58, 7}, {7, 58, 4, 44,
   26, 14}, {14, 26, 36, 35, 25, 13}, {40, 38, 50, 16, 28, 52}, {16, 
  50, 44, 4, 8, 12}, {12, 8, 32, 48, 42, 2}, {48, 32, 22, 34, 46, 
  55}, {55, 46, 45, 54, 17, 18}, {54, 45, 33, 21, 31, 47}, {47, 31, 6,
   10, 1, 41}, {10, 6, 3, 43, 49, 15}, {15, 49, 37, 39, 51, 27}, {39, 
  37, 35, 36, 38, 40}}
 {
  \pgfmathtruncatemacro{\ione}{{\poly}[0]}
  \pgfmathtruncatemacro{\itwo}{{\poly}[1]}
  \pgfmathtruncatemacro{\ithree}{{\poly}[2]}
  \path[overlay,3d coordinate={(dA)=(p\itwo)-(p\ione)},
   3d coordinate={(dB)=(p\itwo)-(p\ithree)},
   3d coordinate={(nA)=(dA)x(dB)}];
  \pgfmathtruncatemacro{\jtest}{sign(TD("(nA)o(p\ione)"))}
  % make sure that the normal points outwards
  \ifnum\jtest<0
   \path[overlay,3d coordinate={(nA)=(dB)x(dA)}];
  \fi
  % compute projection the normal of the polygon on the normal of screen    
  \pgfmathsetmacro\myproj{TD("(nA)o(n)")}
  \pgfmathsetmacro\lproj{TD("(nA)o(L)")}
  \pgfmathtruncatemacro{\itest}{sign(\myproj)}
  \pgfmathtruncatemacro{\cf}{70+20*\lproj}
  \pgfmathtruncatemacro{\mydim}{mdim(\poly)}
  \ifnum\itest>-1 
   \draw[ultra thin] \ifnum\mydim=6 [fill=red!\cf!black]
   \else [fill=black]
   \fi
   plot[samples at=\poly,variable=\x](p\x) -- cycle; 
  \else
   \begin{scope}[on background layer] 
    \draw[gray!20,ultra thin] \ifnum\mydim=6 [fill=red!\cf!black]
   \else [fill=black]
   \fi
    plot[samples at=\poly,variable=\x](p\x) -- cycle;  
   \end{scope}
  \fi
  }  
\end{tikzpicture}
\end{document}

在此处输入图片描述

此为动画版。

\documentclass[tikz,border=3mm]{standalone}
\usepackage{tikz-3dplot}
\usetikzlibrary{backgrounds,3dtools}
\makeatletter
% slightly improved (?) version of dim from pgfmathfunctions.misc.code.tex
% at least in this application dim does not give the right results
\pgfmathdeclarefunction{mdim}{1}{%
  \begingroup
    \pgfmath@count=0\relax
    \expandafter\pgfmath@mdim@i#1\pgfmath@token@stop
    \edef\pgfmathresult{\the\pgfmath@count}%
    \pgfmath@smuggleone\pgfmathresult%
  \endgroup}
\def\pgfmath@mdim@i#1{%
    \ifx\pgfmath@token@stop#1%
    \else
      \advance\pgfmath@count by 1\relax
      \expandafter\pgfmath@mdim@i
    \fi}  
%membership test    
\pgfmathdeclarefunction{memberQ}{2}{%
  \begingroup%
    \edef\pgfutil@tmpb{0}%memberQ({\lstPast},\inow)
    \edef\pgfutil@tmpa{#2}%
    \expandafter\pgfmath@member@i#1\pgfmath@token@stop
    \edef\pgfmathresult{\pgfutil@tmpb}%
    \pgfmath@smuggleone\pgfmathresult%
  \endgroup}
\def\pgfmath@member@i#1{%
    \ifx\pgfmath@token@stop#1%
    \else
      \edef\pgfutil@tmpc{#1}%
      \ifx\pgfutil@tmpc\pgfutil@tmpa\relax%
      \gdef\pgfutil@tmpb{1}%
      \fi%
      \expandafter\pgfmath@member@i
    \fi}        
\makeatother    
% 
\begin{document}
\foreach \Angle in {0,5,...,355}
{\tdplotsetmaincoords{90+30*sin(2*\Angle)}{\Angle}
\begin{tikzpicture}[tdplot_main_coords,line cap=round,line join=round]
\path foreach \Coord [count=\X] in {(-0.16246,-2.11803,1.27598),
 (-0.16246,2.11803,1.27598),(0.16246,-2.11803,-1.27598),(0.16246,2.11803,-1.27598),
 (-0.262866,-0.809017,-2.32744),(-0.262866,-2.42705,-0.425325),(-0.262866,0.809017,-2.32744),
 (-0.262866,2.42705,-0.425325),(0.262866,-0.809017,2.32744),(0.262866,-2.42705,0.425325),
 (0.262866,0.809017,2.32744),(0.262866,2.42705,0.425325),(0.688191,-0.5,-2.32744),
 (0.688191,0.5,-2.32744),(1.21392,-2.11803,0.425325),(1.21392,2.11803,0.425325),
 (-2.06457,-0.5,1.27598),(-2.06457,0.5,1.27598),(-1.37638,-1.,1.80171),
 (-1.37638,1.,1.80171),(-1.37638,-1.61803,-1.27598),(-1.37638,1.61803,-1.27598),
 (-0.688191,-0.5,2.32744),(-0.688191,0.5,2.32744),(1.37638,-1.,-1.80171),
 (1.37638,1.,-1.80171),(1.37638,-1.61803,1.27598),(1.37638,1.61803,1.27598),
 (-1.7013,0.,-1.80171),(1.7013,0.,1.80171),(-1.21392,-2.11803,-0.425325),
 (-1.21392,2.11803,-0.425325),(-1.96417,-0.809017,-1.27598),(-1.96417,0.809017,-1.27598),
 (2.06457,-0.5,-1.27598),(2.06457,0.5,-1.27598),(2.22703,-1.,-0.425325),
 (2.22703,1.,-0.425325),(2.38949,-0.5,0.425325),(2.38949,0.5,0.425325),
 (-1.11352,-1.80902,1.27598),(-1.11352,1.80902,1.27598),(1.11352,-1.80902,-1.27598),
 (1.11352,1.80902,-1.27598),(-2.38949,-0.5,-0.425325),(-2.38949,0.5,-0.425325),
 (-1.63925,-1.80902,0.425325),(-1.63925,1.80902,0.425325),(1.63925,-1.80902,-0.425325),
 (1.63925,1.80902,-0.425325),(1.96417,-0.809017,1.27598),(1.96417,0.809017,1.27598),
 (0.850651,0.,2.32744),(-2.22703,-1.,0.425325),(-2.22703,1.,0.425325),
 (-0.850651,0.,-2.32744),(-0.525731,-1.61803,-1.80171),(-0.525731,1.61803,-1.80171),
 (0.525731,-1.61803,1.80171),(0.525731,1.61803,1.80171)}
  {\Coord coordinate (p\X) \pgfextra{\xdef\NumVertices{\X}}};
 %\message{number of vertices is \NumVertices^^J} 
 % normal of screen and "light source"
 \path[overlay] ({sin(\tdplotmaintheta)*sin(\tdplotmainphi)},
    {-1*sin(\tdplotmaintheta)*cos(\tdplotmainphi)},
    {cos(\tdplotmaintheta)}) coordinate (n)
    ({sin(\tdplotmaintheta+20)*sin(\tdplotmainphi+40)},
    {-1*sin(\tdplotmaintheta+20)*cos(\tdplotmainphi+40)},
    {cos(\tdplotmaintheta+20)})  coordinate (L);; 
 \edef\lstPast{0}
 \foreach \poly in 
 {{53, 11, 24, 23, 9}, {51, 39, 40, 52, 30}, {60, 28, 16, 12, 2}, {20, 
  42, 48, 55, 18}, {19, 17, 54, 47, 41}, {1, 10, 15, 27, 59}, {36, 26,
   44, 50, 38}, {4, 58, 22, 32, 8}, {34, 29, 33, 45, 46}, {21, 57, 3, 
  6, 31}, {37, 49, 43, 25, 35}, {13, 5, 56, 7, 14}, {9, 59, 27, 51, 
  30, 53}, {53, 30, 52, 28, 60, 11}, {11, 60, 2, 42, 20, 24}, {24, 20,
   18, 17, 19, 23}, {23, 19, 41, 1, 59, 9}, {13, 25, 43, 3, 57, 
  5}, {5, 57, 21, 33, 29, 56}, {56, 29, 34, 22, 58, 7}, {7, 58, 4, 44,
   26, 14}, {14, 26, 36, 35, 25, 13}, {40, 38, 50, 16, 28, 52}, {16, 
  50, 44, 4, 8, 12}, {12, 8, 32, 48, 42, 2}, {48, 32, 22, 34, 46, 
  55}, {55, 46, 45, 54, 17, 18}, {54, 45, 33, 21, 31, 47}, {47, 31, 6,
   10, 1, 41}, {10, 6, 3, 43, 49, 15}, {15, 49, 37, 39, 51, 27}, {39, 
  37, 35, 36, 38, 40}}
 {
  \pgfmathtruncatemacro{\ione}{{\poly}[0]}
  \pgfmathtruncatemacro{\itwo}{{\poly}[1]}
  \pgfmathtruncatemacro{\ithree}{{\poly}[2]}
  \path[overlay,3d coordinate={(dA)=(p\itwo)-(p\ione)},
   3d coordinate={(dB)=(p\itwo)-(p\ithree)},
   3d coordinate={(nA)=(dA)x(dB)}];
  \pgfmathtruncatemacro{\jtest}{sign(TD("(nA)o(p\ione)"))}
  % make sure that the normal points outwards
  \ifnum\jtest<0
   \path[overlay,3d coordinate={(nA)=(dB)x(dA)}];
  \fi
  % compute projection the normal of the polygon on the normal of screen    
  \pgfmathsetmacro\myproj{TD("(nA)o(n)")}
  \pgfmathsetmacro\lproj{TD("(nA)o(L)")}
  \pgfmathtruncatemacro{\itest}{sign(\myproj)}
  \pgfmathtruncatemacro{\cf}{70+20*\lproj}
  \pgfmathtruncatemacro{\mydim}{mdim(\poly)}
  \ifnum\itest>-1 
   \draw[ultra thin] \ifnum\mydim=6 [fill=red!\cf!black]
   \else [fill=black]
   \fi
   plot[samples at=\poly,variable=\x](p\x) -- cycle; 
  \else
   \begin{scope}[on background layer] 
    \draw[gray!20,ultra thin] \ifnum\mydim=6 [fill=red!\cf!black]
   \else [fill=black]
   \fi
    plot[samples at=\poly,variable=\x](p\x) -- cycle;  
   \end{scope}
  \fi
  }  
\end{tikzpicture}}
\end{document}

在此处输入图片描述

请注意,这会改变 phi 和 theta,以表明它适用于所有视角。由于我们实际上并没有旋转物体,而只是改变视角,因此我们需要移动光源,(L)以实现旋转多面体的幻觉。

相关内容