5

I want to draw this picture with (normal) TikZ:
enter image description here
How do I have to draw the "vertical arcs"?

MWE:

enter image description here

\documentclass[border=5mm]{standalone}
\usepackage{tikz}
\usetikzlibrary{backgrounds}
\begin{document}

\begin{tikzpicture}[ background grid/.style={help lines, draw, step=5mm}, gridded, every path/.style={very thin}, ] \coordinatelabel= at (0,0);

\def\Radius{2} %\shade[ball color = white] (M) circle[radius=\Radius]; \draw (M) circle[radius=\Radius];

\def\R{2}

\foreach \v in {-6,...,6}{%% \pgfmathsetmacro\h{\v\R/6} \pgfmathsetmacro\Radius{sqrt(\R^2-abs(\h)^2)} % Horicontals ================ % front \def\StartAng{0} \def\EndAng{-180} \draw[] ([shift={(\StartAng:\Radius)}]0,\h) arc[start angle=\StartAng, end angle=\EndAng, x radius=\Radius, y radius=0.25\Radius]; % back \def\StartAng{0} \def\EndAng{180} \draw[help lines] ([shift={(\StartAng:\Radius)}]0,\h) arc[start angle=\StartAng, end angle=\EndAng, x radius=\Radius, y radius=0.25*\Radius];

% Verticals ================ % front \def\StartAng{0} \def\EndAng{-180} \draw[blue] ([shift={(\StartAng:\Radius)}]\h,0) arc[start angle=\StartAng, end angle=\EndAng, y radius=\Radius, x radius=0.25\Radius]; % back %\def\StartAng{0} %\def\EndAng{180} %\draw[blue,densely dashed] ([shift={(\StartAng:\Radius)}]\h,0) arc[start angle=\StartAng, end angle=\EndAng, y radius=\Radius, x radius=0.25\Radius]; }%%

%\fill[fill=black] (M) circle (1pt); %\draw[dashed] (M) -- node[above]{$r$} (\Radius,0); \end{tikzpicture} \end{document}

cis
  • 8,073
  • 1
  • 16
  • 45

2 Answers2

10

You can use tikz-3dplot-circleofsphere

\documentclass{standalone}
\usepackage{tikz-3dplot-circleofsphere}
\begin{document}
\centering
\def\r{3}
\tdplotsetmaincoords{60}{125}
\begin{tikzpicture}[tdplot_main_coords]
 \draw[tdplot_screen_coords,thin,black!30] (0,0,0) circle (\r);
 \foreach \a in {-75,-60,...,75}
 {\tdplotCsDrawLatCircle[thin,black!30]{\r}{\a}}
 \foreach \a in {0,15,...,165}
 {\tdplotCsDrawLonCircle[thin,black!30]{\r}{\a}}
  \tdplotCsDrawGreatCircle%
[red,thick,tdplotCsFill/.style={opacity=0.1}]{\r}{105}{-23.5}
 \end{tikzpicture}
 \end{document}

enter image description here

Or 3dtools

\documentclass[tikz,border=3mm]{standalone}
\usetikzlibrary{3dtools}% https://github.com/marmotghost/tikz-3dtools
\begin{document}
\pgfdeclarelayer{background} 
\pgfdeclarelayer{foreground}
\pgfsetlayers{background,main,foreground}    
    \begin{tikzpicture}[3d/install view={phi=110,theta=70},scale=1,line cap=butt,
        line join=round,visible/.style={draw,solid},
        hidden/.style={draw,very thin,cheating dash},declare function={R=3;}] 
        \path (0,0,0) coordinate (I)
        foreach \Z in {-75,-60,...,75}
        {(0,0,{R*sin(\Z)}) coordinate (I\Z)}
        foreach \Z in {-75,-60,...,90}
        {({cos(\Z)},{sin(\Z)},0) coordinate (n\Z)};
        \shade[ball color=white,3d/screen coords,opacity=0.8] (I) circle[radius=R];
        %
        \path foreach \Z in {-75,-60,...,90}
        {pic{3d/circle on sphere={R=R,C={(I)},P={(I)},n={(n\Z)},
                    fore layer=foreground,back layer=background}}};
        %  
        \path foreach \Z in {-75,-60,...,75}
        {pic{3d/circle on sphere={R=R,C={(I)}, P={(I\Z)},
                    fore layer=foreground,back layer=background}}};
    \end{tikzpicture}
\end{document}  

enter image description here

  • That's not bad, but for general usability or distribution, standard packages or libraries would be better. – cis Jan 21 '24 at 19:00
2

You could use the blochsphere package:

\documentclass{article}

\usepackage{blochsphere}

\begin{document} \begin{blochsphere}[radius=2cm,opacity=50] \drawBallGrid[]{10}{10} \end{blochsphere} \end{document}

enter image description here

  • 1
    This can also be nested in a TikZ picture, and the manual contains all the PGF/TikZ code that is needed. – hpekristiansen Jan 21 '24 at 20:22
  • I had to give up on producing OPs picture with this seemingly promising package. Nesting does not work. The style option for the sphere itself does not work - several problems. – hpekristiansen Jan 21 '24 at 21:00