6

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?

4 Answers 4

6

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

4

With simple computations it's easy to know that your pyramid has a base consisting of an equilateral triangle with side length 3*\sqrt{2}, the pyramid height is 2*\sqrt{3} and the cone radius is \sqrt{6}.

Now that we have the dimensions, my approach (not so very difficult, I hope) is to draw 'as usual' the bases of the pyramid and the cone in the horizontal plane. With a couple of math computations we can have something like this (the visibility is wrong, I know): enter image description here

So now we rotate the figure until we have the approximate view you need.

The complete code could be the following:

\documentclass[tikz,border=2mm]{standalone}

% isometric axes
\pgfmathsetmacro\xx{1/sqrt(2)}
\pgfmathsetmacro\xy{1/sqrt(6)}
\pgfmathsetmacro\zz{sqrt(2/3)}
\tikzset{isometric/.style={
  rotate=110, % <-- commenting this we have the 'usual' view
  x={(-\xx cm,-\xy cm)},y={(\xx cm,-\xy cm)},z={(0cm,\zz cm)}}
}

% dimensions and some maths
\def\r{135}                                                % rotation angle (around z)
\pgfmathsetmacro\ch{2*sqrt(3)}                             % cone height
\pgfmathsetmacro\cr{sqrt(6)}                               % cone radius
\pgfmathsetmacro\gs{sqrt((2*\ch*\ch-\cr*\cr)/(3*\cr*\cr))} % generatrix slope
\pgfmathsetmacro\xt{sqrt(6)*\gs*\ch/(1+3*\gs*\gs)}         % tangent point x
\pgfmathsetmacro\yt{\gs*\xt}                               % tangent point y
\pgfmathsetmacro\aa{(\ch*\zz-\yt)/\xy/2-\xt/\xx/2}         % coordinate x in xy plane
\pgfmathsetmacro\bb{(\ch*\zz-\yt)/\xy/2+\xt/\xx/2}         % coordinate y in xy plane
\pgfmathsetmacro\at{atan(\bb/\aa)+180}                     % angle to the tangent point

\begin{document}
\begin{tikzpicture}[isometric]
  % coordinates
  \coordinate (V) at (0,0,{2*sqrt(3)});
  \foreach\i in {1,2,3}
    \coordinate (A\i) at (120*\i-120+\r:\cr);
  \coordinate (T1) at (180+\at:\cr); % tangent point
  \coordinate (T2) at (270-\at:\cr); % tangent point
  % pyramid 
  \draw (A1) -- (A2) -- (A3) -- cycle;
  \draw[dashed] (A1) -- (V) -- (A3);
  \draw (V) -- (A2);
  % cone
  \draw[thick,red] (0,0) circle (\cr);
  \draw[thick,red] (T1) -- (V) -- (T2);
  % labels
  \node at (A1) [above] {$A$};
  \node at (A2) [below] {$B$};
  \node at (A3) [right] {$C$};
  \node at (V)  [left]  {$D$};
  \fill (0,0,0) circle (1pt) node [right] {$I$};
\end{tikzpicture}
\end{document}

And the final rotated figure: enter image description here

4

A bit try with Asymptote.

Compile at http://asymptote.ualberta.ca/

import solids;
size(10cm,0);
currentprojection=orthographic(1,-0.4,0.2);

triple A=(0,0,3),B=(3,0,0),C=(0,3,0),D=(0,0,0);

revolution CoRev=cone((A+B+C)/3,abs((A+B+C)/3-A),abs((A+B+C)/3-D),axis=D-(A+B+C)/3,n=1);

//draw(surface(CoRev),lightred+opacity(.2));
draw(CoRev,blue+1bp);

draw(A--B--C--cycle^^B--D);
draw(A--D^^C--D,dashed);
dot("$A$",A,dir(90),linewidth(5bp));
dot("$B$",B,dir(-45),linewidth(5bp));
dot("$C$",C,dir(0),linewidth(5bp));
dot("$D$",D,dir(180),linewidth(5bp));
dot("$I$",(A+B+C)/3,dir(-30),linewidth(5bp));

enter image description here

1

I see that is really a cone ^^, and like the way of determining circumcenter via barycentric coordinates.

enter image description here

triple barycentric(triple A, triple B, triple C, real a, real b, real c){
return (a*A+b*B+c*C)/(a+b+c);
}
triple circumcenter(triple A, triple B, triple C){
real a=abs(B-C), b=abs(C-A), c=abs(A-B);
return barycentric(A,B,C,a^2*(b^2+c^2-a^2), b^2*(c^2+a^2-b^2),c^2*(a^2+b^2-c^2));
}
real circumradius(triple A, triple B, triple C){
return abs(A-circumcenter(A,B,C));
}

unitsize(1cm);
import three;
import solids;
//currentprojection=orthographic(dir(70,25),center=true,zoom=.95);
triple D=(0,0,0), B=(3,0,0), C=(0,3,0), A=(0,0,3);
triple O=circumcenter(A,B,C); dot(O,red);
real R=circumradius(A,B,C);
triple nABC=normal(A--C--B);
draw(A--B--C--D--cycle^^A--C^^B--D);
draw(circle(O,R,nABC),red);
real h=abs(D-O);
revolution coneDABC=cone(O,R,h,nABC);
draw(surface(coneDABC),yellow+opacity(.5));

(This arises the general problem for the situation any tetradhedron, such as D=(0,-3,0). Then revolution can not be used.)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.