How to draw circle passing through three points A,P, Q
in this code.
\documentclass[border=3mm,12pt,tikz]{standalone}
\usepackage{fouriernc}
\usepackage{tikz,tikz-3dplot}
\tikzset{projection of point/.style args={(#1,#2,#3) on line through (#4,#5,#6)
and (#7,#8,#9)}{%
/utils/exec=\pgfmathsetmacro{\myprefactor}{((#1-#4)*(#7-#4)+(#2-#5)*(#8-#5)+(#3-#6)*(#9-#6))/((#7-#4)*(#7-#4)+(#8-#5)*(#8-#5)+(#9-#6)*(#9-#6))},
insert path={%
({#4+\myprefactor*(#7-#4)},{#5+\myprefactor*(#8-#5)},{#6+\myprefactor*(#9-#6)})}
}}
\begin{document}
\tdplotsetmaincoords{70}{110}
\begin{tikzpicture}[tdplot_main_coords]
\pgfmathsetmacro\a{4}
\pgfmathsetmacro\b{8}
\pgfmathsetmacro\h{7}
\pgfmathsetmacro\r{sqrt(\a*\a + \b*\b)/2}
% definitions
\path
coordinate(A) at (0,0,0)
coordinate (B) at (\a,0,0)
coordinate (C) at (\a,\b,0)
coordinate (D) at (0,\b,0)
coordinate (S) at (0,0,\h)
coordinate (I) at (\a/2,\b/2,0) ;
\path[projection of point={(0,0,0) on line through (\a,0,0) and (0,0,\h)}]
coordinate (P)
[projection of point={(0,0,0) on line through (0,\b,0) and (0,0,\h)}]
coordinate (Q);
\draw[dashed] (S) -- (A) (P) -- (B) (Q) --(D) (A) -- (C) (B) -- (D)
(A) -- (B) -- (C) -- (D)--cycle (P) -- (Q);
\draw (S) -- (P) (S) -- (Q) (S) -- (C);
\draw (I) circle (\r cm);
\draw[red, thick, dashed] (A)-- (P) (A)-- (Q) ;
\foreach \point/\position in {A/left,B/left,C/below,S/above,D/right,I/left,P/left,Q/right}
{\fill (\point) circle (1.5pt);
\node[\position=3pt] at (\point) {$\point$};
}
\end{tikzpicture}
\end{document}