动画展示切割表面的平面图

动画展示切割表面的平面图
\documentclass[border=10pt]{standalone}
\usepackage{pgfplots}
\pgfplotsset{width=7cm,compat=1.8}
\begin{document}
  \begin{tikzpicture}
    \begin{axis}[grid=major,view={20}{40},z buffer=sort, data cs=polar]
      \addplot3 [surf, domain=0:360, domain y=5:10,samples=30, samples y=10]
      {-y+5};
      \addplot3 [data cs=cart,surf,domain=-10:10,samples=2, opacity=0.5]
      {0};
      \addplot3 [domain=0:360, samples y=0, samples=30, thick, z buffer=auto]
      (x,5.1,0);
      \addplot3 [surf,domain=0:360, domain y=0:5,samples=30, samples y=10]
      {-y+5};
    \end{axis}
  \end{tikzpicture}  
\end{document}

我怎样才能制作一个动画,其中水平曲线平滑地从上到下或相反移动。

答案1

\documentclass[tikz,border=10pt]{standalone}
\usepackage{pgfplots}
\pgfplotsset{width=7cm,compat=1.16}
\begin{document}
\foreach \X [count=\Y] in {-4.5,-4,...,4.5}
{\begin{tikzpicture}
    \begin{axis}[grid=major,view={20}{40},z buffer=sort, data cs=polar]
      \addplot3 [surf, domain=0:360, domain y=5-\X:10,samples=30, samples y=1+\Y]
      {-y+5};
      \addplot3 [data cs=cart,surf,domain=-10:10,samples=2, opacity=0.5,point
      meta=0]
      {\X};
      \addplot3 [domain=0:360, samples y=0, samples=30, thick, z buffer=auto]
      (x,5.1-\X,\X);
      \addplot3 [surf,domain=0:360, domain y=0:5-\X,samples=30, samples y=21-\Y]
      {-y+5};
    \end{axis}
  \end{tikzpicture}} 
\end{document}

在此处输入图片描述

相关内容