Tell me more ×
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.

There are two disjoint circles. Their centers and radii are given. Without doing extra calculations, can we draw the 4 tangent lines using PSTricks (preferred) or others?

I asked many Illustrator, Free-hand, CAD experts, they cannot do it exactly. :-)

share|improve this question
2  
What do you mean by "without doing extra calculations"? – Yossi Farjoun Dec 16 '10 at 9:05
@Yossi, without doing extra calculation means we don't need to do trigonometric calculations. I think you know what I mean. – xport Dec 16 '10 at 11:11
Actually, I'm really not sure...is the answer given by Andrew good or did you hope for something like the TikZ tangent option only that it can take two circles instead of a point and a circle? – Yossi Farjoun Dec 16 '10 at 11:40
This can be done by rule and compass. Some GUI grograms, like GeoGebra, Geometer's Sketchpad can draw such Euclidian geometry graphs easily. – Leo Liu Feb 1 '11 at 16:11

3 Answers

up vote 19 down vote accepted

pstricks-add knows a macro for calculating and saving 10 points as nodes, the two central points and the four points on the circle.

\documentclass{article}
\usepackage{pstricks-add}% loads pst-node

\begin{document}
\begin{pspicture}[showgrid](0,0)(10,10)
\pscircle(1,1){1}\pscircle(7,7){3}
\psCircleTangents(1,1){1}(7,7){3}
\pcline[nodesep=-1cm,linecolor=blue](CircleTO1)(CircleTO2)
\pcline[nodesep=-1cm,linecolor=blue](CircleTO3)(CircleTO4)
\pcline[nodesep=-1cm,linecolor=red](CircleTI1)(CircleTI2)
\pcline[nodesep=-1cm,linecolor=red](CircleTI3)(CircleTI4)
\psdots(CircleTC1)\psdots(CircleTC2)%
  (CircleTO1)(CircleTO2)(CircleTO3)(CircleTO4)%
  (CircleTI1)(CircleTI2)(CircleTI3)(CircleTI4)%
\end{pspicture}

\end{document}

the output looks like!

alt text

share|improve this answer
This is a solution with no extra calculations! +1 Very nice! – Yossi Farjoun Dec 17 '10 at 15:37
2  
Just out of curiosity: Did you just implement that feature/function? Two versions (that is 4 days - from ctan.org) back it did not exist. – Carsten Thiel Dec 17 '10 at 15:55
1  
The solution in pst-eucl needs some understanding on how tangent lines are build. The tangents of two circles is the same as 2 times the tangents of a point and one circle. The macro \psCircleTangents from pstricks-add didn't need any understanding of the geometry behind the constructiong of the tangent lines. The package on texnik.dante.de are development versions and will be as soon as possible on CTAN when no problems are posted. – Herbert Dec 17 '10 at 18:20
2  
from today it should be available by the TeXLive update manager. Read the documentation (run "texdoc pstricks-add") to see how the macro works for one circle and two circles. – Herbert Dec 19 '10 at 8:04
1  
thanks. Indeed the documentation was written with hot needles ... I'll correct the typos – Herbert Dec 19 '10 at 20:13
show 4 more comments

TikZ can work out the tangent line between a circle and a point, so it's halfway there for this. With a tiny bit of mathematics, this can be bootstrapped to the tangent lines you want. The following code will do it (though it ought to check for the case where the two radii are the same - at the moment, that will produce an error, as will the situation where the circles overlap).

Here's the result:

Tangent lines

Here's the code:

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

\begin{document}
\begin{tikzpicture}
\pgfmathsetmacro{\rone}{3}
\pgfmathsetmacro{\rtwo}{2}
\pgfmathsetmacro{\mid}{\rone/(\rone + \rtwo)}
\pgfmathsetmacro{\out}{\rone/(\rone - \rtwo)}
\node[draw,circle,minimum size=2 * \rone cm,inner sep=0pt] (c1) at (1,0) {};
\node[draw,circle,minimum size=2 * \rtwo cm,inner sep=0pt] (c2) at (-1,-6) {};
\path (c1.center) -- node[coordinate,pos=\mid] (mid) {} (c2.center);
\path (c1.center) -- node[coordinate,pos=\out] (out) {}  (c2.center);

%\draw[red] (tangent cs:node=c2,point={(mid)}) -- (tangent cs:node=c1,point={(mid)});
%\draw[red] (tangent cs:node=c2,point={(mid)},solution=2) -- (tangent cs:node=c1,point={(mid)},solution=2);

%\draw[red] (tangent cs:node=c2,point={(out)}) -- (tangent cs:node=c1,point={(out)});
%\draw[red] (tangent cs:node=c2,point={(out)},solution=2) -- (tangent cs:node=c1,point={(out)},solution=2);

\foreach \i in {1,2}
\foreach \j in {1,2}
\foreach \k in {mid,out}
\coordinate (t\i\j\k) at (tangent cs:node=c\i,point={(\k)},solution=\j);

\foreach \i in {1,2}
\foreach \k in {mid,out}
\draw[red] ($(t1\i\k)!-1cm!(t2\i\k)$) --  ($(t2\i\k)!-1cm!(t1\i\k)$);

\end{tikzpicture}
\end{document}

The commented-out lines will draw the tangent lines to the exact points, I chose to extend them a little to show that they were genuinely tangent and that's what the code after the commented-out lines are for.

Despite being a mathematician, I didn't actually compute the formulae for the crossing points - I just guessed something that "felt right" and then tested it and it seems to work. However, I can't guarantee that it is right.

share|improve this answer
Fantastic...I was working on it myself...but you beat me to the punch! – Yossi Farjoun Dec 16 '10 at 10:29
@Yossi: If you had a different implementation, you should still post it. – Andrew Stacey Dec 16 '10 at 10:31
cheers, it is not significantly different, and much less neat...I like your answer. don't worry.. – Yossi Farjoun Dec 16 '10 at 10:33

The next version of tkz-euclide can draw the tangent lines. I created two macro for the internal similitude center of two circles and the external similitude center.

\documentclass{scrartcl}
\usepackage[usenames,dvipsnames]{xcolor}  
\usepackage{tkz-euclide} 
\usetkzobj{all} 
\definecolor{fondpaille}{cmyk}{0,0,0.1,0}
\pagecolor{fondpaille}
\color{Maroon}   

\begin{document}  
\begin{tikzpicture}
   \tkzInit[xmin=-5,ymin=-5,xmax=5,ymax=5]
   \tkzDefPoint(0,0){O}
   \tkzDefPoint(4,-5){A}
   \tkzDrawCircle[R](O,3 cm)
   \tkzDrawCircle[R](A,2 cm) 
   \tkzIntSimilitudeCenter(O,3)(A,2) \tkzGetPoint{I}
   \tkzDrawPoint(I) 
   \tkzExtSimilitudeCenter(O,3)(A,2) \tkzGetPoint{J}
   \tkzDrawPoint(J) 
   \tkzTangent[from with R= I](O,3 cm)  \tkzGetPoints{D}{E} 
   \tkzTangent[from with R= I](A,2 cm)  \tkzGetPoints{D'}{E'}
   \tkzTangent[from  with R= J](O,3 cm) \tkzGetPoints{F}{G}
   \tkzTangent[from with R= J](A,2cm)   \tkzGetPoints{F'}{G'} 
   \tkzDrawSegments[color=red](I,D I,E I,D' I,E')   
   \tkzDrawSegments[color=blue](J,F J,G)
  \end{tikzpicture}     

\end{document}

the code is very simple to get these centers:

%<--------------------------------------------------------------------------–> 
%                    Internal Similitude center
%<--------------------------------------------------------------------------–>
\def\tkzIntSimilitudeCenter(#1,#2)(#3,#4){%
\begingroup
\path[coordinate]  (barycentric cs:#1=#4,#3=#2) coordinate (tkzPointResult);
\endgroup
}
%<--------------------------------------------------------------------------–> 
%                    External Similitude center
%<--------------------------------------------------------------------------–>
\def\tkzExtSimilitudeCenter(#1,#2)(#3,#4){%
\begingroup
 \path[coordinate]  (barycentric cs:#1=-#4,#3=#2) coordinate (tkzPointResult);
\endgroup
}

Then we can get the tangents. The code will be upload in a few days on the ctan servers.

enter image description here

share|improve this answer
Thanks for this solution. I am learning PGF/Tikz now because of its better syntax and one-step compilation. – xport Mar 10 '11 at 1:08
@xport: I think it's a good experience. Andrew's solution is interesting too. My package will be updated in a few days beacause I have a lot of works on others packages. – Alain Matthes Mar 10 '11 at 5:59

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.