如何繪製動畫同構圖?

如何繪製動畫同構圖?

我看到了一個很好的問答這裡,關於創建動畫來示範圖同構。我想對這兩個例子做同樣的事情:

這兩個同構: 在此輸入影像描述 這兩個不是同構: 在此輸入影像描述


我意識到大部分程式碼都是在我之前提供的連結中提供的,但我對 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

顯示等價性的一種方法是在 3d 中繪製圖形,然後移動頂點。

\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如下所示。然後你可以使用partway修飾符,如原始文章中和部分所述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}

在此輸入影像描述

相關內容