# How to draw a circle with the length of a segment?

Previously I posted a question and one answer brought me another question.

Here is the code:

\documentclass[margin=10pt]{standalone}
\usepackage[utf8]{inputenc}
\usepackage{tikz,tkz-euclide,xcolor,graphicx}
\usetkzobj{all}

\begin{document}
\begin{tikzpicture}

\tkzDefPoints{0/0/A, 5/0/B, 3.7896542/3/P}

\draw[thick](A)--(B);

\tkzDrawPoints[color=red](A,B)
\tkzLabelPoint[below=2pt](A){$A$}
\tkzLabelPoint[below=2pt](B){$B$}

\tkzDrawPoint[fill=yellow](P)
\tkzLabelPoint[above=2pt](P){$P$}

\tkzDrawAltitude(A,B)(P) \tkzGetPoint{p}
\tkzDrawSegment(P,p)

\tkzLabelPoint[below=2pt](p){$p$}

\end{tikzpicture}

\end{document}


Which yields:

Now my question. I want to draw a circle which has got the same radius as the length of the segment (P,p) and the middle of the circle is the point P itself. Is it possible? If yes, how to draw that?

• I don't understand the question: If you know the distance P to p and the middle of the circle (P) -- isn't this all you need to know? What's A and B? – user31729 Dec 13 '15 at 19:00
• @ChristianHupfer I suppose A and B were irrelevant in this case, but they were in his previous question. :D – Alenanno Dec 14 '15 at 8:28
• @Alenanno: Ah, a X-Y-question – user31729 Dec 14 '15 at 10:20

This is described in chapter 15 of the documentation, "Les Cercles": the command for drawing a circle around P with a radius equal to the distance between P and p is \tkzDrawCircle(P,p):

\documentclass[margin=10pt]{standalone}
\usepackage[utf8]{inputenc}
\usepackage{tikz,tkz-euclide,xcolor,graphicx}
\usetkzobj{all}

\begin{document}
\begin{tikzpicture}

\tkzDefPoints{0/0/A, 5/0/B, 3.7896542/3/P}

\draw[thick](A)--(B);

\tkzDrawPoints[color=red](A,B)
\tkzLabelPoint[below=2pt](A){$A$}
\tkzLabelPoint[below=2pt](B){$B$}

\tkzDrawPoint[fill=yellow](P)
\tkzLabelPoint[above=2pt](P){$P$}

\tkzDrawAltitude(A,B)(P) \tkzGetPoint{p}
\tkzDrawSegment(P,p)

\tkzLabelPoint[below=2pt](p){$p$}

\tkzDrawCircle(P,p)

\end{tikzpicture}

\end{document}

• +1 Argh, I was about to answer! :D But your solution is easier than mine, so that's for the better. – Alenanno Dec 13 '15 at 19:02