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 would like to draw a few concentric circles with origins of P1 and P2 where all the circles are greater than the minimum distances. The min distances is where the circles will touch at one point only. I would also like to have that circle added to the diagram as well.

How can I find the min circles where this would occur? For the other circles greater than this distance, how can I add them in with a for loop or something of that nature?

Then I want to draw the arc that connects all the intersecting points.

\documentclass{article}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}[scale = .75]
  \node[scale = .75] (P1) at (3, 0) {\(P_1\)};
  \node[scale = .75] (P2) at (-1.5, 2) {\(P_2\)};
  \node[scale = .75] (F) at (0, 0) {\(F\)};
  \draw (F) -- (P1);
  \draw (F) -- (P2);
  \draw (P1) -- (P2);
\end{tikzpicture}
\end{document}

Here is my horrible example drawing, just remember those are circles:

enter image description here

Here is another extremely poor example:

enter image description here

share|improve this question
    
The minimum circle can be found relative easily, using PGF math’s veclen function on the .center anchors of the nodes. (Wouldn't it be better to mark the coordinates with little dots and label these P1, etc?) The other circles can be added with a \foreach loop, but are there any rules? How many? Delta radius? Can you elaborate on the last bit, the arc? –  Qrrbrbirlbel Jun 8 '13 at 1:21
    
@Qrrbrbirlbel I am looking to add a total of 3 circles: the min and two greater with a distance of about 1 cm between them all. I need the labels but when I tried to put in below, left, and above = 2pt, respectively, the labels didn't drop down. The arc would connect all the intersections of the circles. –  dustin Jun 8 '13 at 1:25
    
@Qrrbrbirlbel section 2.3.2 you will see the arc. –  dustin Jun 8 '13 at 1:27
    
Uhh, I see a lot of arcs! And: The minimum-radius circles have different radii. What role has F in this? –  Qrrbrbirlbel Jun 8 '13 at 1:32
    
@Qrrbrbirlbel F is the focus of a transfer ellipse. –  dustin Jun 8 '13 at 1:33
add comment

4 Answers 4

I hope this helps you with the first two parts of your question.

The calc library provides the ($(p1)!<magic>!(p2)$) syntax that evaluates to various coordinates.
If <magic> is a ratio (say, .1, .5 or even -.1) the resulting coordinate lies between (p1) (ratio = 0) and (p2) (ratio = 1). If <magic> is a coordinate (like (F)), this coordinate is projected orthogonal onto the line between (p1) and (p2) (in the example below, the resulting circles a gray).

The very small library through provides only one option: circle through. This option accepts one coordinate through which the circle (this is a node of the shape circle) goes.

The option circle through extra radius which is to be used after circle through adds its argument to the circle’s radius.

The coordinate which will produce equal-radius circles will be saved under the name (half-center), the coordinate where (F) is projected onto the line will be stored unter the name (F-center) (please use better names in your project ;)). One could also use calc’s ($<stuff>$) syntax for circle through but this way, we can reference these coordinates later without the need to let TikZ re-calculate the coordinate over and over again (and it is easier to maintain).

The—apparently un-documented—intersection cs can be used to find the intersection of line/line, lines/circle and circle/circle. This works only if the circle is a node!

There is also the intersections library which can find any intersection between arbitrary paths (refer to Gonzalo Medina’s example, and also TeX.se which has some interesting (and abusing) examples).

Now, I don’t know nothing about this “arc”. If it is a true arc (part of a circle = constant radius) you can take three coordinates (preferable the most outer ones and the center one) and calculate the needed center and start and end angle), but if not, you can add more hidden circles as I did in the example below with {draw=none}/3cm.

If you want a correct smooth hyperbole, I’mma gonna need some math.

Code

\documentclass[tikz,convert=false]{standalone}
\usetikzlibrary{through,calc}
\makeatletter
\tikzset{circle through extra radius/.code={% unorthodox addon for the through library
                                            % needs to be used after 'circle through'!
                                            % this can be avoided by slightly changing the source
  \tikz@addoption{%
    \pgfmathsetlengthmacro\pgf@tempa{\pgfkeysvalueof{/pgf/minimum width}+2*(#1)}%
    \pgfset{/pgf/minimum width/.expanded=\pgf@tempa}%
  }%
}}
\tikzset{
  special style/.code={%
    \if#1\tikz@nonactiveexlmark
      \pgfkeysalso{@special style}%
    \else
      \pgfkeysalso{style/.expanded=#1}%
    \fi
  },
  @special style/.style={draw=none,fill=none}
}
\makeatother
\begin{document}
\begin{tikzpicture}[
  every label/.append style={font=\small},
  dot/.style={fill,outer sep=+0pt,inner sep=+0pt,minimum size=2pt,shape=circle,draw=none,label={#1}},
  dot/.default={}
]

  \node[dot={right:\(P_1\)}] (P1) at ( 3,   0) {};
  \node[dot={\(P_2\)}]       (P2) at (-1.5, 2) {};
  \node[dot={below:\(F\)}]   (F)  at ( 0,   0) {};
  \path [blue] (F) edge (P1) edge (P2) (P1) edge (P2);

  \draw[dashed,gray] (F) -- ($(P1)!(F)!(P2)$) coordinate (F-center);
  \path ($(P1)!.5!(P2)$) coordinate (half-center);
  \foreach \sStyle/\xFocus in {{draw=gray}/F,{draw,thick}/half}
    \foreach \cPoint in {1,2}
     \foreach \sStyleR/\dDeltaRadius[count=\cRadius from 0] in {/0cm,/1cm/,/2cm,!/3cm}
       \node[style/.expanded=\sStyle, special style/.expanded={\sStyleR}] at (P\cPoint.center) ({\xFocus:\cPoint:\cRadius}) [circle through/.expanded={(\xFocus-center)},circle through extra radius=\dDeltaRadius] {};

  \foreach \cSolution in {1,2}
    \foreach \cRadius in {1,...,3}
    \coordinate (i-\cRadius-\cSolution) at (intersection cs: first node={F:1:\cRadius}, second node={F:2:\cRadius}, solution=\cSolution);
%  
  \draw[green] (i-3-1) -- (i-2-1) -- (i-1-1) -- (F-center) -- (i-1-2) -- (i-2-2) -- (i-3-2); % These are straight line segments, but would you have known? ;)
\end{tikzpicture}
\end{document}

Output

enter image description here

Code (with plot/smooth)

\documentclass[tikz,convert=false]{standalone}
\usetikzlibrary{through,calc}
\makeatletter
\tikzset{circle through extra radius/.code={% unorthodox addon for the through library
                                            % needs to be used after 'circle through'!
                                            % this can be avoided by slightly changing the source
  \tikz@addoption{%
    \pgfmathsetlengthmacro\pgf@tempa{\pgfkeysvalueof{/pgf/minimum width}+2*(#1)}%
    \pgfset{/pgf/minimum width/.expanded=\pgf@tempa}%
  }%
}}
\tikzset{
  special style/.code={%
    \if#1\tikz@nonactiveexlmark
      \pgfkeysalso{@special style}%
    \else
      \pgfkeysalso{style/.expanded=#1}%
    \fi
  },
  @special style/.style={draw=none,fill=none}
}
\makeatother
\begin{document}
\foreach \fRatio in {.05,.1,...,.96}{%
\begin{tikzpicture}[
  every label/.append style={font=\small},
  dot/.style={fill,outer sep=+0pt,inner sep=+0pt,minimum size=2pt,shape=circle,draw=none,label={##1}},
  dot/.default={}
]
  \node[dot={right:\(P_1\)}] (P1) at ( 3,   0) {};
  \node[dot={\(P_2\)}]       (P2) at (-1.5, 2) {};
  \node[dot={below:\(F\)}]   (F)  at ( 0,   0) {};
  \path [blue] (F) edge (P1) edge (P2) (P1) edge (P2);

  \path ($(P1)!\fRatio!(P2)$) coordinate (half-center);
  \foreach \sStyle/\xFocus in {{draw,thick}/half}
    \foreach \cPoint in {1,2}
     \foreach \sStyleR/\dDeltaRadius[count=\cRadius from 0] in {/0cm,!/.25cm,!/.5cm,!/.75cm,/1cm/,!/1.5cm,/2cm,!/2.5cm,/3cm,!/3.5cm} {
       \node[style/.expanded=\sStyle, special style/.expanded={\sStyleR}] at (P\cPoint.center) ({\xFocus:\cPoint:\cRadius}) [circle through/.expanded={(\xFocus-center)},circle through extra radius=\dDeltaRadius] {};
       \global\let\cRadius\cRadius
     }

  \let\maxCircles\cRadius
  \edef\maxCirclesMinus{\number\numexpr\maxCircles-1\relax}%
  \foreach \cSolution in {1,2}
    \foreach \cRadius in {1,...,\maxCircles}
      \coordinate (i-\cRadius-\cSolution) at (intersection cs: first node={half:1:\cRadius}, second node={half:2:\cRadius}, solution=\cSolution);

  \def\myList{}
  \foreach \cRadius in {\maxCircles,\maxCirclesMinus,...,1} {\xdef\myList{\myList(i-\cRadius-1)}}
  \edef\myList{\myList(half-center)}
  \foreach \cRadius in {1,...,\maxCircles} {\xdef\myList{\myList(i-\cRadius-2)}}
  \draw[ultra thick,green,smooth] plot coordinates {\myList};

  % for the bounding box:
    \path (P1) circle (8cm);
    \path (P2) circle (8cm);
\end{tikzpicture}}
\end{document}

Output, .gif

share|improve this answer
    
How can we add the arc that runs through the intersections? –  dustin Jun 8 '13 at 2:16
    
@dustin For the .5 solution (equal radius) the arc will be a line (and can be drawn very easily). For any other solution, can you provide some mathematical background about this arc I can use? Does this arc have a constant radius (meaning it is part of a circle) or is it clothoid (disclaimer: no idea how to implement this, you will need to calculate control points (Bézier stuff))? I surely can give you the coordinates … –  Qrrbrbirlbel Jun 8 '13 at 2:22
    
I made another extremely poor drawing and added it to the OP –  dustin Jun 8 '13 at 2:31
    
That is exactly what I was trying to convey in my post. It looks like an arc for begin straight lines. If I change the circles to make the arc greater will it drastically affect the look then? –  dustin Jun 8 '13 at 2:34
    
What kind of math do you need? Your examples are great though. –  dustin Jun 10 '13 at 2:36
show 1 more comment

This might be a case where it makes sense to construct the drawing using external software like Geogebra. Geogebra actually exports surprisingly good TikZ code, which can be used as a starting point for manual adjustments:

\documentclass[10pt]{article}
\usepackage{tikz}
\usetikzlibrary{arrows}
\pagestyle{empty}
\begin{document}
\begin{tikzpicture}[line cap=round,line join=round,>=triangle 45,x=1.0cm,y=1.0cm]
\clip(-4.3,-3.2) rectangle (7.4,6.3);
\draw [gray] (-0.36,3.16) circle (0.64cm);
\draw [gray] (1.48,1) circle (2.2cm);
\draw [gray] (-0.36,3.16) circle (1.27cm);
\draw [gray] (-0.36,3.16) circle (1.91cm);
\draw [gray] (1.48,1) circle (2.84cm);
\draw [gray] (1.48,1) circle (3.47cm);
\draw [samples=50,domain=-0.99:0.99,rotate around={130.43:(0.56,2.08)},xshift=0.56cm,yshift=2.08cm] plot ({0.78*(1+(\x)^2)/(1-(\x)^2)},{1.18*2*\x/(1-(\x)^2)});
\begin{scriptsize}
\fill [red] (1.48,1) circle (1.5pt);
\draw[red] (1.64,1.26) node {$A$};
\fill [red] (-0.36,3.16) circle (1.5pt);
\draw[red] (-0.2,3.42) node {$B$};
\end{scriptsize}
\end{tikzpicture}
\end{document}
share|improve this answer
    
Can you also provide the GeoGebra file? What “arc” is this? –  Qrrbrbirlbel Jun 8 '13 at 2:34
    
The arc should go through the tangent of the two circles though. –  dustin Jun 8 '13 at 2:37
    
@Qrrbrbirlbel: It's a hyperbola. geogebratube.org/student/m40774?mobile=true –  Jake Jun 8 '13 at 2:43
    
@dustin: Ah, yeah, that makes sense. You should really specify your requirements more precisely: geogebratube.org/student/m40775 –  Jake Jun 8 '13 at 2:51
    
@dustin: I've edited my answer to use circles of different sizes now. –  Jake Jun 8 '13 at 2:54
show 4 more comments

The length of the segment joining P1 and P2 can be obtained with the help of the calc library,

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{calc}

\begin{document}
\begin{tikzpicture}[scale = .75]
  \node (P1) at (3, 0) {\(P_1\)};
  \node (P2) at (-1.5, 2) {\(P_2\)};
  \node (F) at (0, 0) {\(F\)};
  \draw (F) -- (P1);
  \draw (F) -- (P2);
  \draw (P1) -- (P2);
\foreach \radio in {0.5,0.8,1.1}
{
\draw[green] let \p1= ($ (P2) - (P1) $), \n2 = {veclen(\x1,\y1)}
 in (P1) circle [radius=\radio*\n2];
\draw[red] let \p1= ($ (P2) - (P1) $), \n2 = {veclen(\x1,\y1)}
 in (P2) circle [radius=\radio*\n2];
}
\end{tikzpicture}

\end{document}

enter image description here

The intersection points of the circles can be obtained with the help of the intersections library; then this points can be joined (I used a simple bend left, since I didn't know what kind of path should join those intersection points; now I know the path is part of an hyperbola, so perhaps tomorrow I'll do the calculations to find the equation of the hyperbola):

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{calc,intersections}

\begin{document}
\begin{tikzpicture}[scale = .75]
  \node (P1) at (3, 0) {\(P_1\)};
  \node (P2) at (-1.5, 2) {\(P_2\)};
  \node (F) at (0, 0) {\(F\)};
  \draw (F) -- (P1);
  \draw (F) -- (P2);
  \draw (P1) -- (P2);
\foreach \radioa/\radiob [count=\i] in {0.5/0.5,0.8/0.65,1.1/0.8}
{
\draw[green,name path global=cira\i] let \p1= ($ (P2) - (P1) $), \n2 = {veclen(\x1,\y1)}
 in (P1) circle [radius=\radioa*\n2];
\draw[red,name path global=cirb\i] let \p1= ($ (P2) - (P1) $), \n2 = {veclen(\x1,\y1)}
 in (P2) circle [radius=\radiob*\n2];
}
\foreach \i in {1,2,3}
\path[name intersections={of={cira\i} and {cirb\i},by={m\i,l\i}}]; 
\draw[blue] (m3) to[bend left=10] (m2) to[bend left=10] (m1) to[bend left=10] (l2) to[bend left=10] (l3);
\end{tikzpicture}

\end{document}

enter image description here

share|improve this answer
    
How can we add the arc that connects the intersections? –  dustin Jun 8 '13 at 2:14
    
@dustin Hmm... what intersections? The path connecting the intersections of circles of equal radius will be a straight line. –  Gonzalo Medina Jun 8 '13 at 2:17
    
The radius aren't supposed to be equal. –  dustin Jun 8 '13 at 2:27
    
I made another extremely poor drawing and added it to the OP –  dustin Jun 8 '13 at 2:30
1  
@Jake ah, thanks, then I guess I need to do some math to find the equation of an hyperbola passing through 5 given points. This will have to wait until tomorrow, though (bed time for me). –  Gonzalo Medina Jun 8 '13 at 3:06
show 6 more comments
up vote 2 down vote accepted

I have adapted Qrrbrbirlbel solutions and used Jake's comment on fitting a hyperbola to the concentric circles. Additionally, I changed the location of P2 to line on the x axis as Qrrbrbirlbel suggested to make the math a bit easier. Therefore, the location of F also changed. After that, I took the acrtan to get the angle of rotation to correctly orient the picture.

\documentclass[tikz,convert=false]{standalone}
\usetikzlibrary{through,calc}
\makeatletter
\tikzset{circle through extra radius/.code={% unorthodox addon for the through library
                                            % needs to be used after 'circle through'!
                                            % this can be avoided by slightly changing the source
  \tikz@addoption{%
    \pgfmathsetlengthmacro\pgf@tempa{\pgfkeysvalueof{/pgf/minimum width}+2*(#1)}%
    \pgfset{/pgf/minimum width/.expanded=\pgf@tempa}%
  }%
}}
\tikzset{
  special style/.code={%
    \if#1\tikz@nonactiveexlmark
      \pgfkeysalso{@special style}%
    \else
      \pgfkeysalso{style/.expanded=#1}%
    \fi
  },
  @special style/.style={draw=none,fill=none}
}
\makeatother
\begin{document}
\begin{tikzpicture}[
  every label/.append style={font=\small},
  dot/.style={fill,outer sep=+0pt,inner sep=+0pt,minimum size=2pt,shape=circle,draw=none,label={#1}},
  dot/.default={}
]
\begin{scope}[rotate around ={-20.5560452:(1, -.75)}]
      \node[scale = .75, dot = {right: \(P_1\)}] (P1) at (3cm, 0) {};
      \node[scale = .75, dot = {\(P_2\)}] (P2) at (-1, 0) {};
      \node[scale = .75, dot = {below: \(F\)}] (F) at (1cm, -.75cm) {};
      \path[blue] (F) edge (P1) edge (P2) (P1) edge (P2);
      \path ($(P1)!.75!(P2)$) coordinate (half-center);
      \foreach \sStyle/\xFocus in {{draw, thick}/half}
        \foreach \cPoint in {1, 2}
          \foreach \sStyleR/\dDeltaRadius[count = \cRadius from 0] in
          {/.0cm, /.5cm, /1cm, /1.5cm}
          {
            \node[style/.expanded = \sStyle,
            special style/.expanded = {\sStyleR}] at (P\cPoint.center)
            ({\xFocus:\cPoint:\cRadius}) [circle through/.expanded =
            {(\xFocus-center)}, circle through extra radius = \dDeltaRadius] {};
            \global\let\cRadius\cRadius
         }

      \clip(-4, -5) rectangle (8, 5);
      \draw [samples = 50, domain = -0.99:0.99, xshift = 1cm, red,
      thick] plot ({(-1 - (\x)^2) / (1 - (\x)^2)},
      {1.73 * (-2) * (\x) / (1 - (\x)^2)});
    \end{scope}
  \end{tikzpicture}
  \end{document}

enter image description here

share|improve this answer
    
Nice! How did you fit the hyperbola? –  Jake Jun 10 '13 at 18:53
1  
@Jake I used Geogebra to find the hyperbola. –  dustin Jun 10 '13 at 19:33
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.