我正在尝试绘制一幅伽利略时空的图画,就像彭罗斯的书《通往现实之路》中的这幅画一样。
我能够画出一个叠在另一个上面的“平面”,但我无法令人满意地画出一些路径(彭罗斯图中带箭头的线),以给人一种它们穿过平面的错觉。(实际上我不需要带箭头的路径,也不需要彭罗斯图中平面周围的虚线曲线)。
以下是我启动代码的方式:
\begin{tikzpicture}[x={(1cm,0cm)}, y={(0cm,1cm)}, z={(3.85mm, 3.85mm)}]% default z value: (-3.85mm,-3.85mm)
\begin{scope}[canvas is xz plane at y=0]
\draw[fill=white] (0, 0) rectangle (4, 3);
\end{scope}
\begin{scope}[canvas is xz plane at y=0.5]
\draw[fill=white] (0, 0) rectangle (4, 3);
\end{scope}
\begin{scope}[canvas is xz plane at y=1]
\draw[fill=white] (0, 0) rectangle (4, 3);
\end{scope}
\begin{scope}[canvas is xz plane at y=1.5]
\draw[fill=white] (0, 0) rectangle (4, 3);
\end{scope}
\end{tikzpicture}
答案1
为了得到正交投影,可以使用tikz-3dplot
。然后你需要一步一步地绘制平面之间的延伸。
\documentclass[tikz,border=3mm]{standalone}
\usepackage{tikz-3dplot}
\begin{document}
\begin{tikzpicture}
\tdplotsetmaincoords{75}{110}
\begin{scope}[tdplot_main_coords,declare function={a1=0.2;b1=-0.1;
a2=0.3;b2=-0.1;a3=-0.2;b3=0.3;a4=0.4;b4=0.1;}]
\path (1.5,-1,0) coordinate (p1) (-1,0.5,0) coordinate (p2)
(1,1,0) coordinate (p3) (-0.5,-0.5,0) coordinate (p4);
\foreach \Y in {1,...,4}
{
\foreach \X in {1,...,4}
{\draw ($(p\X)+({(\Y-1)*a\X},{(\Y-1)*b\X},\Y-1)$) -- ($(p\X)+(\Y*a\X,\Y*b\X,\Y)$);}
\begin{scope}[canvas is xy plane at z=\Y]
\draw[fill=white,fill opacity=0.9] (-3,{-3+sin((\Y-1)*90/1.5)}) rectangle ++ (6,6);
\end{scope}
}
\foreach \X in {1,...,4}
{\draw[-latex] ($(p\X)+({4*a\X},{4*b\X},4)$) -- ($(p\X)+(5.5*a\X,5.5*b\X,5.5)$);}
\end{scope}
\end{tikzpicture}
\end{document}
还可以添加动画,使时间切片的概念更清晰一些(?)。(不过,它不一定是纯粹的伽利略概念。)
\documentclass[tikz,border=3mm]{standalone}
\usepackage{tikz-3dplot}
\usepackage{tikzlings}
\makeatletter
\tikzset{recycle bounding box/.style={%
execute at end picture={%
\immediate\write\@mainaux{\xdef\string\tikz@bbox@figbb@#1{%
(\the\pgf@picminx,\the\pgf@picminy) rectangle (\the\pgf@picmaxx,\the\pgf@picmaxy)}\relax}},
execute at begin picture={%
\ifcsname tikz@bbox@figbb@#1\endcsname
\edef\figbb{\csname tikz@bbox@figbb@#1\endcsname}
\path \figbb;
\fi}}}
\makeatother
\begin{document}
\foreach \Z in {1,...,40}
{\begin{tikzpicture}[recycle bounding box=A]
\tdplotsetmaincoords{75}{110}
\begin{scope}[tdplot_main_coords,declare function={a1=0.2;b1=-0.1;
a2=0.3;b2=-0.1;a3=-0.2;b3=0.3;a4=0.4;b4=0.1;}]
\path (1.5,-1,0) coordinate (p1) (-1,0.5,0) coordinate (p2)
(1,1,0) coordinate (p3) (-0.5,-0.5,0) coordinate (p4);
\foreach \Y in {1,...,\Z}
{
\foreach \X in {1,...,4}
{\draw ($(p\X)+({0.1*(\Y-1)*a\X},{0.1*(\Y-1)*b\X},{0.1*(\Y-1)})$)
-- ($(p\X)+(0.1*\Y*a\X,0.1*\Y*b\X,0.1*\Y)$);}
\begin{scope}[canvas is xy plane at z=0.1*\Y]
\draw[fill=white,fill opacity=0.5] (-3,{-3+sin((\Y-1)*90/1.5)}) rectangle ++ (6,6);
\ifodd\Y
\marmot[rotate=90,xshift=1cm,yshift=-1cm,leftstep]
\else
\marmot[rotate=90,xshift=1cm,yshift=-1cm,rightstep]
\fi
\end{scope}
}
\ifnum\Z=40
\foreach \X in {1,...,4}
{\draw[-latex] ($(p\X)+({4*a\X},{4*b\X},4)$) -- ($(p\X)+(5.5*a\X,5.5*b\X,5.5)$);}
\fi
\end{scope}
\end{tikzpicture}}
\end{document}