0

There should be a sphere that contains the points A,B,C,D and S.

Does somebody know how to draw the picture with sphere correctly?

enter image description here

\documentclass[margin=5pt, tikz]{standalone}
\usepackage{tikz}
\usetikzlibrary{calc}
\usetikzlibrary{angles, quotes, babel}
\usepackage{amsmath, amssymb}
\begin{document}

\begin{tikzpicture}[x=1cm, y=1cm, z={(4mm,3mm)}, scale=1.5, font=\small]
\pgfmathsetmacro\a{2}
\pgfmathsetmacro\b{2.5}
\pgfmathsetmacro\c{3}

\pgfmathsetmacro{\r}{0.5*sqrt(\a^2+\b^2+\c^2)} %  

\pgfmathsetmacro{\AC}{sqrt(\a^2+\b^2)} %  
\pgfmathsetmacro{\PA}{0.5*\AC} %  

\pgfmathsetmacro{\h}{sqrt(\r^2-\PA^2)} %  

% Pyramid
\draw (0,0,0) coordinate[label=below:$A$] (A)
--(\a,0,0) node[midway, below]{$a$} coordinate[label=below:$B$] (B)
--(\a,0,\b) node[midway,right=2mm]{$b$} coordinate[label=$C$] (C);

\draw[densely dashed] (C)--(0,0,\b) coordinate[label=left:$D$] (D)--(A);
\draw (A)--(0,\c,0) node[midway, left]{$c$} coordinate[label=$S$] (S);

 % Diagonals
\draw (A)--(C); 
 \draw ($(A)!0.5!(C)$) coordinate coordinate[label=below:$P$]  (P) -- ($(S)!0.5!(C)$) node[midway, left]{$h$} coordinate[label=$M$] (M); 
\draw (D)--(B);

 % Point M
\draw (S)--(M) node[midway, above]{$r$} -- (C) node[midway, above]{$r$};

\draw[densely dashed] (D) -- (M);
\foreach \P in {A,B,C} \draw (M) -- (\P);

\node[anchor=north west, align=left, yshift=-7mm] at (A){$\begin{array}{l}
a = \a ,~  b = \b,~  c = \c \\
|AC| =  \sqrt{a^2+b^2} = \AC \\
|PA| = 0.5 |AC| = \PA \\
h = \sqrt{r^2- |PA|^2} = \h  \\
r = 0.5 \sqrt{a^2+b^2+c^2} = \r
\end{array}$
};

\shade[ball color = gray!40, opacity = 0.4] (M) circle[radius=5mm] node{?};
\end{tikzpicture}

\end{document}
2

1 Answer 1

2

In your coordinate system it would be a mess because you do not use orthographic projections and the sphere will look like an egg. If you use orthographic projections, a sphere of radius r is just as circle of the same radius in screen coordinates.

\documentclass[margin=5pt, tikz]{standalone}
\usepackage{tikz-3dplot}
\begin{document}
\tdplotsetmaincoords{60}{30}

\begin{tikzpicture}[tdplot_main_coords, font=\small]
  \pgfmathsetmacro\a{2}
  \pgfmathsetmacro\b{2.5}
  \pgfmathsetmacro\c{3}
  % Pyramid
  \draw (0,0,0) coordinate[label=below:$A$] (A)
  --(\a,0,0) node[midway, below]{$a$} coordinate[label=below:$B$] (B)
  --(\a,\b,0) node[midway,right=2mm]{$b$} coordinate[label=$C$] (C);

  \draw[densely dashed] (C)--(0,\b,0) coordinate[label=left:$D$] (D)--(A);
  \draw (A)--(0,0,\c) node[midway, left]{$c$} coordinate[label=$S$] (S);

  \path (\a/2,\b/2,\c/2) coordinate[label=$M$](M);
   % Diagonals
  \draw (A)--(C); 
   \draw ($(A)!0.5!(C)$) coordinate coordinate[label=below:$P$]  (P) --  node[midway, left]{$h$} (M); 
  \draw (D)--(B);

   % Point M
  \draw (S)--(M) node[midway, above]{$r$} -- (C) node[midway, above]{$r$};

  \draw[densely dashed] (D) -- (M);
  \foreach \P in {A,B,C} \draw (M) -- (\P);

  \shade[tdplot_screen_coords,ball color = gray!40, opacity = 0.4] 
   (M) circle[radius={sqrt(\a*\a+\b*\b+\c*\c)/2}];
\end{tikzpicture}
\end{document}
1
  • 1
    Add the line \draw (P) circle[radius={sqrt(\a*\a+\b*\b)/2}]; look better. Commented Jul 23, 2019 at 6:49

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .