How can I draw a sphere circumsribed a pyramid?

One can also use tdplot_screen-coords and on background layer. This could prove more useful it you intend to use more than one sphere.

\documentclass[12pt]{standalone}
\usepackage{tikz}
\usepackage{tikz-3dplot}
\usetikzlibrary{arrows,calc,backgrounds}
\begin{document}
\tdplotsetmaincoords{60}{110}
\begin{tikzpicture}[tdplot_main_coords]
\path
      coordinate (A) at (0,0,0)
      coordinate (B) at (2,0,0)
      coordinate (C) at (2,2,0)
      coordinate (D) at (0,2,0)
      coordinate (S) at (0,0,2)
      coordinate (O) at (1,1,1);

\draw[ dashed] (A)--(S) (A)--(B) (A)--(D);
\draw [fill opacity=0.4,fill=green!80!blue] (S) -- (B) -- (C) -- cycle;
\draw [fill opacity=0.4,fill=orange!80!blue] (S) -- (C) -- (D) -- cycle;

\foreach \v/\position in {A/below,B/below,C/below,D/right,S/above,O/below} {
    \draw[fill=black] (\v) circle (0.7pt) node [\position=0.2mm] {$\v$};
}

\draw[dashed] (1,1,0) circle[radius={sqrt(2)}];% circle ABCD

\begin{scope}[tdplot_screen_coords, on background layer]
  \pgfmathsetmacro{\R}{sqrt(3)}%
  \fill[ball color=cyan!10, opacity=1.0] (O) circle (\R); % 3D lighting effect
\end{scope}
\end{tikzpicture}
\end{document} 

demo


I did so.

\documentclass[border=2mm12pt]{standalone}
\usepackage{tikz}
\usepackage{tikz-3dplot}
\usetikzlibrary{arrows,calc}
\begin{document}
\tdplotsetmaincoords{60}{110}
\begin{tikzpicture}[scale=2]
\def\R{sqrt(3)}
\coordinate (O) at (0,0,0);
\fill[ball color=cyan!10, opacity=1.0]  (O) circle (\R); % 3D lighting effect
 \begin{scope}[tdplot_main_coords, shift={(0,0)}, rotate=0]
\path
      coordinate (A) at (-1,-1,-1)
      coordinate (B) at (1,-1,-1)
      coordinate (C) at (1,1,-1)
      coordinate (D) at (-1,1,-1)
      coordinate (S) at (-1,-1,1);
      \draw[ dashed]
     (A)--(S) (A)--(B)
      (A)--(D)
       ;
\draw [fill opacity=0.4,fill=green!80!blue] (S) -- (B) -- (C) -- cycle;
\draw [fill opacity=0.4,fill=orange!80!blue] (S) -- (C) -- (D) -- cycle;
\foreach \v/\position in {A/below,B/below,C/below,D/right,S/above,O/right} {
    \draw[fill=black] (\v) circle (0.7pt) node [\position=0.2mm] {$\v$};
}
\end{scope}
\end{tikzpicture}
\end{document} 

enter image description here

Tags:

3D