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:
- 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.
- 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.
Here is a little tool box that allows you to protect
some (closed) path. It is based on the links mentioned in the code (and possibly more). The important pieces are
\begin{scope}
\tikzset{protect=\rectA}
\draw[thick,use path=\rectB];
\draw[thick] (I) -- (M);
\tikzset{protect=\rectB}
\draw[thick,use path=\lineA];
\end{scope}
where the paths \rectA
, \rectB
and \lineA
have been used before and saved with save path
. \tikzset{protect=\rectA}
"protects" the interior of the \rectA
path, and likewise for \rectB
.
\documentclass[border=2mm,tikz]{standalone}
\usepackage{tikz-3dplot}
\usetikzlibrary{3dtools}
% based on
% https://tex.stackexchange.com/a/38995/121799
% https://tex.stackexchange.com/a/76216
% https://tex.stackexchange.com/a/59168/194703
% https://tex.stackexchange.com/q/448920/194703
\makeatletter
\tikzset{
reuse path/.code={\pgfsyssoftpath@setcurrentpath{#1}}
}
\tikzset{even odd clip/.code={\pgfseteorule},
protect/.code={
\clip[overlay,even odd clip,reuse path=#1]
(-16383.99999pt,-16383.99999pt) rectangle (16383.99999pt,16383.99999pt);
}}
\makeatother
\tikzset{intersection of line trough/.code args={#1 and #2 with plane containing #3 and normal #4}{%
\pgfmathsetmacro{\ltest}{abs(TD("#2o#4")-TD("#1o#4"))}%
\ifdim\ltest pt<0.01pt
\message{Plane and line are parallel!^^J}
\pgfmathsetmacro{\myd}{0}
\else
\pgfmathsetmacro{\myd}{(TD("#3o#4")-TD("#1o#4"))/(TD("#2o#4")-TD("#1o#4"))}%
\fi
\pgfmathsetmacro{\myP}{TD("#1+\myd*#2-\myd*#1")}%
\pgfkeysalso{insert path={%
(\myP)
}}
}}
\begin{document}
\tdplotsetmaincoords{60}{65}
\begin{tikzpicture}[scale=1,tdplot_main_coords,line join = round, line cap = round, declare function={a = 3;b = 4;}]
\path
(0,0,b+2) coordinate (M)
(0,0,-b) coordinate (N);
\begin{scope} [canvas is xy plane at z=0]
\draw[dashed,save path=\rectB] (-a,-a) rectangle (a,a);
\end{scope}
\begin{scope} [canvas is xy plane at z=a]
\draw[thick,save path=\rectA] (-a,-a) rectangle (a,a);
\end{scope}
\draw[dashed,save path=\lineA] (M) -- (N) ;
\path[overlay][intersection of line trough={(M) and (N) with plane containing (0,0,0) and normal (0,0,1)}] coordinate (I);
\path[overlay][intersection of line trough={(M) and (N) with plane containing (0,0,a) and normal (0,0,1)}] coordinate (J);
\begin{scope}
\tikzset{protect=\rectA}
\draw[thick,use path=\rectB];
\draw[thick] (I) -- (M);
\tikzset{protect=\rectB}
\draw[thick,use path=\lineA];
\end{scope}
\foreach \p in {M,N,I,J}
\draw[fill=black] (\p) circle (1pt);
\foreach \p/\g in {M/90,N/-90,I/0,J/0}
\path (\p)+(\g:3mm) node{$\p$};
\draw[thick] (M) -- (J);
\end{tikzpicture}
\end{document}
It turns out that for some (to me obscure) reasons it can happen in some cases that the insanely large bounding box is too large. However, for most practical applications something more "modest" like
\tikzset{even odd clip/.code={\pgfseteorule},
protect/.code={
\clip[overlay,even odd clip,reuse path=#1]
(-6383.99999pt,-6383.99999pt) rectangle (6383.99999pt,6383.99999pt);
}}
will be more than sufficient.
Best Answer
As John Kormylo'comment, I think, you can not rotate the sphere with a mouse (if you use TikZ). We hope that, in future, Asymptote can do this (keep automatic dashed lines when we rotate sphere!). You can try this code. I hope, it helps you something.
The output get a big file, I can not upload it at here. I put it here or here