Icosaedro truncado en TikZ-3dplot

Icosaedro truncado en TikZ-3dplot

Quiero dibujar un icosaedro truncado:

icosaedro truncado

Encontré un código con @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}

pie de tex

Solo me falta colorear las caras como la primera.

Respuesta1

Por suerte, este es el mismo problema quedibujando un fullereno. Es decir, parece que la naturaleza se inspiró en sus elecciones de moléculas en balones de fútbol. ;-) Entonces la respuesta es sí.

Para ejecutar el siguiente código, debe descargartikzlibrary3dtools.code.tex desdeeste repositorioy coloque el archivo en algún lugar donde LaTeX lo encuentre, como el directorio en el que se encuentra el archivo que contiene el siguiente código.

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

ingrese la descripción de la imagen aquí

Esta es una versión animada.

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

ingrese la descripción de la imagen aquí

Observe que esto varía tanto en phi como en theta para mostrar que funciona para todos los ángulos de visión. Dado que en realidad no rotamos el objeto sino que solo cambiamos los ángulos de visión, necesitamos mover la fuente de luz (L)para lograr la ilusión de girar el poliedro.

información relacionada