发布日期:2024-09-14 18:35 点击次数:158
与 TikZ 合营制作动画,不错使用 animate 宏包。animate 宏包不错用于生成 JavaScript 动画探花 91,而 TikZ 不错用于生成矢量图形。
要使用 animate 宏包与 TikZ 合营制作动画,需要先在导言区中引入 animate 宏包和 TikZ 宏包:
\usepackage{animate}\usepackage{tikz}然后,不错使用 animate 号召来创建动画。animate 号召的参数阐述如下:
file:动画的文献名。start:动画的肇端帧。end:动画的已毕帧。delay:帧之间的延长技巧(以毫秒为单元)。举例,以下号召将创建一个包含 10 帧的动画,每帧延长 100 毫秒:
\animategraphics[delay=100]{image.pdf}{1}{10}
要使用 TikZ 在动画中生成矢量图形,需要在 animate 号召中指定图形的参数。举例,以下号召将在动画的第一帧中绘图一个红色的圆形,在第二帧中绘图一个绿色的圆形,在第三帧中绘图一个蓝色的圆形:
\animategraphics[delay=100]{image.pdf}{1}{3}{ { \draw[red,circle] (0,0) circle (1cm); }, { \draw[green,circle] (0,0) circle (1cm); }, { \draw[blue,circle] (0,0) circle (1cm); }}animate 宏包提供了很多选项来抑制动画的后果。这些选项不错在 animate 号召中指定,也不错在宏包的选项中指定。
以下是一些常用的选项:
autoplay:动画是否自动播放。loop:动画是否轮回播放。controls:是否露出抑制按钮。posterframe:动画的预览帧。举例,以下号召将创建一个自动播放、轮回播放、露出抑制按钮的动画,并将肇端帧建造为 5:
\animategraphics[autoplay,loop,controls]{image.pdf}{5}{10}
以下是一些使用 animate 宏包与 TikZ 合营制作动画的示例:
物体剖析:不错使用 TikZ 绘图物体,并使用 animate 宏包抑制物体的剖析。举例,不错绘图一个球,并使用 animate 宏包抑制球的迁移。局势变化:不错使用 TikZ 绘图局势,并使用 animate 宏包抑制局势的变化。举例,不错绘图一个矩形,并使用 animate 宏包抑制矩形的大小变化。翰墨动画:不错使用 TikZ 绘图翰墨,并使用 animate 宏包抑制翰墨的动画后果。举例,不错绘图一个字幕,并使用 animate 宏包抑制字幕的改革后果。animate 宏包不错用于创建多样类型的动画,不错匡助您在 LaTeX 文档中创建天真兴味的动画。
底下代码是生成不同函数的动图演示,有需要的不错下载不雅瞻不雅瞻。
sin函数的动图
\documentclass{beamer}\usepackage{tikz}\usepackage{animate}\usetikzlibrary{math, calc}\begin{document} \huge \begin{center} Função Seno \end{center} \normalsize \begin{animateinline}[poster=31, controls={play,step,stop}]{24} \multiframe{361}{rtheta=0+1} { \begin{tikzpicture} \path[use as bounding box] (-3.5,-2) rectangle (7.2,2); \draw[rounded corners] (-3.5,-2) rectangle (7.2,2); \tikzmath{ function degreeToRad(\d){ return {pi}*\d/180; }; } \draw[->,>=latex,thick] (-0.3,0) -- (7,0)node[below]{\(x\)}; \draw[->,>=latex,thick] (0,-1.5) -- (0,1.5)node[left]{\(y\)}; \draw[ultra thick, blue, samples=50, domain=0:{2*pi}] plot (\x, {sin(\x r)}); \node at (0,0) [below left]{\(O\)}; \node at ({pi/2},0) [below]{\(\frac{\pi}{2}\)}; \node at ({pi},0) [below]{\(\pi\)}; \node at ({3*pi/2},0) [below]{\(\frac{3\pi}{2}\)}; \node at ({2*pi},0) [below]{\(2\pi\)}; \draw (-2,0) circle (1cm); \draw[->,>=latex,thick] (-3.5,0) -- (-0.5,0); \draw[->,>=latex,thick] (-2,-1.5) -- (-2,1.5); \coordinate (A) at (-2,0); \coordinate (B) at (-2,1); \coordinate (C) at (-2,-1); \coordinate (D) at (-3,0); \coordinate (E) at (-1,0); \coordinate[rotate around={\rtheta:(A)}] (P) at ($(A) + (1,0)$); \draw[thick] (A) -- (P); \draw[thin, dashed, blue] ($(D)!(P)!(E)$) -- (P) -- ($(B)!(P)!(C)$); \draw[->, >=stealth] (-1.6,0) arc [start angle=0, end angle=\rtheta, radius=0.4]; \draw[ultra thick, blue] (-2, 0) -- (-2, {sin(\rtheta)}); \draw[thin, blue, dashed] (P) -- ({degreeToRad(\rtheta)}, {sin(\rtheta)}) -- ({degreeToRad(\rtheta)},0); \draw[fill=black] ({degreeToRad(\rtheta)}, {sin(\rtheta)}) circle (1pt); \end{tikzpicture} } \end{animateinline}\end{document}图片探花 91
大色网cos 函数的动图:
图片
\documentclass{beamer}\usepackage{tikz}\usepackage{animate}\usetikzlibrary{math, calc}\begin{document} \huge \begin{center} Função Cosseno \end{center} \normalsize \begin{animateinline}[poster=31, controls={play,step,stop}]{24} \multiframe{361}{rtheta=0+1} { \begin{tikzpicture}[scale=1] \path[use as bounding box] (-3.5,-2) rectangle (7.2,2); \draw[rounded corners] (-3.5,-2) rectangle (7.2,2); \tikzmath{ function degreeToRad(\d){ return {pi}*\d/180; }; } \draw[->,>=latex,thick] (-0.3,0) -- (7,0)node[below]{\(x\)}; \draw[->,>=latex,thick] (0,-1.5) -- (0,1.5)node[left]{\(y\)}; \draw[ultra thick, red, samples=50, domain=0:{2*pi}] plot (\x, {cos(\x r)}); \node at (0,0) [below left]{\(O\)}; \node at ({pi/2},0) [below]{\(\frac{\pi}{2}\)}; \node at ({pi},0) [below]{\(\pi\)}; \node at ({3*pi/2},0) [below]{\(\frac{3\pi}{2}\)}; \node at ({2*pi},0) [below]{\(2\pi\)}; \draw[thin, dashed] ({2*pi}, 0) -- ({2*pi},1); \draw (-2,0) circle (1cm); \draw[->,>=latex,thick] (-3.5,0) -- (-0.5,0); \draw[->,>=latex,thick] (-2,-1.5) -- (-2,1.5); \coordinate (A) at (-2,0); \coordinate (B) at (-2,1); \coordinate (C) at (-2,-1); \coordinate (D) at (-3,0); \coordinate (E) at (-1,0); \coordinate (P) at ($(A) + (\rtheta:1)$); \draw[thick] (A) -- (P); \draw[thin, dashed, red] ($(D)!(P)!(E)$) -- (P) -- ($(B)!(P)!(C)$); \draw[->, >=stealth] (-1.6,0) arc [start angle=0, end angle=\rtheta, radius=0.4]; \coordinate (Q) at ($(A) + ({cos(\rtheta)},0)$); \coordinate (R) at ($({-2+cos(\rtheta)}, {cos(\rtheta)})$); \draw[ultra thick, red] (A) -- (Q) -- (R); \draw[thin, red] (Q) circle [radius={abs(cos(\rtheta))}]; \draw[thin, red, dashed] (R) -- ({degreeToRad(\rtheta)}, {cos(\rtheta)}) -- ({degreeToRad(\rtheta)},0); \draw[fill=black] ({degreeToRad(\rtheta)}, {cos(\rtheta)}) circle (1pt); \end{tikzpicture} } \end{animateinline}\end{document}
抛物线的演示动图:
图片
\documentclass{beamer}\usepackage{tikz}\usepackage{animate}\begin{document} \begin{center} \begin{animateinline}[poster=0, controls={play,step,stop}]{10} \multiframe{51}{ri=0+0.04} { \begin{tikzpicture} \path[use as bounding box] (-2,-1) rectangle (5.5,5.5); \draw[->,>=latex, thick] (-2,0) -- (5,0) node[below]{\(x\)}; \draw[->,>=latex, thick] (0,-2) -- (0,5) node[left]{\(y\)}; \draw[ultra thick, blue, samples=200, domain=\ri+2:\ri-2] plot (\x, {(\x-\ri)^2}) node[right]{$f\left(x\right)=\left(x-\ri \right)^2$}; \node at (\ri, 0)[below] {$\ri$}; \node at (0, 0)[below left] {$O$}; \end{tikzpicture} } \newframe \multiframe{26}{ri=0+0.04} { \begin{tikzpicture} \path[use as bounding box] (-2,-1) rectangle (5.5,5.5); \draw[->,>=latex, thick] (-2,0) -- (5,0) node[below]{\(x\)}; \draw[->,>=latex, thick] (0,-2) -- (0,5) node[left]{\(y\)}; \draw[ultra thick, blue, samples=200, domain=4:0] plot (\x, {(\x-2)^2+\ri}) node[right]{$f\left(x\right)=\left(x-2 \right)^2+\ri $}; \node at (0, 0)[below left] {$O$}; \node at (2, 0)[below] {$2$}; \draw[dashed] (2,0)--(2,\ri)--(0,\ri)node[left]{$\ri$}; \end{tikzpicture} } \newframe \multiframe{31}{ri=1+0.1} { \begin{tikzpicture} \path[use as bounding box] (-2,-1) rectangle (5.5,5.5); \draw[->,>=latex, thick] (-2,0) -- (5,0) node[below]{\(x\)}; \draw[->,>=latex, thick] (0,-2) -- (0,5) node[left]{\(y\)}; \draw[ultra thick, blue, samples=200, domain=4:0] plot (\x, {\ri*(\x-2)^2+1}); \node at (0,5) [right, blue] {$f\left(x\right)=\ri \left(x-2 \right)^2+1$}; \node at (0, 0)[below left] {$O$}; \node at (2, 0)[below] {$2$}; \draw[dashed] (2,0)--(2,1)--(0,1)node[left]{$1$}; \end{tikzpicture} } \end{animateinline} \end{center}\end{document}图片
\documentclass{article}\usepackage{tikz}\usepackage{animate}\usepackage{ifthen}\usepackage{amsmath}\usetikzlibrary{math}\begin{document} \begin{center} \begin{animateinline}[poster=1, controls={play,step,stop}]{5} \multiframe{29}{ri=0+0.05} { \begin{tikzpicture}[ scale=2.5, extended line/.style={shorten >=-#1,shorten <=-#1}, extended line/.default=1cm] \path[use as bounding box] (-1,-1) rectangle (3.5,3); \tikzmath{ function calcF(\x){ return 1+(2*\x-\x^2)*ln(\x); }; } \draw[->,>=latex, thick] (-.5,0) -- (3,0) node[below]{\(x\)}; \draw[->,>=latex, thick] (0,-.5) -- (0,1.8) node[left]{\(y\)}; \draw[ultra thick, blue, samples=200, domain=0.0001:2.6] plot (\x, {1+(2*\x-\x^2)*ln(\x)}) node[right]{\(f\)}; \draw[orange, thick] (0.5,0.5) -- (1.5,1.5) node[above]{\(t\)}; \draw[thin, dashed] (1,{calcF(1)}) -- (1,0) node[below]{\(a\)}; \draw[thin, dashed] (1,{calcF(1)}) -- (0,{calcF(1)}) node[left]{\(f\left(a\right)\)}; \ifthenelse{\equal{\ri}{1.4}}{}{ \draw[red,thick,extended line] (1,{calcF(1)}) -- ({2.4-\ri}, {calcF(2.4-\ri)}); \draw[thin, dashed] ({2.4-\ri}, {calcF(2.4-\ri)}) -- (2.4-\ri, 0) node[below]{\(a+h\)}; \draw[thin, dashed] (2.4-\ri,{calcF(2.4-\ri)}) -- (0, {calcF(2.4-\ri)}) node[left]{\(f\left(a+h\right)\)}; \draw[<->, >=latex] (1,-0.3) -- (2.4-\ri,-0.3); \node at ({1+0.5*(1.4-\ri)},-0.3) [below]{\(h\)}; } \draw[color=blue, fill=white] (0,{calcF(0.0001)}) circle(1pt); \node at (0,0) [below left]{\(O\)}; \node at (1.5,1.8) [above]{\(f'\left(a\right)=\underset{h\to0}{\lim}\dfrac{f\left(a+h\right)-f\left(a\right)}{h}\)}; \end{tikzpicture} } \end{animateinline} \end{center}\end{document}本站仅提供存储作事,扫数骨子均由用户发布,如发现存害或侵权骨子,请点击举报。