1

How can I find the smooth curve connecting or passing through the circles centers and draw an arrow parallel to it with certain offset?

\documentclass[border=2pt]{standalone}
\usepackage{tikz}

\begin{document}
    \begin{tikzpicture}
     \foreach[count=\i] \x in {0,1,...,6}{%
        \pgfmathsetmacro\ml{1.2^(\i-1)}
        \draw (1,1)++(\x*30:5*\ml) circle[radius=1];
    }
\end{tikzpicture}
\end{document}

enter image description here

4

Updated Answer

Following the determination of the Hobby path as the one desired and some clarification regarding the 'offset', here's an amended answer based on that.

\documentclass[border=10pt,multi,tikz]{standalone}
\usetikzlibrary{hobby,arrows.meta}
\begin{document}
\begin{tikzpicture}
  \foreach [evaluate=\i as \ml using {1.2^\x}] \x in {0,1,...,6}{%
    \draw (1,1) ++(\x*30:5*\ml) circle [radius=1] ++(\x*30:1.5) coordinate (c\x) ++(\x*30:-3) coordinate (d\x);
  }
  \draw [-Latex, ultra thick, blue] [use Hobby shortcut] (c0) .. (c1) .. (c2) .. (c3) .. (c4) .. (c5) .. (c6);
  \draw [Latex-, ultra thick, magenta] [use Hobby shortcut] (d0) .. (d1) .. (d2) .. (d3) .. (d4) .. (d5) .. (d6);
\end{tikzpicture}
\end{document}

inside and outside

Original Answer

There are infinitely many paths through the centres of the circles. Hence, it is not at all clear which you mean by 'the' path.

Moreover, what kind of offset matters a lot. Here, I assume the path should be offset relative to (1,1) in the direction of the relevant circle's centre, by a constant distance. This means the points are 'pushed out' from a centre at (1,1).

Infinitely many paths is too many for an answer on this site. I draw three, each with an arrow. The others are left as an exercise for you, gentle reader.

\documentclass[border=10pt,multi,tikz]{standalone}
\usetikzlibrary{hobby}
\begin{document}
\begin{tikzpicture}
  \foreach [evaluate=\i as \ml using {1.2^\x}] \x in {0,1,...,6}{%
    \draw (1,1) ++(\x*30:5*\ml) circle [radius=1] ++(\x*30:1.5) coordinate (c\x);
  }
  \draw [->] [green] (c0) \foreach \i in {1,...,6} { -- (c\i) };
  \draw [->] [blue] [use Hobby shortcut] (c0) .. (c1) .. (c2) .. (c3) .. (c4) .. (c5) .. (c6);
  \draw [->] [magenta] \foreach  \i [remember=\i as \ilast (initially 0)] in {1,...,6} { (c\ilast) [out=-120,in=60]to (c\i) };
\end{tikzpicture}
\end{document}

three of infinitely many possible paths

  • Thanks for your answer. The blue one is the line that I need to be an arrow. For offset, I meant that I need to control whether this arrow should be engulfed by this pattern of circles or surrounding it. – Diaa Apr 4 '17 at 23:53
  • 1
    @DiaaAbidou Well, this shows you how to do that. Just pick the blue one and use a negative distance if you want the path inside the circles or positive (as here) if you want it outside them. – cfr Apr 4 '17 at 23:55
  • There's really a library called hobby? :) – Dr. Manuel Kuehner Apr 4 '17 at 23:59
  • 1
    @Dr.ManuelKuehner Of course. – cfr Apr 5 '17 at 0:01
  • 1
    @Dr.ManuelKuehner Hobby is amazing. – cfr Apr 5 '17 at 0:04
3

Like this?

enter image description here

\documentclass[tikz, border=3mm]{standalone}

\begin{document}
\begin{tikzpicture}
\foreach \x [count=\i, remember=\x as \rx (initially 01)] in {0,1,...,6}
{%
\pgfmathsetmacro\ml{1.2^(\i-1)}
\pgfmathsetmacro\mr{1.2^(\i-2)}
\ifnum\i>1
\draw[thick, red] (\rx*30:5*\mr) -- (\x*30:5*\ml);
\fi
\draw (\x*30:5*\ml) circle[radius=1];
}
\end{tikzpicture}
\end{document}

or

\documentclass[tikz, border=3mm]{standalone}

\begin{document}
\begin{tikzpicture}
\foreach \x [count=\i,
              remember=\x as \rx (initially 0),
              evaluate=\i as \ml using 1.2^(\i-1),
              evaluate=\i as \mr using 1.2^(\i-2)] in {0,1,...,6}
{
\ifnum\i>1
\draw[blue] (\rx*30:5*\mr) -- (\x*30:5*\ml);
\fi
\draw[thick, red] (\x*30:5*\ml) circle[radius=1];
}
\end{tikzpicture}
\end{document}
  • Yes, but preferably, I need it to be smooth. Additionally, I want to draw an arrow parallel to it and control the position of this arrow to be either inside this pattern of circles or outside. – Diaa Apr 4 '17 at 23:55
  • ok, you now already have @cfr answer. – Zarko Apr 5 '17 at 0:03
  • Why do you want to delete it? It answers the original question and I guess you didn't see my green path before posting your red one. Besides, yours goes through the centres. – cfr Apr 5 '17 at 0:06
  • Your answer is helpful to me as well since it is informative to me in terms of the usage of remember and evaluate inside foreach. – Diaa Apr 5 '17 at 0:07
  • as you can see, I already change my mind :) and +1 for hobby – Zarko Apr 5 '17 at 0:07

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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