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 draw a tanget on a circle, but I'm not happy with the result I get from the tangent option.

all particularly, I'd like to have the lines ending smoothly in the circle. The problem is shown enlarged here:

enlarge1 enlarge2

Here is the code for this mininmal example

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

\begin{document}
  \begin{tikzpicture}[thick]
    \node[draw,circle,xshift=2.2cm] (big) [minimum size=25mm] {};
    \node[draw,circle] (small) [minimum size=2mm] {};
    \draw (small.south) -- (tangent cs:node=big,point={(small.south)});
    \draw (small.north) -- (tangent cs:node=big,point={(small.north)},solution=2);
   \end{tikzpicture}
\end{document}

I'd greatly appreciate any advice allowing me to do this!

share|improve this question
add comment

2 Answers 2

up vote 18 down vote accepted

You already have the solution: Just apply the same to the small circle, and throw some outer sep=0 for a nice blend.

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

\begin{document}

  \begin{tikzpicture}[thick]
    \node[draw,circle,xshift=2.2cm,minimum size=25mm,outer sep=0] (big) {};
    \node[draw,circle,minimum size=2mm,outer sep=0] (small) {};
    \draw (tangent cs:node=small,point={(big.south)},solution=2) -- (tangent cs:node=big,point={(small.south)});
    \draw (tangent cs:node=small,point={(big.north)},solution=1) -- (tangent cs:node=big,point={(small.north)},solution=2);
   \end{tikzpicture}

\end{document}

enter image description here

share|improve this answer
    
oh great. Until now I was only aware of the inner sep key! thanks for the lightening fast answer! Spot on. –  Sebastian Jan 21 '12 at 7:17
    
This "solution" is just an approximation... –  Paul Gaborit Oct 10 '12 at 20:21
2  
@PaulGaborit Current TeX math operations, no matter how complicated, are always approximate. It's an acceptable visual solution. Note that we are producing graphics not assessing the data scientifically. But I'll be more than happy to see the precise solution. –  percusse Oct 10 '12 at 20:41
add comment

Here is an exact solution (via barycentric coordinate system as in this answer to the question Can PSTricks or others draw the 4 common tangent lines of 2 “disjoint” circles without having to do extra calculations?):

enter image description here

\documentclass{standalone}
\usepackage{tikz}
\usetikzlibrary{calc}
\begin{document}
\begin{tikzpicture}[inner sep=0,outer sep=0]
  % radii
  \pgfmathsetmacro{\rbig}{20mm}
  \pgfmathsetmacro{\rsmall}{1mm}
  % the two circles
  \node[draw,circle,xshift=\rsmall+\rbig+1mm,minimum size=2*\rbig pt] (big) {};
  \node[draw,circle,minimum size=2*\rsmall pt] (small) {};
  % the good point !
  \coordinate (c) at (barycentric cs:big=-\rsmall,small=\rbig);
  \fill[red](c) circle (.2pt);
  % the two tangents
  \draw (tangent cs:node=small,point={(c)},solution=2) -- (tangent cs:node=big,point={(c)},solution=2);
  \draw (tangent cs:node=small,point={(c)},solution=1) -- (tangent cs:node=big,point={(c)},solution=1);
\end{tikzpicture}
\end{document}

Edit:

The following code computes the difference between Percusse's solution (a good approximation) and this solution (an "exact" solution):

\documentclass{standalone}
\usepackage{tikz}
\usetikzlibrary{calc}
\begin{document}
\begin{tikzpicture}[inner sep=0,outer sep=0]
  \pgfmathsetmacro{\rbig}{20mm}
  \pgfmathsetmacro{\rsmall}{1mm}
  \node[draw,circle,xshift=\rsmall+\rbig+1mm,minimum size=2*\rbig pt] (big) {};
  \node[draw,circle,minimum size=2*\rsmall pt] (small) {};
  \coordinate (c) at (barycentric cs:big=-\rsmall,small=\rbig);

  \coordinate (exact small 1) at (tangent cs:node=small,point={(c)},solution=1);
  \coordinate (approx small 1) at (tangent cs:node=small,point={(big.south)},solution=2);
  \coordinate (exact big 1) at (tangent cs:node=big,point={(c)},solution=1);
  \coordinate (approx big 1) at (tangent cs:node=big,point={(small.south)},solution=1);

  % the difference
  \path let \p1=($(exact small 1) - (approx small 1)$),
  \p2=($(exact big 1) - (approx big 1)$) in
  \pgfextra{
    \typeout{small circle difference:\x1,\y1}
    \typeout{big circle difference:\x2,\y2}
  };
\end{tikzpicture}
\end{document}

And from the log:

small circle difference:-0.6035pt,0.73969pt
big circle difference:1.43744pt,-2.58029pt
share|improve this answer
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.