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'm trying to plot in TikZ the two tangents to a fixed circle passing through a given point.

In some details, given an arbitrary circle centered at C with with radius r, and a point P outside of the circle. I want to plot the two tangents from P to the circle. My problems are mainly:

  1. I want it to plot a general case, namely, the circle's center and radius should be arbitrary as well as the point outside.
  2. The formulas, that I came up with, are not too friendly and involves cubic factors of coordinates and square roots.

Any tips, advices, code fragments etc. will be very welcome!

Epilog: This question was actually, the first step towards the generation of some plots related to the Poncelet's Porism. I felt on one hand that the built in methods, in TikZ related to the notion of tangents, were too hard for me to use. On the other hand, the tkz-euclid is too much in French :) Finally, I reverted to PiScript, which is easier to program in my mind. Here is one of the results I obtained (here's the source code, if you're interested):

enter image description here

As for the answer I chose; it is the one which provides a solution to the question as I posed it in the simplest manner. Thank you all for the help!

share|improve this question
    
    
@Dror: not difficult with PSTricks, see answer –  Herbert Sep 23 '11 at 13:34
    
@Dror: This should really have been a separate question. –  Peter Grill Sep 23 '11 at 15:58
    
@Peter: Well I didn't want to be too lengthy in the first place, and I tried to break my question into parts. However, the answers I got weren't good for my ultimate goal. I didn't want to ask a "how-do-I-do-this" sort of question. –  Dror Sep 23 '11 at 20:54

5 Answers 5

up vote 6 down vote accepted

In the pgf manual page 130 (ver. 3.10), you have the exact example. I just copy it from there for convenience in case anybody needs. It requires \usetikzlibrary{calc}

\begin{tikzpicture}
\draw[help lines] (0,0) grid (3,2);
\coordinate (a) at (3,2);
\node [circle,draw] (c) at (1,1) [minimum size=40pt] {$c$};
\draw[red] (a) -- (tangent cs:node=c,point={(a)},solution=1) --
(c.center) -- (tangent cs:node=c,point={(a)},solution=2) -- cycle;
\end{tikzpicture}
share|improve this answer
    
do you know how this is implemented? I might need some variant... –  Dror Sep 17 '11 at 11:10
    
Actually no but i will look it up when I have the chance –  percusse Sep 17 '11 at 22:21

Here is an example using the tikz-eculide. I am not an expert on this and could not find the english documentation on this, so had to resort to mixing the usual tikz syntax, but does seem to work.

\begin{document} 
\begin{tikzpicture}
   \newcommand*{\Radius}{3cm}%
   \coordinate (Origin) at (0,0);
   \coordinate (P) at (4,4);% External point

   \node [right,blue] at (P) {P};
   \draw[thin,gray!30] (-5,-5) grid (5,5);

   \tkzDrawCircle[R,ultra thick](Origin,\Radius)
   \tkzTangent[from with R= P](Origin,\Radius)  \tkzGetPoints{D1}{D2} 

   \tkzDrawSegments[color=red,ultra thick](P,D1)% First tangent
   \tkzDrawSegments[color=red,ultra thick](P,D2)% Second tangent
\end{tikzpicture}     
\end{document}

enter image description here

share|improve this answer

tkz-eucide, based on tikz is a package that simplifies a lot this type of problem.

To have random points and radius, I suggest the following code:

\documentclass{minimal}

\usepackage{tkz-euclide}

\begin{document}
   \begin{tikzpicture}
      \tkzDefPoint(0,0){C}
      \tkzDefPoint(5,5){B}
      \tkzGetRandPointOn[rectangle = C and B]{A}
      \tkzDefPoint(10,10){Q}
      \tkzGetRandPointOn[rectangle = B and Q]{P}
      \tkzCalcLength[cm](C,A)\tkzGetLength{CRadius}
      \tkzDrawCircle[R](C,\CRadius cm)

      \tkzDefPointBy[rotation=center C angle 0](P)
      \tkzGetPoint{a}
      \tkzTangent[from with R = a](C,\CRadius cm)
      \tkzGetPoints{T_1}{T_2}
      \tkzDrawLines(a,T_1 a,T_2)
      \tkzDrawSegments(C,T_1 C,T_2)

      \tkzDrawPoints(C,P,T_1,T_2)
      \tkzLabelPoints(C,P,T_1,T_2)
   \end{tikzpicture}
\end{document}

Since the documentation is only in French and this is an English-speaking forum, I'll explain a bit the mechanics:

First the points C and B are defined, then a random point is generated inside the rectangle (A), defining the segment that gives a radius of the circle. Then another random point is defined (P), which should be outside the circle. This is why it is outside the original rectangle.

The circle is drawn and then the two possible tangents are constructed and the radii associated with the tangent points.

Finally the points are drawn (as small circles) and labelled.

Enjoy! :)

share|improve this answer
1  
Unfortunately, the tkz-euclid seems to be very powerful, but it is inaccessible for non French speakers. @Count Zero, thanks for the added explanations. –  Dror Sep 17 '11 at 11:12

Pretty simple with PSTricks ...

\documentclass{article}
\usepackage{pst-eucl,pstricks-add}
\begin{document}

\def\psR{5}\def\psM{0,0}\def\psr{0.4}\def\psm{1,0.5}

\begin{pspicture}(-5,-5)(5,5)
\pscircle(\psM){\psR}\pscircle(\psm){\psr}
\pnode(\psR;0){Start}\pnode(\psm){m}\pnode[\psr,0](\psm){mA}
\pnode(Start){C2}
\multido{\iA=1+1}{75}{%
  \psCircleTangents(C2)(\psm){\psr}
  \pstInterLC[PointSymbol=none,PointName=none]{C2}{CircleT1}{psM}{Start}{C1}{C2} 
  \psline[linecolor=blue!80](C1)(C2)}
\end{pspicture}

\end{document}

enter image description here

enter image description here

share|improve this answer
    
This is indeed very compact! Very nice! I have some followup questions/discussions related to this plot. If you're interested I'd be happy to continue this off this web site. Thanks again! Dror Atariah. –  Dror Sep 23 '11 at 20:59
    
sure, go on ... –  Herbert Sep 23 '11 at 21:02
    
How should we do it? Would be nice to have more people and keep the "chat" for later reference. –  Dror Sep 26 '11 at 11:18
    
maybe, but I have not the time for a chat. You can reach me at Herbert.Voss@fu-berlin.de –  Herbert Sep 26 '11 at 12:21

After getting impressed by the power of PStricks, I tried to come up with a TikZ solution for your second question just for the fun of it, to see if I can replicate the example (in a rather simple way). Here is what I did...

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{calc,intersections}
\newcommand*{\Radius}{10cm}
\newcommand*{\gettang}[2]{
\path[name path = L] (#1) -- ($(#1)!\Radius!(tangent cs:node=c,point={(#1)},solution=1)$);
\path [name intersections={of=BIG and L}];
\draw (#1)  -- (intersection-1) node[inner sep=0cm] (#2) {};}

\begin{document}
\begin{tikzpicture}
\node[name path = BIG,circle,draw,minimum size=\Radius] (bc) at (0,0) {};
\node [circle,draw,minimum size=0.764cm] (c) at (1,1) {$c$};

\foreach \y in {90,89,...,84}{
\coordinate (a1) at (\y:5);
\coordinate (tangpoint) at (tangent cs:node=c,point={(a1)},solution=1);
\path[name path = L] (a1) -- ($(a1)!\Radius!(tangpoint)$);
\path [name intersections={of=BIG and L}];
\draw (a1) -- (intersection-1) node[inner sep=0cm] (a2) {};
\foreach \x [remember=\x as \lastx (initially 2)] in {3,4,...,21} {\gettang{a\lastx}{a\x}};}
\end{tikzpicture}
\end{document}

A small explanation about the algorithm:

a) I take a point (a1) on the circle. (north pole is selected in the example for simplicity)

b) I draw the extended line (one diameter long to be safe) through the tangent point

c) Intersect it with the big circle. Take one of the solutions.

d) Draw the line from the initial point to the intersection.

e) And repeat it for given number of times.

Here are the results for different numbers of iterations.

enter image description here

I didn't understand how you can obtain those nicely repeating lines, such that it returns to the initial point after travelling a number of times. Hence I can only have this by eye-balling but if you let me know how to do it, I think we can modify the code.

I still don't have the full code. There is a bug that prevents the last two set finishing the on the initial point. I will try to see if I can fix that.

share|improve this answer
    
The theorem implies that if the polygon closes for one starting point, then it will close for any after the same number of iterations. I'm having problems with closing my plot using PiScript as well. –  Dror Sep 26 '11 at 11:08
    
@Dror That's interesting because the PStricks examples don't seem to have such problems. Thet's why I thought there is some sort of a condition that closes the polygon. –  percusse Sep 26 '11 at 12:21
    
There is one! Known for N=3,..,20 with some gaps. Checkout: mathworld.wolfram.com/PonceletsPorism.html. –  Dror Sep 26 '11 at 12:49

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.