From here Using Tikz, is it possible to draw a cube within a sphere? I want to draw a circumsribed sphere with centre at O(1,1,1) and radius R = sqrt(3). I tried
\documentclass[12pt]{standalone}
\usepackage{tikz}
\usepackage{tikz-3dplot}
\usetikzlibrary{arrows,calc}
\begin{document}
\tdplotsetmaincoords{60}{110}
\begin{tikzpicture}[scale=1]
\def\R{sqrt(3)}
\coordinate (O) at (1,1,1);
\fill[ball color=cyan!10, opacity=1.0] (O) circle (\R); % 3D lighting effect
\begin{scope}[tdplot_main_coords, shift={(1,1,1)}, rotate=0]
\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$};
}
\end{scope}
\end{tikzpicture}
\end{document}
My result is not correct. How can I repair it?


