Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I want to draw circular waves like these:

enter image description here

in TikZ.

share|improve this question
9  
Welcome to TeX.sx! On this site, a question should typically revolve around an abstract issue (e.g. "How do I get a double horizontal line in a table?") rather than a concrete application (e.g. "How do I make this table?"). Questions that look like "Please do this complicated thing for me" tend to get closed because they are "too localized". Please try to make your question clear and simple by giving a minimal working example (MWE): you'll stand a greater chance of getting help. –  hpesoj626 Nov 14 '12 at 23:30
4  
Well to start off with, it would be helpful if you figured out the equation(s) to that represents that path you want to draw -- that is a math issue, not a TeX issue. Once you get that (perhaps in parametrized form), the I'd suggest you use pgfplots pacakge to draw it. There should be plenty of examples on this site for that. Once you make an attempt and run into a specific issue, then perhaps you can update this question showing what you attempted, and then people here could help you with a specific issue. –  Peter Grill Nov 14 '12 at 23:38
add comment

5 Answers 5

up vote 27 down vote accepted

I'll draw the first one and you try to work on the rest. You can do this iteratively, too, I think, with some extra work.

\documentclass[tikz,border=10]{standalone}

\begin{document}

\begin{tikzpicture}[scale=3,very thick]
\draw[color=red,domain=0:6.28,samples=200,smooth] plot (canvas polar
cs:angle=\x r,radius={28-8*sin(3*\x r)});
\draw[,dashed,domain=0:6.28,samples=200,smooth] plot (canvas polar
cs:angle=\x r,radius={0.5 r});
\end{tikzpicture}

\end{document}

enter image description here

As have been said in the comment above, once you have the mathematical equation in polar coordinates, it is just a matter of some pgfplots work. To learn more about pgplots, which is built upon tikz, type texdoc pgfplots in your terminal.

Edit

This is not a pgfplots solution BTW. As have been noted by Paul Gaborit in comment, pgfplots is superfluous in the given code. I was about to go back to it since I mentioned pgfplots in my answer. I've been away for a while. Anyway, others have already provided other solutions so I will leave my answer as it is.

share|improve this answer
    
Thank you that was exactly what I needed. –  user22117 Nov 15 '12 at 0:07
1  
\usepackage{pgfplots} is superfluous... –  Paul Gaborit Nov 15 '12 at 0:33
    
@PaulGaborit Yeah. Removed it. I was working with article class before replacing it with standalone. And I was thinking of pgfplots solution earlier. Thanks for the heads up. –  hpesoj626 Nov 15 '12 at 8:52
    
Adding border=10 to the options to the standalone class can help when the clipping is overzealous. –  Loop Space Nov 15 '12 at 9:56
1  
@hpesoj626 if you do not mind, I will "copy" something inspired by your example into the pgfplots manual as an example for how to provide polar coordinates into a cartesian axis using data cs=polar (your example is prettier than mine in the manual) –  Christian Feuersänger Nov 17 '12 at 16:39
show 2 more comments

The hardest part is to parametrize the curve. There are lots of ways to do this, one such way is

x(t) = (2+.5*cos(nt))cos(t)
y(t) = (2+.5*cos(nt))sin(t)

where 0\leq t\leq 2\pi and n\in \{3, 4, 5, ....\}

If you vary the .5 it will vary the sharpness of the curve.

Once you have this, you can plot the curve easily using pgfplots and its \addplot command

enter image description here

\documentclass{standalone}

\usepackage{pgfplots}

\begin{document}

\begin{tikzpicture}
 \begin{axis}[axis equal,axis lines=none]
 \addplot[samples=100,domain=0:2*pi,thick] ({(2+.5*cos(deg(5*x)))*cos(deg(x))},{(2+.5*cos(deg(5*x)))*sin(deg(x))});
 \addplot[samples=50,domain=0:2*pi,dashed] ({2*cos(deg(x))},{2*sin(deg(x))});
 \end{axis}
\end{tikzpicture}

\end{document}

Animation: vary n

vary n

\documentclass[tikz]{standalone}

\usepackage{pgfplots}
\usepackage{amsmath}

\begin{document}

\foreach \n in{3,4,...,10}{%
\begin{tikzpicture}
 \begin{axis}[axis equal,
    xmin=-3,xmax=3,
    ymin=-3,ymax=3,
    axis lines=none]
 \addplot[samples=400,domain=0:2*pi,thick] ({(2+.3*cos(deg(\n*x)))*cos(deg(x))},{(2+.3*cos(deg(\n*x)))*sin(deg(x))});
 \addplot[samples=40,domain=0:2*pi,dashed] ({2*cos(deg(x))},{2*sin(deg(x))});
 \node at (axis cs:0,0){$n=\n$};
 \end{axis}
\end{tikzpicture}
}

\end{document}

Animation: vary 'sharpness' of the curve

animate1

\documentclass[tikz]{standalone}

\usepackage{pgfplots}
\usepackage{amsmath}

\begin{document}

\foreach \r in{0.1,0.2,...,1}{%
\begin{tikzpicture}
 \begin{axis}[axis equal,
    xmin=-3,xmax=3,
    ymin=-3,ymax=3,
    axis lines=none]
 \addplot[samples=300,domain=0:2*pi,thick] ({(2+\r*cos(deg(5*x)))*cos(deg(x))},{(2+\r*cos(deg(5*x)))*sin(deg(x))});
 \addplot[samples=40,domain=0:2*pi,dashed] ({2*cos(deg(x))},{2*sin(deg(x))});
 \node at (axis cs:0,0){$r=\r$};
 \end{axis}
\end{tikzpicture}
}

\end{document}

See How to convert pstricks animation to GIF file? for full details of the rest of the animation creation process (just a couple of steps).

share|improve this answer
4  
GarbageCollector has a rival, I see! –  Loop Space Nov 15 '12 at 9:43
add comment

Here is another TikZ solution...

enter image description here

\documentclass{standalone}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}
  \def\r{1cm}
  \def\v{2.5mm}
  \foreach \n in {3,4,5,6}{
    \begin{scope}[xshift=\n*2*(\r+\v+1mm)]
      \draw[thick]  (0:{\r+\v})
      \foreach \a in {1,...,359}{ -- (\a:{\r+cos(\a*\n)*\v}) } -- cycle;
      \draw[dashed] circle (\r);
    \end{scope}
  }
\end{tikzpicture}
\end{document}
share|improve this answer
add comment

If you're not too bothered about the exact equation, here's a method using the hobby package (although you'd need the development version for it to work with foreach, it's nearly ready for upload to CTAN - just needs documentation - but for now it can be found at TeX-SX Launchpad, download hobby.dtx and run tex hobby.dtx).

\documentclass{article}
%\url{http://tex.stackexchange.com/q/82773/86}
\usepackage{tikz}
\usetikzlibrary{hobby}

\begin{document}
\begin{tikzpicture}
\draw[dashed]
    (0,0) circle[radius=3cm];
\def\n{8}
\def\amp{1}
\draw[use Hobby shortcut] ([closed]3-\amp,0) \foreach \k in {1,...,\n}
{ .. (\k*360/\n:{3+(Mod(\k,2) == 1 ? \amp : -\amp)})};
\end{tikzpicture}
\end{document}

Two obvious parameters: \n is twice the number of "lumps" and \amp is the (half) amplitude.

I don't know how to do fancy animations, so here's a static image:

bumpy circles with hobby

share|improve this answer
add comment

Just 4 fun with PSTricks. (and probably Bohr used PSTricks to illustrate his atomic model.)

enter image description here

\documentclass[pstricks]{standalone}
\usepackage{pst-plot}

\psset
{
    unit=\psrunit,
    polarplot,
    algebraic=true,
    plotpoints=150,
}

\begin{document}
\begin{pspicture}(-3,-3)(3,3)
\pscircle[linestyle=dashed](0,0){2}
\psplot[linecolor=red]{0}{TwoPi}{2+.5*sin(3*x)}
\end{pspicture}
\end{document}

Animated version:

enter image description here

\documentclass[pstricks]{standalone}
\usepackage{pst-plot}

\psset
{
    unit=\psrunit,
    polarplot,
    algebraic=true,
    plotpoints=1000,
}

\begin{document}
\multido{\i=2+1}{25}{%
\begin{pspicture}(-3,-3)(3,3)
\pscircle[linestyle=dashed](0,0){2}
\psplot[linecolor=red]{0}{TwoPi}{2+.5*sin(\i*x)}
\end{pspicture}}
\end{document}

Edit:

I am a bit lazy to redo my work above. Please try cos instead of sin if you want to shift the curve period/4 along the angular direction.

The last edit:

The requested random magic by Doctor Kumar is given as follow. Please compile with pdflatex -shell-escape bohring.

% the filename of this code is bohring (not boring!)
\documentclass[preview,border=12pt]{standalone}
\usepackage{filecontents}
\def\filename{Bohr}

\begin{filecontents*}{\filename}
\documentclass[pstricks]{standalone}
\usepackage{pst-plot}

\psset
{
    unit=\psrunit,
    polarplot,
    algebraic=true,
    plotpoints=1000,
}

\begin{document}
\multido{\i=1+1}{25}{%
\begin{pspicture}(-3,-3)(3,3)
\pscircle[linestyle=dashed](0,0){2}
\psplot[linecolor=red]{0}{TwoPi}{2+.5*cos(\i*x)}
\end{pspicture}}
\end{document}
\end{filecontents*}


\usepackage{animate}

\immediate\write18{latex \filename}
\immediate\write18{dvips \filename}
\immediate\write18{ps2pdf \filename.ps}

% begin cleaning
% The following codes are written with Windows' shell commands only for Windows user.
% If you use Linux, then ask other people to translate the codes to Linux's equivalent. 
% If you have no friend who can help you, just comment the code and manually remove the associated files.
\makeatletter
\@for\x:={tex,dvi,ps,log,aux}\do{\immediate\write18{cmd /c del \filename.\x}}
\makeatother
% end cleaning

\begin{document}
\animategraphics[controls,loop,autoplay,scale=1]{2}{\filename}{}{}
\end{document}
share|improve this answer
    
Why the code doesn't contain convert magic line ? ;-) –  Harish Kumar Nov 18 '12 at 0:40
1  
+1 for Bohring :-) –  Harish Kumar Nov 18 '12 at 0:42
    
@HarishKumar: Can you remove the preview environment sandwiching the animategraphics as standalone does it by default? I am limited by the system so I can have 5 edits a day. –  Please don't touch Apr 25 '13 at 12:09
    
Done. Is it OK? –  Harish Kumar Apr 25 '13 at 22:44
    
@HarishKumar: Thank you very much. It suits my intent. –  Please don't touch Apr 26 '13 at 5:09
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.