Tikz-3dplot – How to Draw Insphere of a Pyramid in TikZ

tikz-3dplot

I am trying to draw insphere of tetrahedron DABC. My code

\documentclass[tikz,border=3mm]{standalone}
\usepackage{tikz-3dplot}
\begin{document}
    \tdplotsetmaincoords{60}{100}
    \begin{tikzpicture} [tdplot_main_coords]
        \path
        (0,0,0) coordinate (D)
        (3,0,0)  coordinate (B)
        (0,6,0) coordinate (C)
        (0,0,9) coordinate (A)
     (1,1,1) coordinate (I) 
        ;
\fill (D) circle (1.5pt) node [right] {$D$};
\fill (A) circle (1.5pt) node [above] {$A$};    
\fill (B) circle (1.5pt) node [left] {$A$};
\fill (C) circle (1.5pt) node [right] {$C$};
\fill (I) circle (1.5pt) node [right] {$I$};
\draw[dashed,red] (I) circle[radius = 1];
\draw (C) -- (A) -- (B) -- cycle;
\draw[dashed] (D) -- (C) (D) --(A) (D) -- (B);
\end{tikzpicture}
\end{document}  

I got

enter image description here

I can not get the correct result of the sphere. My questions:

  1. How can I get correct result;
  2. Is there a way to draw insphere without using the center I and radius R = 1 like my code?

Best Answer

I copy a part of this code from here.

    \documentclass[tikz,border=3mm]{standalone}
\usetikzlibrary{3dtools,calc}% https://github.com/marmotghost/tikz-3dtools
\begin{document}
    \begin{tikzpicture}[3d/install view={phi=110,theta=70},line cap=butt,
        line join=round,c/.style={circle,fill,inner sep=1pt},declare function={a=3;b=6;c=9;}] 
        \path
        (0,0,0) coordinate (D)
        (a,0,0)  coordinate (A)
        (0,b,0) coordinate (B)
        (0,0,c) coordinate (C);
\tikzset{3d/plane through=(A) and (B) and (C) named pABC}
\path [3d/insphere center] coordinate (I)
[3d/project={(I) on pABC}] coordinate (I');
\pgfmathsetmacro{\myr}{tddistance("(I)","(I')")}
\shade[3d/screen coords,ball color=green, opacity=0.8] 
(I) circle [radius=\myr];
\draw[3d/hidden] (D) -- (A) (D) --(B) (D) --(C);    
\draw[3d/visible] (A) --(B) --(C) -- cycle;     
\path foreach \p/\g in {A/-90,D/-90,B/-30,C/90,I/0}{(\p)node[c]{}+(\g:2.5mm) node{$\p$}};
    \end{tikzpicture}
\end{document}  

enter image description here