Draw this cone

tikz-3dplot

Let be a pyramid DABC, where D(0,0,0), A(0,0,3), B(3,0,0) and C(0, 3,0). I am trying to draw this codeenter image description here

I cannot draw the cone. I tried

 \documentclass[tikz,border=3mm]{standalone}
\usepackage{tikz-3dplot}
\begin{document}
    \tdplotsetmaincoords{60}{100}
\begin{tikzpicture} [tdplot_main_coords,c/.style={circle,fill,inner sep=1pt}]
\path
(0,0,0) coordinate (D)
(3,0,0)  coordinate (B)
(0, 3,0) coordinate (C)
(0,0,3) coordinate (A)
;
\draw (C) -- (A) -- (B) -- cycle;
\draw[dashed] (D) -- (C) (D) --(A) (D) -- (B);
\path foreach \p/\g in {A/180,B/0,C/90,D/-90}{(\p)node[c]{}+(\g:2.5mm) node{$\p$}};
\end{tikzpicture}
\end{document}  

enter image description here

How to draw the cone?

Best Answer

You can you 3dtools. Some calculations can be found by 3dtools.

\documentclass[tikz,border=3mm]{standalone}
\usetikzlibrary{3dtools,calc}% https://github.com/marmotghost/tikz-3dtools
\begin{document}
\begin{tikzpicture}[3d/install view={phi=70,theta=80},line cap=butt,
line join=round,c/.style={circle,fill,inner sep=1pt},declare function={a=4;}] 
\path
(0,0,0) coordinate (D)
(a,0,0)  coordinate (B)
(0, a,0) coordinate (C)
(0,0,a) coordinate (A);
\path[3d/circumcircle center={A={(A)},B={(B)},C={(C)}}] coordinate (J);
;
\draw[3d/hidden] (D) --(A)  (D) -- (J)  (D) --(C);
\draw[3d/visible] (A) --(B)--(C) --cycle (D) -- (B);
\pgfmathsetmacro{\R}{tddistance("(J)","(B)")}
\pgfmathsetmacro{\h}{tddistance("(J)","(D)")}
\tikzset{3d/define orthonormal dreibein={A={(A)},B={(C)},C={(B)}}}
\path[x={(ex)},y={(ey)},z={(ez)}]
(J) pic{3d/cone={r=\R,h=\h}};
\path foreach \p/\g in {A/90,D/-90,B/-30,C/0,J/-90}{(\p)node[c]{}+(\g:2.5mm) node{$\p$}};
\end{tikzpicture}
\end{document}  

enter image description here

With phi=5,

\documentclass[tikz,border=3mm]{standalone}
\usetikzlibrary{3dtools,calc}% https://github.com/marmotghost/tikz-3dtools
\begin{document}
\begin{tikzpicture}[3d/install view={phi=5,theta=80},line cap=butt,
line join=round,c/.style={circle,fill,inner sep=1pt},declare function={a=4;}] 
\path
(0,0,0) coordinate (D)
(a,0,0)  coordinate (B)
(0, a,0) coordinate (C)
(0,0,a) coordinate (A);
\path[3d/circumcircle center={A={(A)},B={(B)},C={(C)}}] coordinate (J);
;
\draw[3d/hidden]   (D) -- (J)  (D)  --(C) (A) -- (B) -- (C) --cycle ;
\draw[3d/visible] (D) --(A) (D) -- (B);
\pgfmathsetmacro{\R}{tddistance("(J)","(B)")}
\pgfmathsetmacro{\h}{tddistance("(J)","(D)")}
\tikzset{3d/define orthonormal dreibein={A={(A)},B={(C)},C={(B)}}}
\path[x={(ex)},y={(ey)},z={(ez)}]
(J) pic{3d/cone={r=\R,h=\h}};
\path foreach \p/\g in {A/90,D/-90,B/-30,C/50,J/-90}{(\p)node[c]{}+(\g:2.5mm) node{$\p$}};
\end{tikzpicture}
\end{document}  

enter image description here

Related Question