[Tex/LaTex] Tangent to circle given point on circle

tikz-pgf

I've been able to draw tangent lines to a circle at a given point on the circle, and I've done so in two ways (using the calc library, and using the /tikz/turn feature). But I must admit I don't fully understand /tikz/turn and don't know if there is an advantage of using calc or turn (or some other approach).

My current MWE is below. My questions are:

1) I (think) that I get how the blue line is drawn using "turn" (draw a line from center of circle to point on circle, then rotate clockwise by 90 degrees relative to incoming direction and then continue for 2 cm). But the red line is confusing to me. If I simply start at a point on the circle (P in this case), how does TikZ know what direction to "turn" relative to? Somehow it understands that +/- 90 is tangent to the circle… Is there implicitly a line from (0,0) to the point P (to define the angle=0 direction)?

2) Both the red curve and the black curve (made with calc library) give me what I need. Is there any advantage of one over the other?

enter image description here

Made with:

\documentclass[tikz]{standalone}
\usepackage{tikz}
\usetikzlibrary{calc}
\begin{document}
\begin{tikzpicture}
 [
   scale=1,
   point/.style = {draw, circle, fill=black, inner sep=0.5pt},
 ]

\def\rad{2cm}
\node (C) at (0,0) [point]{};
\draw (C) circle (\rad);
\node (P)  at +(160:\rad)  [point]{};

% Using the calc library
\draw (P) -- ($(P)!2!-90:(C)$);
\draw (P) -- ($(P)!2!90:(C)$);

% using /tikz/turn
\draw[->,thick, color=blue] (C) -- (P) -- ([turn]-90:2cm);
% this is the command that I don't understand
\draw[->,thick, color=red] (P) -- ([turn]90:1cm);

\end{tikzpicture}
\end{document}

Best Answer

The voodoo effect comes from the fact that when a coordinate is omitted origin is assumed and this happens to be the center of the circle. If you change the starting point the mystery goes away rather quickly.

I've placed more arrows to show the effect when the paths start from different coordinates.

\documentclass[tikz]{standalone}
\usetikzlibrary{calc}
\def\rad{2cm}

\begin{document}
\begin{tikzpicture}
 [point/.style = {draw, circle, fill=black, inner sep=0.5pt}]
\draw[style=help lines] (0,-1) grid[step=1cm] (5,4);

\node (C) at (2,1) [point,label=0:C]{};
\draw (C) circle (\rad);
\path (2,1) node[point,label={180:P}] (P)  at +(120:\rad){};

\foreach \x in {0,10,...,90}{
\draw[-latex,draw=blue,thick] (2,1) -- (P) -- ([turn]\x:2cm);
\draw[-latex,draw=red] (P) -- ([turn]\x:2cm);% You can add (0,0) -- as an initial point too
}
\end{tikzpicture}
\end{document}

enter image description here

As you can see, when initiated from a different point the red arrows loose the magic tangentiality but rather follow the incoming angle to that point (though blue arrows still preserve since the initial point is given). When the initial point is omitted it assumes that the path starts from (0,0) hence there is an inherent illusion of guessing the tangent.