18

Following this question about representation of a darkhole, how could one represent a tikzduck or a tikzmarmot being swallowed by it.

No animal should be harmed in the process.

I think this solution based on non-linear transforms or this one using transform canvas could help, but I don't know where to start really.

\documentclass[border=3.14pt]{standalone}
\usepackage{pgfplots}
\usepgfplotslibrary{colorbrewer}
\pgfplotsset{compat=newest}
\begin{document}
    \begin{tikzpicture}
        \begin{axis}[
            axis line style={draw=none},
            tick style={draw=none},
            colormap/Blues,
            data cs=polar,
            samples=50,
            domain=0:360,
            y domain=1:10,
            declare function={darkhole(\r)={-exp(-\r)};
                % added functions to calculate cartesian coordinates from polar coordinates
                pol2cartX(\angle,\radius) = \radius * cos(\angle);
                pol2cartY(\angle,\radius) = \radius * sin(\angle);
            },
            xtick={\empty},
            ytick={\empty},
            ztick={\empty},
        ]
            \addplot3 [surf,shader=flat,draw=black,z buffer=sort] {darkhole(y)};
        \end{axis}
    \end{tikzpicture}
\end{document}

enter image description here

  • "No animal should be harmed" is not a very tough requirement because we are dealing with beings here. You need to say "No animal nor being is to be harmed!". – Schrödinger's cat Aug 27 at 1:36
33

A marmot would only fall in a black hole if it is a wormhole. Other than that, you need to draw the black hole in two stretches, first background, then the passenger(s), and then the foreground.

\documentclass[tikz,border=3.14pt]{standalone}
\usepackage{pgfplots}
\usepgfplotslibrary{colorbrewer}
\pgfplotsset{compat=1.16}
\usepackage{tikzmarmots}
\usepgfmodule{nonlineartransformations}
\makeatletter
\def\blackholetransformation{%
\pgf@xa=\pgf@x%
\pgf@ya=\pgf@y%
\pgfmathsetmacro{\myy}{\pgf@ya-40*exp(-0.04*abs(\the\pgf@xa))}%
\pgf@y=\myy pt}
\makeatother
\newsavebox\Back
\newsavebox\Front
\sbox\Back{\begin{tikzpicture}
        \begin{axis}[
            axis line style={draw=none},
            tick style={draw=none},
            colormap/Blues,
            data cs=polar,
            samples=25,
            y domain=1:10,
            declare function={darkhole(\r)={exp(-1)-exp(-\r)};
                % added functions to calculate cartesian coordinates from polar coordinates
                pol2cartX(\angle,\radius) = \radius * cos(\angle);
                pol2cartY(\angle,\radius) = \radius * sin(\angle);
            },
            xtick={\empty},
            ytick={\empty},
            ztick={\empty},
        ]
          \addplot3[surf,shader=flat,draw=black,z buffer=sort,
            domain=\pgfkeysvalueof{/pgfplots/view/az}:\pgfkeysvalueof{/pgfplots/view/az}+180] 
            {darkhole(y)};
          \addplot3[surf,shader=flat,draw=black,z buffer=sort,
            domain=\pgfkeysvalueof{/pgfplots/view/az}:\pgfkeysvalueof{/pgfplots/view/az}+180] 
            {-darkhole(y)}; 
         \addplot3[surf,shader=flat,draw=black,z buffer=sort,opacity=0,
            domain=\pgfkeysvalueof{/pgfplots/view/az}:\pgfkeysvalueof{/pgfplots/view/az}-180] 
            {darkhole(y)};  
         \addplot3[surf,shader=flat,draw=black,z buffer=sort,opacity=0,
            domain=\pgfkeysvalueof{/pgfplots/view/az}:\pgfkeysvalueof{/pgfplots/view/az}-180] 
            {-darkhole(y)}; 
        \end{axis}
    \end{tikzpicture}}
\sbox\Front{\begin{tikzpicture}
        \begin{axis}[
            axis line style={draw=none},
            tick style={draw=none},
            colormap/Blues,
            data cs=polar,
            samples=25,
            y domain=1:10,
            declare function={darkhole(\r)={exp(-1)-exp(-\r)};
                % added functions to calculate cartesian coordinates from polar coordinates
                pol2cartX(\angle,\radius) = \radius * cos(\angle);
                pol2cartY(\angle,\radius) = \radius * sin(\angle);
            },
            xtick={\empty},
            ytick={\empty},
            ztick={\empty},
        ]
          \addplot3[surf,shader=flat,draw=black,z buffer=sort,opacity=0,
            domain=\pgfkeysvalueof{/pgfplots/view/az}:\pgfkeysvalueof{/pgfplots/view/az}+180] 
            {darkhole(y)};
          \addplot3[surf,shader=flat,draw=black,z buffer=sort,opacity=0,
            domain=\pgfkeysvalueof{/pgfplots/view/az}:\pgfkeysvalueof{/pgfplots/view/az}+180] 
            {-darkhole(y)}; 
         \addplot3[surf,shader=flat,draw=black,z buffer=sort,
            domain=\pgfkeysvalueof{/pgfplots/view/az}:\pgfkeysvalueof{/pgfplots/view/az}-180] 
            {darkhole(y)};  
         \addplot3[surf,shader=flat,draw=black,z buffer=sort,
            domain=\pgfkeysvalueof{/pgfplots/view/az}:\pgfkeysvalueof{/pgfplots/view/az}-180] 
            {-darkhole(y)}; 
        \end{axis}
    \end{tikzpicture}}  
\begin{document}
\foreach \X in {-50,-48,...,-8,8,10,...,50}%{-50,-40,...,50}%
{\begin{tikzpicture}
\begin{scope}[local bounding box=nonlinear,transform shape
nonlinear=true]
 \pgftransformnonlinear{\blackholetransformation}
 \path[use as bounding box] (-5,-4) rectangle (5,5);
 \node[scale=2]{\usebox\Back};
 \begin{scope}[xshift={-1cm+\X*1mm},yshift={-1*tanh(\X/10)*4cm-1cm}]
  \marmot
 \end{scope}
 \node[scale=2]{\usebox\Front};
\end{scope} 
\end{tikzpicture}}
\end{document}

enter image description here

Another version with slower fall.

\documentclass[tikz,border=3.14pt]{standalone}
\usepackage{pgfplots}
\usepgfplotslibrary{colorbrewer}
\pgfplotsset{compat=1.16}
\usepackage{tikzmarmots}
\usepgfmodule{nonlineartransformations}
\makeatletter
\def\blackholetransformation{%
\pgf@xa=\pgf@x%
\pgf@ya=\pgf@y%
\pgfmathsetmacro{\myy}{\pgf@ya-60*exp(-0.06*abs(\the\pgf@xa))}%
\pgf@y=\myy pt}
\makeatother
\newsavebox\Back
\newsavebox\Front
\sbox\Back{\begin{tikzpicture}
        \begin{axis}[
            axis line style={draw=none},
            tick style={draw=none},
            colormap/Blues,
            data cs=polar,
            samples=25,
            y domain=1:10,
            declare function={darkhole(\r)={exp(-1)-exp(-\r)};
                % added functions to calculate cartesian coordinates from polar coordinates
                pol2cartX(\angle,\radius) = \radius * cos(\angle);
                pol2cartY(\angle,\radius) = \radius * sin(\angle);
            },
            xtick={\empty},
            ytick={\empty},
            ztick={\empty},
        ]
          \addplot3[surf,shader=flat,draw=black,z buffer=sort,
            domain=\pgfkeysvalueof{/pgfplots/view/az}:\pgfkeysvalueof{/pgfplots/view/az}+180] 
            {darkhole(y)};
          \addplot3[surf,shader=flat,draw=black,z buffer=sort,
            domain=\pgfkeysvalueof{/pgfplots/view/az}:\pgfkeysvalueof{/pgfplots/view/az}+180] 
            {-darkhole(y)}; 
         \addplot3[surf,shader=flat,draw=black,z buffer=sort,opacity=0,
            domain=\pgfkeysvalueof{/pgfplots/view/az}:\pgfkeysvalueof{/pgfplots/view/az}-180] 
            {darkhole(y)};  
         \addplot3[surf,shader=flat,draw=black,z buffer=sort,opacity=0,
            domain=\pgfkeysvalueof{/pgfplots/view/az}:\pgfkeysvalueof{/pgfplots/view/az}-180] 
            {-darkhole(y)}; 
        \end{axis}
    \end{tikzpicture}}
\sbox\Front{\begin{tikzpicture}
        \begin{axis}[
            axis line style={draw=none},
            tick style={draw=none},
            colormap/Blues,
            data cs=polar,
            samples=25,
            y domain=1:10,
            declare function={darkhole(\r)={exp(-1)-exp(-\r)};
                % added functions to calculate cartesian coordinates from polar coordinates
                pol2cartX(\angle,\radius) = \radius * cos(\angle);
                pol2cartY(\angle,\radius) = \radius * sin(\angle);
            },
            xtick={\empty},
            ytick={\empty},
            ztick={\empty},
        ]
          \addplot3[surf,shader=flat,draw=black,z buffer=sort,opacity=0,
            domain=\pgfkeysvalueof{/pgfplots/view/az}:\pgfkeysvalueof{/pgfplots/view/az}+180] 
            {darkhole(y)};
          \addplot3[surf,shader=flat,draw=black,z buffer=sort,opacity=0,
            domain=\pgfkeysvalueof{/pgfplots/view/az}:\pgfkeysvalueof{/pgfplots/view/az}+180] 
            {-darkhole(y)}; 
         \addplot3[surf,shader=flat,draw=black,z buffer=sort,
            domain=\pgfkeysvalueof{/pgfplots/view/az}:\pgfkeysvalueof{/pgfplots/view/az}-180] 
            {darkhole(y)};  
         \addplot3[surf,shader=flat,draw=black,z buffer=sort,
            domain=\pgfkeysvalueof{/pgfplots/view/az}:\pgfkeysvalueof{/pgfplots/view/az}-180] 
            {-darkhole(y)}; 
        \end{axis}
    \end{tikzpicture}}  
\begin{document}
\foreach \X in {-50,-48,...,50}
{\begin{tikzpicture}[declare function={darkhole(\r)=exp(-2.5)-exp(-\r);}]
 \path[use as bounding box] (-5,-6) rectangle (5,7);
 \node[scale=2]{\usebox\Back};
 \begin{scope}
  \clip (-5,6) -- plot[domain=-5:-0.5] ({\x},{25*darkhole(abs(5*\x))})
  -- plot[domain=-0.5:-5] ({\x},{-25*darkhole(abs(5*\x))})
  |- (5,-7)
  -- plot[domain=5:0.5] ({\x},{-25*darkhole(abs(5*\x))}) 
  -- plot[domain=0.5:5] ({\x},{25*darkhole(abs(5*\x))}) |-cycle;
  \begin{scope}[local bounding box=nonlinear,transform shape
  nonlinear=true]
   \pgftransformnonlinear{\blackholetransformation}
   \begin{scope}[xshift={-1cm+\X*1mm},yshift={-1*tanh(\X/10)*4cm-1cm}]
    \marmot
   \end{scope}
  \end{scope}
 \end{scope}  
 \node[scale=2]{\usebox\Front};
\end{tikzpicture}}
\end{document}

enter image description here

  • Nice solution !!! – BambOo Aug 27 at 7:26
  • 1
    Wow! I love the deforming effects :):):) – CarLaTeX Aug 27 at 11:44
  • I think from our point of view, there would be more deformation. – Strawberry Aug 27 at 14:12
  • 3
    Gotta love those Marmots! – John Aug 31 at 1:03
  • 1
    @CuriousEinstein It is at ctan.org/pkg/tikzmarmots?lang=en but the by far cleaner way is to use a package manager to update your TeX installation. – Schrödinger's cat Sep 4 at 22:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.