[Tex/LaTex] Draw sphere with some portion is dotted

tikz-pgf

I need to draw the following figure :
enter image description here

I have used the following code to get it :

\documentclass{article}
\usepackage{tikz}

\begin{document}
\begin{tikzpicture}
\draw (2,2) circle (3cm);
\draw (2,2) ellipse (3cm and 1cm);
\end{tikzpicture}
\end{document}    

which produces :

enter image description here

How can I draw my desired figure using tikzpicture ?

Is there any way to draw an arbitrary curve with some portion of it is dotted?

Best Answer

In your case, it is very simple to draw the ellipse twice, and clip the solid part, so only half of it is shown.

\documentclass{article}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}
\draw (2,2) circle (3cm);
\draw[dashed] (2,2) ellipse (3cm and 1cm);
\clip (-1.1,2) rectangle (5.1 cm,0.9 cm);
\draw (2,2) ellipse (3cm and 1cm);
\end{tikzpicture}
\end{document}

result