[Tex/LaTex] TikZ: Thales circle, radius unknown

tikz-pgf

Is there any way to make a circle knowing just two points on its diameter?

Here's the complete problem I'm trying to solve: there is a segment MN (but points M and N are calculated as an intersection of other lines so I don't know their coordinates) and I want to construct the Thales circle (to find some right angles).

I've found some code for drawing part of the circumference, so I've modified it to

\coordinate (S_MN) at ($(M)!.5!(N)$);
\draw[red] (S_MN) let \p1 = ($(N)-(S_MN)$) in  ++({veclen(\x1,\y1)},0) arc (0:360:({veclen(\x1,\y1)}););

(I'm using the calc library), but the compilation runs into errors.

!package Tikz error: + or - expected. See the tikz documentation...

(Yeah, I admit that I dont know much about the TikZ construction I've used, unfortunately.)

I've also tried to compute the radius by $(M) - (N)$ (which I've seen somewhere), but without success.

—- edit —

(…)

BUT I think I've found the problem – I've tried to remove packages form head of the doc and check if there is a problem

-> once \usepackage[czech]{babel} package is %commented, everything runs normally

\documentclass[12pt,a4paper]{report}

\usepackage[czech]{babel}

\usepackage[cp1250]{inputenc}
\usepackage{graphicx}
\usepackage{amsthm}
\usepackage{amsmath}
\usepackage{epstopdf}

\usepackage{tikz}
\usetikzlibrary{calc}
\pgfmathsetseed{\pdfuniformdeviate 10000000}

\begin{document}
\begin{tikzpicture}
\draw[style=help lines] (0,0) grid[step=1cm] (3,3);
\coordinate (M) at (2,1);
\foreach \x in {1,...,5}{
\node (N) at ({random(0,3)},{random(0,3)}) {here};
\coordinate (S_MN) at ($(M)!.5!(N)$);
\draw[red] (S_MN)
 let \p1 = ($(N)-(M)$),\n1 = {0.5*veclen(\x1,\y1)} in  ++(\n1,0) arc (0:360:\n1);
}
\end{tikzpicture}  
\end{document}

edit2:
I've used percusse's construction with cjorssen's "update" and it worked really fine. But now I've realized one problem – how coud I find that intersection with other line I've been talking about in first post? (summary: I've circle made by your way. There is also line, say, AB, which intersects the circle in two points. How could I detect them to draw that right angle for which I'm using Thales circle? Thanks in advance

Best Answer

With tkz-euclide

\documentclass{scrartcl}
\usepackage{tkz-euclide} 
\usetkzobj{all} 
\begin{document}

\begin{tikzpicture} 
  \tkzDefPoint(2,1){A}
  \tkzDefPoint(7,3){B} 
  \tkzDrawCircle[diameter,fill=yellow!50](A,B) 
  \tkzDefMidPoint(A,B) \tkzGetPoint{O} 
  \tkzCalcLength[cm](O,B) \tkzGetLength{rAB}
  \tkzGetRandPointOn[circle = center O radius \rAB cm]{C}
  \tkzDrawPolygon[fill=red!40](A,B,C) 
  \tkzLabelPoints(A,B,C,O)
  \tkzMarkRightAngle(A,C,B)
\end{tikzpicture}

\end{document}  

enter image description here

Related Question