LaTeX 中的简单线条帮助!

LaTeX 中的简单线条帮助!

我正在为大学做一个使用 LaTeX 的项目,我将制作一个 gif 来解释数学的弧度。我真的不知道如何制作这种类型的线

在此处输入图片描述

我目前所做的

\documentclass[border=1cm]{standalone}
\usepackage[utf8]{inputenc}
\usepackage{tikz}
\begin{document}

\begin{tikzpicture}





\begin{scope}
\draw (0,0) circle (10cm);
\draw[line width=0.15cm, blue] (10,0) arc (0:360:10) ;

\draw[-] (-12,0) -- (12,0) node[right] {$x$};
\draw[-] (0,-12) -- (0,12) node[above] {$y$};
\draw[line width=0.15cm,red] (0,0) -- (10,-0);
\node[scale=15.5, red, right, opacity=0.5] at (2,2) {r};

\draw[red][fill] (0,0) circle (0.2cm);
\draw[red][fill] (10,-0) circle (0.2cm);


  \end{scope}


\end{tikzpicture}

\end{document}

答案1

PSTricks 解决方案仅用于娱乐目的。

\documentclass[pstricks,border=12pt,12pt]{standalone}
\radians
\def\obj#1{%
\begin{pspicture}(-4,-4)(4,4)
    \pscircle{4}
    \psset{linecolor=red,linewidth=2\pslinewidth}
    \psarc(0,0){4}{0}{#1}
    \rput{#1}(4;#1){\psline(!0 1 #1 sub 4 mul)}
\end{pspicture}}
\begin{document}
    \foreach \i in {0,0.1,...,1.0}{\obj{\i}}
\end{document}

在此处输入图片描述

答案2

如果你想制作这样的动画 gif,你可能需要编译

\documentclass[border=1cm,tikz]{standalone}
\usetikzlibrary{arrows.meta}
\begin{document}
\foreach \X in {180,175,...,90}
{\begin{tikzpicture}
\begin{scope}
\draw (0,0) circle (10cm);
\draw[line width=0.15cm, blue] (10,0) arc (0:360:10) ;
\draw[-] (-12,0) -- (12,0) node[right] {$x$};
\draw[-] (0,-12) -- (0,12) node[above] {$y$};
\draw[line width=0.15cm,red,{Circle}-{Circle},shorten >=-2*\pgflinewidth,shorten
<=-2*\pgflinewidth] (10,0) -- ++(\X:10);
\node[scale=15.5, red, right, opacity=0.5] at (2,2) {r};
\end{scope}
\end{tikzpicture}}
\end{document}

pdflatex将结果 pdf 转换为

convert -density 300 -delay 34 -loop 0 -alpha remove outfile.pdf ani.gif

要得到

在此处输入图片描述

当您尝试将其中几个修补在一起时,您需要定义一些行为与 beamer 命令类似的命令\only

\documentclass[border=1cm,tikz]{standalone}
\usetikzlibrary{arrows.meta}
\def\Only<#1-#2>#3{\ifnum\numexpr\X+1>#1
\ifnum\numexpr\X-1<#2
\pgfmathtruncatemacro{\DeltaX}{\X+1-#1}
\xdef\DeltaX{\DeltaX}
#3
\fi\fi}
\begin{document}
\pgfmathtruncatemacro{\Xmax}{50}
\foreach \X in {0,1,...,\Xmax}
{\begin{tikzpicture}[fat line/.style={line width=0.15cm,red,{Circle}-{Circle},shorten >=-2*\pgflinewidth,shorten
<=-2*\pgflinewidth},cc/.style={line width=0.15cm,
blue},annot/.style={scale=15.5}]
\draw[-] (-12,0) -- (12,0) node[right] {$x$};
\draw[-] (0,-12) -- (0,12) node[above] {$y$};
%
\Only<2-5>{
\draw[fat line] (0,0) -- (2*\X,0);
}
\Only<6-10>{
\draw[fat line] (0,0) -- (10,0) node[midway,above,annot,red]{$r$};
}
\Only<11-25>{
\typeout{Delta=\DeltaX}
\draw[cc] (10,0) arc[start angle=0,end angle={\DeltaX*24},radius=10];
\draw[fat line] (0,0) -- ({\DeltaX*24}:10);
}
\Only<26-\Xmax>{
\draw[cc] circle[radius=10cm];
}
\Only<26-35>{\draw[fat line] (10,0)  -- ++ ({180-\DeltaX*9}:10);}
\Only<36-45>{\draw[fat line] (10,0) arc(0:{18*\DeltaX/pi}:10) -- ++
({18*\DeltaX/pi+90}:{10-\DeltaX});}
\Only<46-50>{
\draw [fill=green!70!black,fill opacity=0.2] (0,0) -- (3,0) 
node[green!70!black,below,annot,opacity=1]{rad} arc[start angle=0,
end angle={180/pi},radius=3] -- cycle;
\draw[cc,green!70!black] (10,0) -- (0,0) 
-- ({180/pi}:10);
}
\end{tikzpicture}}
\end{document}

在此处输入图片描述

相关内容