# Draw sphere and curved surface with TikZ

I want to draw this picture, can anyone help me complete it? \documentclass[a4paper,11pt]{article}

\usepackage{tikz}

\begin{document}
\begin{tikzpicture}
\shade[ball color = brown, opacity=0.7] (0,0) circle (2cm);
\draw (0,0) circle (2cm);
\draw[thick, -latex] (-130:1cm) -- (-130:3.5cm) node [below] {$x$}; % x axis
\draw[thick, -latex] (-20:1cm) -- (-20:3.5cm) node [right] {$y$}; % y axis
\draw[thick, -latex] (90:1cm) -- (90:3.5cm) node [above] {$z$}; % z axis
\draw (60:1.5cm) -- (60:3.5cm) node [anchor=south west, xshift=-2em]
{$x^2 + y^2 + z^2 - a^2 = 0$};
\end{tikzpicture}
\end{document} • You can see here. Mar 8, 2021 at 14:54

I'g go for a 3d approach here. I think that it is almost as simple but it looks a little better. I left the labels for you.

\documentclass[border=2mm]{standalone}
\usepackage    {tikz}
\usetikzlibrary{3d}

\begin{document}
\begin{tikzpicture}[line cap=round,line join=round,x={(-0.3590cm,-0.4278cm)},y={(0.9333cm,-0.1646cm)},z={(0cm,0.8887cm)}]
% coordinates
\coordinate (A1) at ({-3+2*cos(60)}, 1.75,{ 2*sin(60)});
\coordinate (C1) at ({-3+2*cos(60)},-1.75,{-2*sin(60)});
\coordinate (A2) at ({ 3-2*cos(60)}, 1.75,{ 2*sin(60)});
\coordinate (C2) at ({ 3-2*cos(60)},-1.75,{-2*sin(60)});
% cylinder behind
\begin{scope}[canvas is xz plane at y=-1.75]
(A1) arc (60:-60:2) -- (C1) arc (-60:60:2) -- cycle;
\end{scope}
% sphere
% y,z axis
\draw [-latex] (0,1,0) -- (0,3,0) node [right] {$y$};
\draw [-latex] (0,0,1) -- (0,0,3) node [above] {$z$};
% front cylinder
\begin{scope}[canvas is xz plane at y=-1.75]
(A2) arc (120:240:2) -- (C2) arc (240:120:2) -- cycle;
\end{scope}
% little dot and x axis
\draw [fill=red] (1,0,0) circle (0.025 cm);
\draw [-latex]   (1.025,0,0) -- (3,0,0) node [left]  {$x$};
\end{tikzpicture}
\end{document}


This is the result: The figure is suitable for 3D Asymptote: an elliptic cylinder and a sphere. The elliptic cylinder x^2-z^2=1 can be parameterized by x=cosh(t) and y=sinh(t). unitsize(1cm);
import graph3;
currentprojection=orthographic(3,2,3,zoom=.9);
draw(unitsphere,yellow);
real a=3;
draw(Label("$x$",EndPoint),O--a*X,Arrow3());
draw(Label("$y$",EndPoint),O--a*Y,Arrow3());
draw(Label("$z$",EndPoint),O--a*Z,Arrow3());

// parabolic cylinder x^2 - z^2 = 1
triple f(pair M) {
real t=M.x, y=M.y;
real x=sinh(t);
real z=cosh(t);
return (x,y,z);
}
triple g(pair M) {
real t=M.x, y=M.y;
real x=-sinh(t);
real z=-cosh(t);
return (x,y,z);
}

real tmax = 1, tmin =-1;
real ymax = 2, ymin =-2;
surface elliptic_cylinder1=surface(f,(tmin,ymin),(tmax,ymax),Spline);
surface elliptic_cylinder2=surface(g,(tmin,ymin),(tmax,ymax),Spline);

draw(parabolic_cylinder1,cyan+opacity(.7));
draw(parabolic_cylinder2,cyan+opacity(.7));