# How can I draw two spheres and a cone between them with TikZ?

I would like to get an image like this:

with two spheres, intersecting a cone,the points on the intersections should also be highlighted in the way showed in figure.

I've tried to get this work with tikz-3dplot (documentation here) , but I haven't find any solution for the intersection problem.

Thanks in advance for any help you will give me.

## 1 Answer

Maybe this pgfplots diagram is sufficient.

\documentclass[tikz,border=3mm]{standalone}
\usepackage{pgfplots}
\usetikzlibrary{backgrounds,calc}
\pgfplotsset{compat=1.17}
\begin{document}
\begin{tikzpicture}[declare function={R=3;D=11;c=0.9;s=sqrt(1-c*c);
L=D/2-c*R;f(\x)=R*cos(45*\x/L)-R*cos(45);}]
\begin{axis}[xmin=-D/2-R,xmax=D/2+R,hide axis,
axis equal,view={0}{20}]
\addplot3[surf,shader=interp,domain=-L:L,domain y=0:360,z buffer=sort,
colormap={bb}{color=(blue) color=(blue!20)},opacity=0.8]
({x*(1-0.1*sin(y))},
{s*(1+0.1*f(x))*R*sin(y)+1.5*f(x)},
{s*(1+0.1*f(x))*R*cos(y)});
\path (-D/2,0,0) coordinate(L)  (D/2,0,0) coordinate(R)
(1,0,0) coordinate (X) (0,0,0) coordinate (O);
\end{axis}
\begin{scope}[on background layer]
\shade[ball color=blue!20] let \p1=($(X)-(O)$) in
(L)  circle[radius=R*\x1];
\shade[ball color=blue!20] let \p1=($(X)-(O)$) in
(R)  circle[radius=R*\x1];
\end{scope}
\end{tikzpicture}
\end{document}

• @schrodingerscat you can now the « gym » library :) – JeT May 26 at 17:05