# How to draw a circle (sphere) passing through four points?

I am trying to draw a circle (sphere) passing through four points B, C, E, F like this picture

I tried with tikz-3dplot and my code

\documentclass[border=3mm,12pt]{standalone}
\usepackage{fouriernc}
\usepackage{tikz,tikz-3dplot}
\usepackage{tkz-euclide}
\usetkzobj{all}

\usetikzlibrary{intersections,calc,backgrounds}

\begin{document}

\tdplotsetmaincoords{70}{110}
%\tdplotsetmaincoords{80}{100}
\begin{tikzpicture}[tdplot_main_coords,scale=1.5]
\pgfmathsetmacro\a{3}
\pgfmathsetmacro\b{4}
\pgfmathsetmacro\h{5}

% definitions
\path
coordinate(A) at (0,0,0)
coordinate (B) at (\a,0,0)
coordinate (C) at (0,\b,0)
coordinate (S) at (0,0,\h)
coordinate (E) at  ({\a*\h^2/(\a*\a + \h*\h)},0,{(\a*\a*\h)/(\a*\a + \h*\h)})
coordinate (F) at  (0,{(\b*\h*\h)/(\b*\b + \h*\h)},{(\b*\b*\h)/(\b*\b + \h*\h)});
\draw[dashed,thick]
(A) -- (B)  (A) -- (C)  (A) -- (E)  (S)--(A)  (F)--(A);
\draw[thick]
(S) -- (B) -- (C) -- cycle;
\draw[thick]
(F) -- (B) (C)--(E) (F)--(E);
\tkzMarkRightAngle(S,E,A);
\tkzMarkRightAngle(S,F,A);

\foreach \point/\position in {A/below,B/left,C/below,S/above,E/left,F/above}
{
\fill (\point) circle (.8pt);
\node[\position=3pt] at (\point) {$\point$};
}

\end{tikzpicture}
\end{document}


and got

How can I draw a circle (sphere) passing through four points B, C, E, F?

• A circle is already uniquely fixed by 3 (noncollinear) points. There exist answers that show you how to find such a circle. E.g. tex.stackexchange.com/questions/461161/… (Sorry for advertising;-) – user121799 Jan 15 at 3:38
• @marmot Is it true in 3D? – minhthien_2016 Jan 15 at 3:52
• I believe that an orthographic projection of a sphere is a circle. The subtle point is whether the projected circle runs through the points you indicate, something that I cannot decide without more information on how the sphere is determined. – user121799 Jan 15 at 3:56
• The sphere has centre is midpoint of the segment EC. – minhthien_2016 Jan 15 at 3:59
• That circle doesn't look very circular. – RemcoGerlich Jan 15 at 9:07

A circle is determined by 3 points. A sphere, of course, needs at least 4 points on its boundary to be determined. However, the projection of the sphere, i.e. the circle, won't necessarily run through the projections of these points. (Actually, if the sphere is uniquely determined by these points, the boundary circle, i.e. the projection of the sphere on the screen coordinates, will never run through all projections of the points because for this to happen, the points need to lie in a plane, but then they no longer uniquely determine the circle.)

This shows two ways to construct circles that run through some of the points:

1. The dotted circle runs through F, E and C. It is fixed by this requirement. As a consequence it misses B by a small amount.
2. The red dashed circle runs through the midpoint of BC and through these points. It misses F and E by small amounts.

\documentclass[border=3mm,12pt]{standalone}
\usepackage{fouriernc}
\usepackage{tikz,tikz-3dplot}
\usepackage{tkz-euclide}
\usetkzobj{all}
\usetikzlibrary{calc,through}
\tikzset{circle through 3 points/.style n args={3}{%
insert path={let    \p1=($(#1)!0.5!(#2)$),
\p2=($(#1)!0.5!(#3)$),
\p3=($(#1)!0.5!(#2)!1!-90:(#2)$),
\p4=($(#1)!0.5!(#3)!1!90:(#3)$),
\p5=(intersection of \p1--\p3 and \p2--\p4)
in },
at={(\p5)},
circle through= {(#1)}
}}

\usetikzlibrary{intersections,calc,backgrounds}

\begin{document}

\tdplotsetmaincoords{70}{110}
%\tdplotsetmaincoords{80}{100}
\begin{tikzpicture}[tdplot_main_coords,scale=1.5]
\pgfmathsetmacro\a{3}
\pgfmathsetmacro\b{4}
\pgfmathsetmacro\h{5}

% definitions
\path
coordinate(A) at (0,0,0)
coordinate (B) at (\a,0,0)
coordinate (C) at (0,\b,0)
coordinate (S) at (0,0,\h)
coordinate (E) at  ({\a*\h^2/(\a*\a + \h*\h)},0,{(\a*\a*\h)/(\a*\a + \h*\h)})
coordinate (F) at  (0,{(\b*\h*\h)/(\b*\b + \h*\h)},{(\b*\b*\h)/(\b*\b + \h*\h)});
\draw[dashed,thick]
(A) -- (B)  (A) -- (C)  (A) -- (E)  (S)--(A)  (F)--(A);
\draw[thick]
(S) -- (B) -- (C) -- cycle;
\draw[thick]
(F) -- (B) (C)--(E) (F)--(E);
\tkzMarkRightAngle(S,E,A);
\tkzMarkRightAngle(S,F,A);

\foreach \point/\position in {A/below,B/left,C/below,S/above,E/left,F/above}
{
\fill (\point) circle (.8pt);
\node[\position=3pt] at (\point) {$\point$};
}
\node[circle through 3 points={F}{E}{C},draw=blue,dotted]{};
\draw[red,dashed]
let \p1=($(B)-(C)$), \n1={veclen(\x1,\y1)/2} in ($(B)!0.5!(C)$) circle (\n1);
\end{tikzpicture}
\end{document}


It will be possible to construct the sphere as well. However, as mentioned its boundary may not run through any of the points.

ADDENDUM: In your setup, the four points do not determine a unique sphere because they all lie in a plane. Using Mathematica I was able to express F as a linear combination

 F = x B + y C + z E


where

So in this setup it is not possible to draw a unique sphere.

• I edited your mathematical equations so that it is easier to read them. If it is wrong or you don't like it, feel free to re-edit it :)) – user156344 Jan 15 at 8:42