Skip to main content

Needless to say: marmots love cheese. (This is taken from here and done with a typesetting system that is often said to be only good for equations. The spurious black lines in the holes come from the conversion to an animated gif, and are not there on the pdf file that gets created when the following code gets compiled with pdflatex.)

\documentclass[tikz,border=3.14mm]{standalone}
\usetikzlibrary{3d}
\usepackage{tikz-3dplot}
\makeatletter % https://tex.stackexchange.com/a/48776/121799
\tikzoption{canvas is xy plane at z}[]{%
  \def\tikz@plane@origin{\pgfpointxyz{0}{0}{#1}}%
  \def\tikz@plane@x{\pgfpointxyz{1}{0}{#1}}%
  \def\tikz@plane@y{\pgfpointxyz{0}{1}{#1}}%
  \tikz@canvas@is@plane
}
\makeatother
\newcommand{\DrawVerticalPart}[3][]{%
\draw[fill=yellow!30!orange,#1]
plot[variable=\x,domain=#2:#3,samples=30,smooth] 
({4*cos(\x)},{4*sin(\x)},0) -- ++(0,0,2)  --
plot[variable=\x,domain=#3:#2,samples=30,smooth] 
({4*cos(\x)},{4*sin(\x)},2) --cycle;
}
\newcommand{\CheesePiece}[1]{\ifcase#1
\or% 1: xz face
\begin{scope}[canvas is xz plane at y=0,transform shape]
\filldraw[fill=yellow!80!orange] (4,2) -- (4,0) --(0,0) -- (0,2) -- cycle;
\foreach \x/\y/\r in {0.4/0.6/0.3, 
0.5/1.3/0.2,
1.5/0.5/0.4,
1.5/0.5/0.4, 
2.1/1.5/0.3,
2.5/0.8/0.2, 
3.3/1.1/0.3}
{\shade[ball color=yellow!80!orange,opacity=0.2] (\x,\y) circle (\r);}
\end{scope}
\or% 2: yz face 
\begin{scope}[canvas is yz plane at x=0,transform shape]
\filldraw[fill=yellow!80!orange] (-4,2) -- (-4,0) --(0,0) -- (0,2) -- cycle;
\foreach \x/\y/\r in {-0.4/0.6/0.3, 
-0.5/1.3/0.2,
-1.5/0.5/0.4,
-1.5/0.5/0.4, 
-2.1/1.5/0.3,
-2.5/0.8/0.2, 
-3.3/1.1/0.3}
{\shade[ball color=yellow!80!orange,opacity=0.2] (\x,\y) circle (\r);}
\end{scope}
\or% 3: top
\draw[fill=yellow!30!orange] plot[variable=\x,domain=0:270,samples=90,smooth] 
({4*cos(\x)},{4*sin(\x)},2) -- (0,-4,2) -- (0,0,2) -- (4,0,2);
\or% 4: bottom
\draw[fill=yellow!30!orange] plot[variable=\x,domain=0:270,samples=90,smooth] 
({4*cos(\x)},{4*sin(\x)},0) -- (0,-4,0) -- (0,0,0) -- (4,0,0);
\fi} 
\begin{document}
\foreach \X in {0,5,...,355}%{45,135,225,315} 
{%\tdplotsetmaincoords{120+20*sin(\X)}{-135+45*cos(2*\X)}
\tdplotsetmaincoords{90+30*sin(\X)}{\X}
\begin{tikzpicture}
\path[use as bounding box] (-6,-3) rectangle (6,5);
\pgfmathtruncatemacro{\xtest}{sign(cos(\tdplotmainphi+90))}
\pgfmathtruncatemacro{\ytest}{sign(-cos(\tdplotmainphi))}
\pgfmathtruncatemacro{\ztest}{sign(cos(\tdplotmaintheta))}
%\node[anchor=north west] at (-6,5) {\X,\xtest,\ytest,\ztest};
\begin{scope}[tdplot_main_coords]
\ifnum\xtest=1
  \CheesePiece{2}
  \ifnum\ytest=1
    \CheesePiece{1}
    \DrawVerticalPart{0}{\tdplotmainphi-180}
    \DrawVerticalPart{\tdplotmainphi}{270}
  \else
    \DrawVerticalPart{0}{\tdplotmainphi-180}
  \fi
\else
  \ifnum\ytest=1
    \CheesePiece{1}
    \DrawVerticalPart{\tdplotmainphi}{270}
  \else
    \DrawVerticalPart{\tdplotmainphi}{\tdplotmainphi+180}
  \fi
\fi
\ifnum\ztest=1
\CheesePiece{4}
\else
\CheesePiece{3}
\fi
\end{scope}
\end{tikzpicture}}
\end{document}

enter image description here

user399040