这是我的第一个尝试将它放在投影机和\foreach
。
对于你们中的一些人来说,这可能只是五分钟的工作时间...但对于我来说,这已经耗费了整个上午...
我的问题是:我如何才能将操作员frame
生成的每个图像分开\foreach
。\newframe
内部\foreach
不起作用。
我的目标是让它有运动(逆时针旋转)……但不要把两个问题纠缠在一起
\documentclass{beamer}%{book}
\usepackage[utf8x]{inputenc}
\usepackage{default}
\usepackage{tikz}
\usetikzlibrary{calc}
\usetheme{Warsaw}
\usecolortheme{whale}
\begin{document}
%
\begin{frame}{rotating - test}
%
\begin{center}
\begin{tikzpicture}[scale=2]
\draw[thin,gray,step=0.25] (-1,-1) grid (1,1);
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\draw[->] (-1.5,0) -- (1.5,0) node[below]{$\phi_0$};
\draw[->] (0,-1.5) -- (0,1.5) node[left]{$x$};
\draw[thick] (0,0) circle [radius=1];
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\coordinate (C1) at (1,0);
\coordinate (C2) at (0.86,0.5);
\coordinate (C3) at (0.7,0.7);
\coordinate (C4) at (0.5,0.86);
\coordinate (C5) at (0,1);
\coordinate (C6) at (-0.5,0.86);
\coordinate (C7)at(-0.7,0.7);
\coordinate (C8)at(-0.86,0.5);
\coordinate (C9) at (-1,0);
\coordinate (C10) at (-0.86,-0.5);
\coordinate (C11)at(-0.7,-0.7);
\coordinate (C12) at (-0.5,-0.86);
\coordinate (C13) at (0,-1);
\coordinate (C14) at (0.5,-0.86);
\coordinate (C15) at (0.7,-0.7);
\coordinate (C16) at (0.86,-0.5);
%
\foreach \Ctest in {(C1),(C2),(C3),(C4),(C5),(C6),
(C7),(C8),(C9),(C10),(C11),(C12),(C13),(C14),(C15),(C16)}{%
\draw [dashed] let \p1 = \Ctest
in
(\x1,\y1) -- (0,\y1)
(\x1,\y1) -- (0,0);
\draw [red,thick,->] let \p1 = \Ctest
in
(0,0) -- (0,\y1) node[left] {$x$};
\draw [red,thick] let \p1 = \Ctest,
\n1={atan2(\x1,\y1)}
in
(1,0) arc (0:\n1:1)
(0,0)--(0.251,0) arc (0:\n1:0.25)--cycle;
\draw[fill=red] \Ctest circle [radius=0.06];
% \newframe %<<================================================
};
\end{tikzpicture}
%
\end{center}
%
\end{frame}
\end{document}
1更新:在@Claudio Fiandrino 和@Gonzalo Medina 的回复后,我得到了这个图。现在的问题是,我希望红体的“轨道”有连续增加的弧度,但超过 180 度的角度没有定义
答案1
TikZ
并且beamer
很好地集成在一起;特别是,TikZ 命令具有叠加感知功能,因此您可以说,例如\draw<+-> ...
;在这种特殊情况下,count=<macro>
可以使用语法(如卡卢迪奥·菲安德里诺在他的评论中建议)在循环中保存每个位置,然后用于<macro>
覆盖规范:
如果不为\Ctest
一个角度分配坐标,原始代码可以高度简化:
\documentclass{beamer}%{book}
\usepackage[utf8x]{inputenc}
\usepackage{tikz}
\usetikzlibrary{calc}
\usetheme{Warsaw}
\usecolortheme{whale}
\begin{document}
\begin{frame}{rotating - test}
\begin{center}
\begin{tikzpicture}[scale=2]
\draw[thin,gray,step=0.25] (-1,-1) grid (1,1);
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\draw[->] (-1.5,0) -- (1.5,0) node[below]{$\phi_0$};
\draw[->] (0,-1.5) -- (0,1.5) node[left]{$x$};
\draw[thick] (0,0) circle [radius=1];
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\foreach \Ctest[count=\i] in {0,30,45,60,90,120,135,150,180,210,225,240,270,300,315,330,360}{%
\draw<\i> [dashed]
(0,0) -- (\Ctest:1) -- (0,{sin(\Ctest)})
node[left,red] {$x$};
\draw<\i> [red,thick]
(0,0)--(0.251,0) arc (0:\Ctest:0.25) -- cycle;
\draw<\i> [->,red,thick]
(0,0) -- (0,{sin(\Ctest)});
\draw<\i>[fill=red] ({cos(\Ctest)},{sin(\Ctest)}) circle [radius=0.06];
}
\end{tikzpicture}
\end{center}
\end{frame}
\end{document}
原始代码如下:
\documentclass{beamer}%{book}
\usepackage[utf8x]{inputenc}
%\usepackage{default}
\usepackage{tikz}
\usetikzlibrary{calc}
\usetheme{Warsaw}
\usecolortheme{whale}
\begin{document}
%
\begin{frame}{rotating - test}
%
\begin{center}
\begin{tikzpicture}[scale=2]
\draw[thin,gray,step=0.25] (-1,-1) grid (1,1);
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\draw[->] (-1.5,0) -- (1.5,0) node[below]{$\phi_0$};
\draw[->] (0,-1.5) -- (0,1.5) node[left]{$x$};
\draw[thick] (0,0) circle [radius=1];
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\coordinate (C1) at (1,0);
\coordinate (C2) at (0.86,0.5);
\coordinate (C3) at (0.7,0.7);
\coordinate (C4) at (0.5,0.86);
\coordinate (C5) at (0,1);
\coordinate (C6) at (-0.5,0.86);
\coordinate (C7)at(-0.7,0.7);
\coordinate (C8)at(-0.86,0.5);
\coordinate (C9) at (-1,0);
\coordinate (C10) at (-0.86,-0.5);
\coordinate (C11)at(-0.7,-0.7);
\coordinate (C12) at (-0.5,-0.86);
\coordinate (C13) at (0,-1);
\coordinate (C14) at (0.5,-0.86);
\coordinate (C15) at (0.7,-0.7);
\coordinate (C16) at (0.86,-0.5);
%
\foreach \Ctest[count=\i] in {(C1),(C2),(C3),(C4),(C5),(C6),
(C7),(C8),(C9),(C10),(C11),(C12),(C13),(C14),(C15),(C16)}{%
\draw<\i> [dashed] let \p1 = \Ctest
in
(\x1,\y1) -- (0,\y1)
(\x1,\y1) -- (0,0);
\draw<\i> [red,thick,->] let \p1 = \Ctest
in
(0,0) -- (0,\y1) node[left] {$x$};
\ifnum\i<9\relax
{\draw<\i> [red,thick] let \p1 = \Ctest,
\n1={atan2(\x1,\y1)}
in
(0,0)--(0.251,0) arc (0:\n1:0.25)--cycle;
}
\else
{
\draw<\i> [red,thick]
(0.25,0mm) arc (0:180:0.25);
\draw<\i> [red,thick] let \p1 = \Ctest,
\n1={atan2(-\x1,\y1)}
in
(0,0)--(-0.251,0) arc (0:-\n1:-0.25)--cycle;
}
\fi
\draw<\i>[fill=red] \Ctest circle [radius=0.06];
};
\end{tikzpicture}
%
\end{center}
%
\end{frame}
\end{document}