4

I'm working in a project for university using LaTeX and I'll make a gif explaning the radians of math. And I really don't know how to make this type of line

enter image description here

What I have done so far

\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}

2 Answers2

12

If you wish to produce such animated gifs, you may want to compile

\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}

with pdflatex and then convert the resulting pdf with

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

to get

enter image description here

When you attempt to patch several of those together, you want to define some command which behaves similarly as the beamer command \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}

enter image description here

  • I clicked ! Ty so much! But just one more question :D There is a way to put marmot's animation frame by frama separed in diferents pdfs? Or it needs to be one? – Felipe Fonseca Apr 21 '19 at 03:41
  • Like ive done here: http://prntscr.com/nerl0s and http://prntscr.com/nerl3o – Felipe Fonseca Apr 21 '19 at 03:42
  • @FelipeFonseca I added something that might be useful for that task. –  Apr 21 '19 at 06:16
  • Marmot there is a way to talk with you private?? I really need your help with some questions! If you cant there is no problems – Felipe Fonseca Apr 21 '19 at 21:47
  • @FelipeFonseca Sorry, this is not how this site works. Everything here is non-private. You can reach out to users on the chat but the chat is for chat, i.e. not for questions of this type. But you can ask as many questions as you want here, as long as you attach some code that shows what you have tried they will, according to my experience, be well-received and likely to get a useful answer. –  Apr 21 '19 at 21:54
  • Alright, so iam making my university project using LaTeX and my teacher want us to make a animated PDF for the text. The pdf must be photo by photo for example: photo1, photo2, photo3 and etc. I started really well my pdf that it is in this link link And I really liked the way that you did the .gif of the line and one of my questions is, how to transform what you have already made to be separed .tex by .tex (photo by photo)... Can you help me ? If it is too complicated i undestand :/ Iam really lost in Latex ;- – Felipe Fonseca Apr 22 '19 at 00:06
  • 1
    @FelipeFonseca Here you can find an incomplete list of possibilities to create animations with LaTeX. I feel it would be best if you could go through this list with your advisor and then decide what you want. Apart from animated gifs you can create animated pdf, svg (which can be embedded in web sites) and mp4. You can also employ the full beamer machinery for that. I really think you guys should first have a look at the options before making a quick decision how to proceed. –  Apr 22 '19 at 01:14
  • Alright marmot! I got it the part of the line (http://prntscr.com/nh0owz) changing the number of the \foreach! Ty so much! but how can I do it in this part without using \only???? Help me please man! (http://prntscr.com/nh0p7r) how can i make the curved line changing in each .tex? without making lots of them? – Felipe Fonseca Apr 26 '19 at 04:03
  • 2
    @FelipeFonseca Please ask a new question. Please note that some users do not like if a user unaccepts an answer just to add an additional request. If you feel you want to unaccept my answer this is up to you but please do not expect me to address additional requests. –  Apr 26 '19 at 04:08
8

A PSTricks solution only for fun purposes.

\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}

enter image description here

Display Name
  • 46,933