# Tikz: specifying radius of circle using two points without Euclid package

I define two points using \coordinate, a and b. Then I try to plot a circle with centre at a and radius given by a-b. I made 3 attempts, see code below

1. a little bit naif, does not work
2. using https://tex.stackexchange.com/a/58287, does not work
3. using https://tex.stackexchange.com/a/38500 this generates a circle with a huge radius.

Is there a way to make work any of the three? The simplest the better.

\documentclass{article}
\usepackage{tkz-euclide}
\usetkzobj{all}
\usetikzlibrary{calc,patterns,angles,quotes,intersections}

\makeatletter
\def\calcLength(#1,#2)#3{%
\pgfpointdiff{\pgfpointanchor{#1}{center}}%
{\pgfpointanchor{#2}{center}}%
\pgf@xa=\pgf@x%
\pgf@ya=\pgf@y%
\FPeval\@temp@a{\pgfmath@tonumber{\pgf@xa}}%
\FPeval\@temp@b{\pgfmath@tonumber{\pgf@ya}}%
\FPeval\@temp@sum{(\@temp@a*\@temp@a+\@temp@b*\@temp@b)}%
\FProot{\FPMathLen}{\@temp@sum}{2}%
\FPround\FPMathLen\FPMathLen5\relax
\global\expandafter\edef\csname #3\endcsname{\FPMathLen}
}
\makeatother

\begin{document}

Attempt 1:

\begin{center}
\begin{tikzpicture}[]
\coordinate (a) at (0,0);
\coordinate (b) at (1.3,1.5);
\draw (a) circle (2);
\draw (a) circle ($(b)-(a)$);
\end{tikzpicture}
\end{center}

Attempt 2:

\begin{center}
\begin{tikzpicture}[]
\coordinate (a) at (0,0);
\coordinate (b) at (1.3,1.5);
\draw (a) circle (2);
% https://tex.stackexchange.com/a/58287
\draw
let
\p1 = (a),
\p2 = (b),
\n1 = {veclen((\x2-\x1),(\y2-\y1))}
(a) circle ({\n1});
\end{tikzpicture}
\end{center}

Attempt 3:

\begin{center}
\begin{tikzpicture}[]
\coordinate (a) at (0,0);
\coordinate (b) at (1.3,1.5);
\draw (a) circle (2);
% https://tex.stackexchange.com/a/38500
\calcLength(a,b){mylen}
\draw (a) circle (\mylen);
\end{tikzpicture}
\end{center}

\end{document}

• Look at the TikZ manual 3.1.4 on page 62 and 63, where it is explained how to do this Aug 16, 2019 at 8:58

A slight modification of the first attempt works. The second one works as well if you add the missing in (and one may want to switch to the modern syntax circle[radius=<radius>]).

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

\begin{document}

Attempt 1 slightly modified:

\begin{center}
\begin{tikzpicture}
\coordinate (a) at (0,0);
\coordinate (b) at (1.3,1.5);
\draw let \p1=($(b)-(a)$),\n1={veclen(\x1,\y1)} in (a) circle[radius=\n1] ;
\end{tikzpicture}
\end{center}

\begin{center}
\begin{tikzpicture}[]
\coordinate (a) at (0,0);
\coordinate (b) at (1.3,1.5);
% https://tex.stackexchange.com/a/58287
\draw
let
\p1 = (a),
\p2 = (b),
\n1 = {veclen((\x2-\x1),(\y2-\y1))} in
\end{tikzpicture}
\end{center}

\end{document}


With tikzlibrary through, it can be done easily:

\node [draw] at (a) [circle through={(b)}] {};


\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{through}
\begin{document}
\begin{tikzpicture}
\draw[help lines] (-2,-2) grid (2,2);
\node[circle,fill=red,inner sep=1pt] (a) at (0,0){a};
\node[circle,fill=red,inner sep=1pt] (b) at (1.3,1.5){b};

\node [draw,thick] at (a) [circle through={(b)}] {};
\end{tikzpicture}
\end{document}

• thank you, nice clean way to solve the problem Aug 17, 2019 at 7:03
• +1 very nice solution Aug 19, 2020 at 13:46