我看到一个很好的问题和答案这里关于创建动画来演示图同构。我想对这两个示例做同样的事情:
我意识到大多数代码都是在我之前提供的链接中提供的,但我对 LaTeX 不是很熟悉,而且我在调整代码以适应新图表方面遇到了一些麻烦。
所以,我有这个形状(一个五边形根):
\documentclass{standalone}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}
\tikzset{Bullet/.style={circle,draw,fill=black,scale=0.75}}
\node[Bullet,label=left :{$e_1$}] (E1) at (0,2) {} ;
\node[Bullet,label=above:{$e_2$}] (E2) at (1,3) {} ;
\node[Bullet,label=right:{$e_3$}] (E3) at (2,2) {} ;
\node[Bullet,label=right:{$e_4$}] (E4) at (2,0) {} ;
\node[Bullet,label=left :{$e_5$}] (E5) at (0,0) {} ;
\draw[thick] (E1)--(E2)--(E3)--(E4)--(E5)--(E1) {} ;
\end{tikzpicture}
\end{document}
我有这个形状(一个五边形)公克):
\documentclass{standalone}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}
\tikzset{Bullet/.style={circle,draw,fill=black,scale=0.75}}
\node[Bullet,label=left :{$c_1$}] (C1) at (0,2) {} ;
\node[Bullet,label=above:{$c_2$}] (C2) at (1,3) {} ;
\node[Bullet,label=right:{$c_3$}] (C3) at (2,2) {} ;
\node[Bullet,label=right:{$c_4$}] (C4) at (2,0) {} ;
\node[Bullet,label=left :{$c_5$}] (C5) at (0,0) {} ;
\draw[thick] (C1)--(C3)--(C5)--(C2)--(C4)--(C1) {} ;
\end{tikzpicture}
\end{document}
每种代码基本相同。除了顶点上的名称和标签外,两者之间唯一真正的区别是边将不同的顶点对连接在一起。因此五边形的顺序为 1-2-3-4-5-1,而五角星的顺序为 1-3-5-2-4-1。
无论如何,我只需要知道如何将一个动画变形为另一个动画并再次变形。我仍然在学习 LaTeX,所以我试图保持简单。提前致谢。
答案1
显示等价性的一种方法是绘制三维图形,然后移动顶点。
\documentclass[tikz,border=3.14mm]{standalone}
\usepackage{tikz-3dplot}
\begin{document}
\pgfmathsetmacro{\t}{135}
\pgfmathsetmacro{\R}{3}
\tdplotsetmaincoords{70}{0}
\foreach \t in {0,4,...,180}
{\begin{tikzpicture}[tdplot_main_coords,font=\sffamily,
bullet/.style={circle,fill,inner sep=1.5pt}]
\path[use as bounding box,tdplot_screen_coords]
(-1.2*\R,-1.2*\R) rectangle (1.2*\R,1.2*\R);
\pgfmathsetmacro{\tmax}{2*max(\t-90,0)}
\node[bullet,label=above:v1] (v1) at (0,0,\R){};
\node[bullet,label=\tmax:v2] (v2) at
({\R*cos(min(\t,90))*cos(18)+\R*sin(min(\t,90))*cos(-54)
+2*\R*cos(max(\t,90))*cos(-54)},{\R*sin(min(2*\t,180))},%
{\R*cos(min(\t,90))*sin(18)+\R*sin(min(\t,90))*sin(-54)}){};
\node[bullet,label=right:v3] (v3) at
({\R*sin(min(\t,90))*cos(18)+\R*cos(min(\t,90))*cos(-54)},{-\R*sin(min(2*\t,180))},%
{\R*sin(min(\t,90))*sin(18)+\R*cos(min(\t,90))*sin(-54)}){};
\node[bullet,label=left:v4] (v4) at
({-1*\R*sin(min(\t,90))*cos(18)-\R*cos(min(\t,90))*cos(-54)},{-\R*sin(min(2*\t,180))},%
{\R*sin(min(\t,90))*sin(18)+\R*cos(min(\t,90))*sin(-54)}){};
\node[bullet,label=180-\tmax:v5] (v5) at
({-1*\R*cos(min(\t,90))*cos(18)-\R*sin(min(\t,90))*cos(-54)
-2*\R*cos(max(\t,90))*cos(-54)},{\R*sin(2*\t)},%
{\R*cos(min(\t,90))*sin(18)+\R*sin(min(\t,90))*sin(-54)}){};
\draw[thick] (v1) -- (v3) -- (v5) -- (v2) -- (v4) -- (v1);
\end{tikzpicture}}
\end{document}
如果你想遵循以下策略这个答案,您可以在原始顶点名称和映射顶点名称及其逆之间定义一个字典,称为\LstMapped
和,\LstMappedInverse
如下所示。然后,您可以使用部分修饰符,如原始帖子中所述,并如第节所述4.2.1 使用部分计算来构建 Dpgfmanual 在坐标之间进行插值。
\documentclass[tikz,border=3.14mm]{standalone}
\usetikzlibrary{calc}
\begin{document}
\foreach \t in {0,0.05,...,1,1,0.95,...,0}
{\begin{tikzpicture}[bullet/.style={fill,circle,inner sep=1.5pt},font=\sffamily]
\path[use as bounding box] (-3.5,-3.5) rectangle (3.5,3.5);
\edef\LstMapped{{1,3,5,2,4}}
\edef\LstMappedInverse{{1,4,2,5,3}}
\foreach \X in {1,...,5}
{\pgfmathtruncatemacro{\Xmapped}{\LstMapped[\X-1]}
\coordinate[alias=v'\Xmapped] (v\X) at (90+72-72*\X:3);}
\foreach \X in {1,...,5}
{\pgfmathtruncatemacro{\Xmapped}{\LstMappedInverse[\X-1]}
\node[bullet,label={[opacity=1-\t]90+72-72*\X:$v_\X$},
label={[opacity=\t]90+72-72*\Xmapped:$v_\Xmapped'$}] (m\X) at ($(v\X)!\t!(v'\X)$){};}
\draw (m1) -- (m3) -- (m5) -- (m2) -- (m4) -- (m1);
\end{tikzpicture}}
\end{document}