我想创建一个动画,将平面扇形逐渐变形为圆锥体。我受到一个问题的启发,该问题名为如何变形二维形状以制作三维物体?。
以下源代码可以作为起点。由于缺乏微分几何知识,我不知道下一步该做什么。
\documentclass[pstricks]{standalone}% Peter Lewintan
\usepackage{pst-solides3d,pst-math,multido,xfp}
\def\associate#1{\begin{pspicture}(-1.8,-2.8)(1.8,3.2)
\defFunction{associated}(u,v)
{#1 Cos v SINH mul u Sin mul #1 Sin v COSH mul u Cos mul add}
{#1 Cos v SINH mul u Cos mul neg #1 Sin v COSH mul u Sin mul add}
{#1 Cos u mul #1 Sin v mul add}
\psSolid[object=surfaceparametree,base=pi neg pi -1
1,function=associated,ngrid=25 25,linewidth=0.001]
\end{pspicture}}
\begin{document}
\psset{Decran=15}
\multido{\ik=0+1}{72}{%
\def\K{\fpeval{.08726646259971*\ik}}%
\associate{\K}%
}
\end{document}
对于您需要的任何工具,我们将不胜感激。
答案1
我不知道如何制作动画。但我认为我可以帮你制作过渡效果,如果你需要的是类似以下代码的东西:
\documentclass[border=2mm]{standalone}
\usepackage {tikz}
\usetikzlibrary{calc}
\begin{document}
\begin{tikzpicture}[x={(0.866cm,0.5cm)},y={(-0.866cm,0.5cm)},z={(0cm,1cm)}]
\def\r {1} % radius
\def\h {2} % height
\def\np{20} % number of base points
\def\nt{4} % number of transitions
\pgfmathsetmacro\s {4.5*\r} % separation between transitions
\pgfmathsetmacro\g{sqrt(\r*\r+\h*\h)} % generatrix
\pgfmathsetmacro\a{360*\r/\g} % sector angle
% Initial and final points
\coordinate (I0) at (0,0,0); % initial vertex
\coordinate (F0) at (0,0,\h); % final vertex
\foreach\i in {1,...,\np}
{%
\coordinate (I\i) at ({\a/(\np-1)*(\i-1)-0.5*\a}:\g); % initial base point
\coordinate (F\i) at ({360/(\np-1)*(\i-1)-180}:\r); % final base point
}
\foreach\j in {0,...,\nt}
{% Axes
\draw[-latex,red] (-45:\s*\j) --++ (1.25*\h,0,0) node [right] {$x$};
\draw[-latex,red] (-45:\s*\j) --++ (0,1.25*\h,0) node [left] {$y$};
\draw[-latex,red] (-45:\s*\j) --++ (0,0,1.25*\h) node [above] {$z$};
\fill[red] (-45:\s*\j) circle (1pt);
\foreach\i in {1,...,\np}
{% Cone
\pgfmathtruncatemacro\k{\i-1}
\draw ($(I0)!{\j/\nt}!(F0)+(-45:\s*\j)$) -- ($(I\i)!{\j/\nt}!(F\i)+(-45:\s*\j)$);
\draw ($(I\i)!{\j/\nt}!(F\i)+(-45:\s*\j)$) -- ($(I\k)!{\j/\nt}!(F\k)+(-45:\s*\j)$);
}
}
\end{tikzpicture}
\end{document}
当然,对于动画,您不需要(-45:\s*\j)
我添加的位移来分离过渡。
更新:我在 beamer 文档中制作了过渡。我认为这样更容易看到动画步骤。它基本上是相同的代码,只是减去了(-45:\s*\j)
现在不需要的位移。我也改变了尺寸并添加了更多过渡,但所有这些都是可自定义的。
\documentclass {beamer}
\usepackage {tikz}
\usetikzlibrary{calc}
\setbeamertemplate{navigation symbols}{}
\begin{document}
\begin{frame}
\begin{figure}\centering
\begin{tikzpicture}[x={(0.866cm,0.5cm)},y={(-0.866cm,0.5cm)},z={(0cm,1cm)}]
\def\r {2} % radius
\def\h {3} % height
\def\np{20} % number of base points
\def\nt{20} % number of transitions
\pgfmathsetmacro\g{sqrt(\r*\r+\h*\h)} % generatrix
\pgfmathsetmacro\a{360*\r/\g} % sector angle
% Initial and final points
\coordinate (I0) at (0,0,0); % initial vertex
\coordinate (F0) at (0,0,\h); % final vertex
\foreach\i in {1,...,\np}
{%
\coordinate (I\i) at ({\a/(\np-1)*(\i-1)-0.5*\a}:\g); % initial base point
\coordinate (F\i) at ({360/(\np-1)*(\i-1)-180}:\r); % final base point
}
\foreach\j in {0,...,\nt}
{
\only<\j>
{% Axes
\useasboundingbox (0,0,0) -- (1.25*\h,0,0) -- (0,1.25*\h,0) -- cycle;
\draw[-latex,red] (0,0,0) --++ (1.25*\h,0,0) node [right] {$x$};
\draw[-latex,red] (0,0,0) --++ (0,1.25*\h,0) node [left] {$y$};
\draw[-latex,red] (0,0,0) --++ (0,0,1.25*\h) node [above] {$z$};
\fill[red] (0,0,0) circle (1pt);
\foreach\i in {1,...,\np}
{% Cone
\draw ($(I0)!{\j/\nt}!(F0)$) -- ($(I\i)!{\j/\nt}!(F\i)$);
\ifnum \i > 1
\pgfmathtruncatemacro\k{\i-1}
\draw ($(I\i)!{\j/\nt}!(F\i)$) -- ($(I\k)!{\j/\nt}!(F\k)$);
\fi
}
}
}
\end{tikzpicture}
\end{figure}
\end{frame}
\end{document}
更新 2:\useasboundingbox
按照 OP 的建议,添加了一个使轴静止,并使用一个删除重复的线\ifnum