是否可以使用 Latex 制作出这种破碎球体的图片?

是否可以使用 Latex 制作出这种破碎球体的图片?

我目前正在写一篇关于巴拿赫-塔斯基悖论的文章。我想画一幅破碎球体的图像,就像本网站

在此处输入图片描述

有人知道是否/如何使用 Latex 来实现这一点?

答案1

这可能太 hacky 了,但设置一些随机路径并裁剪它们并不困难。您可以通过更改 的参数来更改随机路径\pgfmathsetseed{42}

\documentclass[tikz,border=3mm]{standalone}
\makeatletter
\tikzset{ball colors/.code 2 args={\pgfutil@colorlet{tikz@ballA}{#1}%
\pgfutil@colorlet{tikz@ballB}{#2}%
\def\tikz@shading{balls}\tikz@addmode{\tikz@mode@shadetrue}}}%
\pgfdeclareradialshading[tikz@ballA,tikz@ballB]{balls}{\pgfqpoint{-15bp}{15bp}}{%
 color(0bp)=(tikz@ballA!15!tikz@ballB);
 color(9bp)=(tikz@ballA!35!tikz@ballB);
 color(18bp)=(tikz@ballA!50!tikz@ballB);
 color(25bp)=(tikz@ballA!70!tikz@ballB);
 color(50bp)=(tikz@ballA)}%
\makeatother 
\begin{document}
\begin{tikzpicture}
 \begin{scope}[local bounding box=L]
  \draw[ball colors={red}{blue}] (-4,0) circle[radius=1cm];
 \end{scope}
 %
 \begin{scope}[local bounding box=M]
  \pgfmathsetseed{42}
  \edef\x{0}
  \loop
   \pgfmathtruncatemacro\u{\x*2}
   \pgfmathtruncatemacro\y{\x*2+1}
   \pgfmathsetmacro{\a}{\x*60+20*(rnd-0.5)}
   \pgfmathsetmacro{\bA}{\x*60+10*(rnd-0.5)}
   \pgfmathsetmacro{\rA}{0.1+0.8*rnd}
   \pgfmathsetmacro{\bB}{\x*60+30+10*(rnd-0.5)}
   \pgfmathsetmacro{\rB}{0.1+0.8*rnd}
   \ifnum\x=0
    \edef\lsta{\a}
    \edef\lstb{\bA,\bB}
    \edef\lstr{\rA,\rB}
   \else
    \edef\lsta{\lsta,\a}
    \edef\lstb{\lstb,\bA,\bB}
    \edef\lstr{\lstr,\rA,\rB}
   \fi
   %  
   \edef\x{\the\numexpr\x+1} 
  \ifnum\x<6\repeat
  %
  \edef\x{0}
  \loop
   \pgfmathtruncatemacro\u{\x*2}
   \pgfmathtruncatemacro\y{\x*2+1}
   \pgfmathtruncatemacro\z{mod(\x*2+2,12)}
   \pgfmathsetmacro{\a}{{\lsta}[\x]}
   \ifnum\x=5
    \pgfmathsetmacro{\b}{{\lsta}[mod(\x+1,6)]+360}
   \else
    \pgfmathsetmacro{\b}{{\lsta}[mod(\x+1,6)]}
   \fi
   \begin{scope}[shift={(0.5*\a+0.5*\b:0.5)}]
    \begin{scope}
     \clip (\a:1) arc[start angle=\a,end angle=\b,radius=1]
      -- plot[samples at={\z,\y,\u},variable=\t] ({{\lstb}[\t]}:{{\lstr}[\t]})
      -- cycle;
     \path[ball colors={red}{blue}] circle[radius=1cm];
    \end{scope}
    \draw (\a:1) arc[start angle=\a,end angle=\b,radius=1]
      -- plot[samples at={\z,\y,\u},variable=\t] ({{\lstb}[\t]}:{{\lstr}[\t]})
      -- cycle;
   \end{scope}
   \edef\x{\the\numexpr\x+1} 
  \ifnum\x<6\repeat
  %
  \begin{scope}[shift={(0,0.17)}]
   \begin{scope}
    \clip plot[samples at={0,...,6},variable=\t] ({{\lstb}[\t]}:{{\lstr}[\t]}) -- cycle; 
    \path[ball colors={red}{blue}] circle[radius=1cm];
   \end{scope}
   \draw plot[samples at={0,...,6},variable=\t] ({{\lstb}[\t]}:{{\lstr}[\t]}) -- cycle; 
  \end{scope}
  \begin{scope}[shift={(0,-0.17)}]
   \begin{scope}
    \clip plot[samples at={6,...,11,0},variable=\t] ({{\lstb}[\t]}:{{\lstr}[\t]}) -- cycle; 
    \path[ball colors={red}{blue}] circle[radius=1cm];
   \end{scope}
   \draw plot[samples at={6,...,11,0},variable=\t] ({{\lstb}[\t]}:{{\lstr}[\t]}) -- cycle; 
  \end{scope}
 \end{scope}
 %
 \begin{scope}[local bounding box=R]
  \draw[ball colors={red}{blue}] (4,0) circle[radius=1cm];
 \end{scope}
 %
\end{tikzpicture}
\end{document}

在此处输入图片描述

一旦完成后,人们就可以玩它,或者说服自己各个部分相匹配(这在某种程度上违背了悖论)。

\documentclass[tikz,border=3mm]{standalone}
\makeatletter
\tikzset{ball colors/.code 2 args={\pgfutil@colorlet{tikz@ballA}{#1}%
\pgfutil@colorlet{tikz@ballB}{#2}%
\def\tikz@shading{balls}\tikz@addmode{\tikz@mode@shadetrue}}}%
\pgfdeclareradialshading[tikz@ballA,tikz@ballB]{balls}{\pgfqpoint{-15bp}{15bp}}{%
 color(0bp)=(tikz@ballA!15!tikz@ballB);
 color(9bp)=(tikz@ballA!35!tikz@ballB);
 color(18bp)=(tikz@ballA!50!tikz@ballB);
 color(25bp)=(tikz@ballA!70!tikz@ballB);
 color(50bp)=(tikz@ballA)}%
\makeatother 
\begin{document}
\begingroup
  \pgfmathsetseed{28}
  \edef\x{0}
  \loop
   \pgfmathtruncatemacro\u{\x*2}
   \pgfmathtruncatemacro\y{\x*2+1}
   \pgfmathsetmacro{\a}{\x*60+20*(rnd-0.5)}
   \pgfmathsetmacro{\bA}{\x*60+10*(rnd-0.5)}
   \pgfmathsetmacro{\rA}{0.1+0.8*rnd}
   \pgfmathsetmacro{\bB}{\x*60+30+10*(rnd-0.5)}
   \pgfmathsetmacro{\rB}{0.1+0.8*rnd}
   \ifnum\x=0
    \edef\lsta{\a}
    \edef\lstb{\bA,\bB}
    \edef\lstr{\rA,\rB}
   \else
    \edef\lsta{\lsta,\a}
    \edef\lstb{\lstb,\bA,\bB}
    \edef\lstr{\lstr,\rA,\rB}
   \fi
   %  
   \edef\x{\the\numexpr\x+1} 
  \ifnum\x<6\repeat
  %
  \foreach \RR in {0,0.04,...,1}
  {\begin{tikzpicture}
    %
    \begin{scope}[local bounding box=M]
     %
     \edef\x{0}
     \loop
      \pgfmathtruncatemacro\u{\x*2}
      \pgfmathtruncatemacro\y{\x*2+1}
      \pgfmathtruncatemacro\z{mod(\x*2+2,12)}
      \pgfmathsetmacro{\a}{{\lsta}[\x]}
      \ifnum\x=5
       \pgfmathsetmacro{\b}{{\lsta}[mod(\x+1,6)]+360}
      \else
       \pgfmathsetmacro{\b}{{\lsta}[mod(\x+1,6)]}
      \fi
      \begin{scope}[shift={(0.5*\a+0.5*\b:0.5*\RR)}]
       \begin{scope}
        \clip (\a:1) arc[start angle=\a,end angle=\b,radius=1]
         -- plot[samples at={\z,\y,\u},variable=\t] ({{\lstb}[\t]}:{{\lstr}[\t]})
         -- cycle;
        \path[ball colors={red}{blue}] circle[radius=1cm];
       \end{scope}
       \draw (\a:1) arc[start angle=\a,end angle=\b,radius=1]
         -- plot[samples at={\z,\y,\u},variable=\t] ({{\lstb}[\t]}:{{\lstr}[\t]})
         -- cycle;
      \end{scope}
      \edef\x{\the\numexpr\x+1} 
     \ifnum\x<6\repeat
     %
     \begin{scope}[shift={(0,0.17*\RR)}]
      \begin{scope}
       \clip plot[samples at={0,...,6},variable=\t] ({{\lstb}[\t]}:{{\lstr}[\t]}) -- cycle; 
       \path[ball colors={red}{blue}] circle[radius=1cm];
      \end{scope}
      \draw plot[samples at={0,...,6},variable=\t] ({{\lstb}[\t]}:{{\lstr}[\t]}) -- cycle; 
     \end{scope}
     \begin{scope}[shift={(0,-0.17*\RR)}]
      \begin{scope}
       \clip plot[samples at={6,...,11,0},variable=\t] ({{\lstb}[\t]}:{{\lstr}[\t]}) -- cycle; 
       \path[ball colors={red}{blue}] circle[radius=1cm];
      \end{scope}
      \draw plot[samples at={6,...,11,0},variable=\t] ({{\lstb}[\t]}:{{\lstr}[\t]}) -- cycle; 
     \end{scope}
    \end{scope}
    %
    \path (-2,-2.3) (2,2.3);
   \end{tikzpicture}}
\endgroup
\end{document}

在此处输入图片描述

相关内容