8

I am trying to draw the following six hemispheres next to each other with their centers aligned on a horizontal line. I am using Alenanno's answer to the question.
enter image description here
I have done this just for the hemisphere with z > 0 using the following code taken from the question.

\documentclass[12pt]{report}
\usepackage{tikz}
\usepackage{tikz-3dplot}
\begin{document}
\tdplotsetmaincoords{60}{110}

\pgfmathsetmacro{\radius}{1} \pgfmathsetmacro{\thetavec}{0} \pgfmathsetmacro{\phivec}{0}

\begin{tikzpicture}[scale=1,tdplot_main_coords] \tdplotsetthetaplanecoords{\phivec}

\draw[dashed] (\radius,0,0) arc (0:360:\radius); \shade[ball color=blue!10!white,opacity=0.2] (1cm,0) arc (0:-180:1cm and 5mm) arc(180:0:1cm and 1cm);

\shade[ball color=blue!10!white,opacity=0.2] (1cm,0) arc (180::1cm and 5mm) arc(360:0:1cm and 1cm); \end{tikzpicture} \end{document}

Black Mild
  • 17,569

3 Answers3

16

Welcome to TeX.SE!!

This is another approach, using an isometric view (from perspective TikZ library) and a \foreach loop. This way you only need tho draw two hemispheres and rotate them.

For example:

\documentclass[tikz,border=1.618mm]{standalone}
\usetikzlibrary{perspective}

\tikzset{sphere/.style={shading=ball,ball color=gray!30,fill opacity=0.8}}

\begin{document} \begin{tikzpicture}[isometric view,rotate around z=180] \foreach\i in {0,1,2} { \begin{scope}[shift={(135:4.5\i)},rotate=-120\i] \draw (0,0) circle (1); \draw[sphere] (-45:1) arc (180:0:1cm) arc (135:-45:1); \end{scope} \begin{scope}[shift={(135:4.5\i+2.25)},rotate=-120\i] \draw[sphere] (0,0) circle (1); \draw[sphere] (-45:1) arc (-180:0:1cm) arc (135:-45:1); \end{scope} }
\end{tikzpicture} \end{document}

enter image description here

Update: Almost the same, but using a \pic. Now it's more customizable, but also requires more code:

\documentclass[tikz,border=1.618mm]{standalone}

\tikzset { sphere/.style={ball color=#1,fill opacity=0.6}, pics/hemisphere/.style={code=% { \ifnum#1=0 \draw (0,0) ellipse (1 and {sqrt(1/3)}); \fi \begin{scope} \clip (-1,0) arc (180:0:1cm) arc (0:-180:1 and {(1-2#1)sqrt(1/3)}); \fill[pic actions] (0,0) circle (1); \end{scope} \draw (-1,0) arc (180:0:1cm) arc (0:-180:1 and {(1-2#1)sqrt(1/3)}); \ifnum#1=1 \begin{scope} \clip (0,0) ellipse (1 and {sqrt(1/3)}); \fill[pic actions] (0.25,-0.25) circle (2); \end{scope} \draw (0,0) ellipse (1 and {sqrt(1/3)}); \fi }}, }

\begin{document} \begin{tikzpicture} \pic[sphere=red!70] at (0,0) {hemisphere=0}; % 0 = interior not visible \pic[sphere=red!70,rotate=180] at (2.25,0) {hemisphere=1}; % 1 = interior visible \pic[sphere=blue!50,rotate=60] at (5,0) {hemisphere=1}; \pic[sphere=blue!50,rotate=240] at (6.5,0) {hemisphere=0}; \pic[sphere=green,rotate=120] at (9.5,0) {hemisphere=0}; \pic[sphere=green,rotate=300] at (11,0) {hemisphere=1}; \end{tikzpicture} \end{document}

enter image description here

Juan Castaño
  • 28,426
9

For this situation, Asymptote with the 3D module three gives a kind of code simplification.

Starting with the unithemisphere, we can take reflection with respect to the XY-plane, suitable rotations and shifts. That's it!

enter image description here

// http://asymptote.ualberta.ca/
unitsize(2cm);
import three;
currentprojection=orthographic(X+.3Z,zoom=.9);

picture uhsN; // the north hemisphere draw(uhsN,unithemisphere,yellow+opacity(.7)); draw(uhsN,unitcircle3,gray); picture uhsS=zscale3(-1)*uhsN; // the south hemisphere

real a=.3,b=.6; add(uhsN); add(shift(0,2+a,0)uhsS); add(shift(0,4+a+b,0)rotate(60,X)uhsN); add(shift(0,4.5+2a+b,0)rotate(60,X)uhsS); add(shift(0,7+a+b,0)rotate(-60,X)uhsN); add(shift(0,9+2a+b,0)rotate(-60,X)*uhsS);

Black Mild
  • 17,569
8

Three cuts without any 3D-related packages (to provide a simple solution which admittedly might not work everywhere):

\documentclass[border=10pt]{standalone}
\usepackage{tikz}

\begin{document} \begin{tikzpicture}

\begin{scope}[shift={(-2.25,0)}] \draw[dashed] (1,0) arc[start angle=0, end angle=360, x radius=1, y radius=1]; \shade[ball color=blue!10!white, opacity=0.2] (1,0) arc[start angle=0, end angle=360, x radius=1, y radius=1]; \end{scope}

\begin{scope}[shift={(-2.25,-2.25)}] \draw[dashed, opacity=0.25] (1,0) arc[start angle=0, end angle=360, x radius=1, y radius=1]; \shade[ball color=blue!10!white, opacity=0.2] (1,0) arc[start angle=0, end angle=360, x radius=1, y radius=1]; \end{scope}

\begin{scope}[shift={(0,0)}] \draw[dashed] (1,0) arc[start angle=0, end angle=-180, x radius=1, y radius=.5]; \draw[dashed, opacity=0.25] (1,0) arc[start angle=0, end angle=180, x radius=1, y radius=.5]; \shade[ball color=blue!10!white, opacity=0.2] (1,0) arc[start angle=0, end angle=-180, x radius=1, y radius=.5] arc[start angle=180, end angle=0, x radius=1, y radius=1]; \end{scope}

\begin{scope}[shift={(0,-2.25)}] \draw[dashed] (1,0) arc[start angle=0, end angle=360, x radius=1, y radius=.5]; \shade[ball color=blue!10!white, opacity=0.2] (1,0) arc[start angle=0, end angle=180, x radius=1, y radius=.5] arc[start angle=180, end angle=360, x radius=1, y radius=1]; \end{scope}

\begin{scope}[shift={(2.25,0)}] \draw[dashed] (0,1) arc[start angle=90, end angle=450, x radius=.5, y radius=1]; \shade[ball color=blue!10!white, opacity=0.2] (0,1) arc[start angle=90, end angle=-90, x radius=.5, y radius=1] arc[start angle=270, end angle=90, x radius=1, y radius=1]; \end{scope}

\begin{scope}[shift={(2.25,-2.25)}] \draw[dashed] (0,1) arc[start angle=90, end angle=270, x radius=.5, y radius=1]; \draw[dashed, opacity=0.25] (0,1) arc[start angle=90, end angle=-90, x radius=.5, y radius=1]; \shade[ball color=blue!10!white, opacity=0.2] (0,1) arc[start angle=90, end angle=270, x radius=.5, y radius=1] arc[start angle=-90, end angle=90, x radius=1, y radius=1]; \end{scope}

\end{tikzpicture} \end{document}

enter image description here

  • Thanks for your answer. I will try to see if can rotate the first and forth hemispheres to get them look sitting inside three dimensions. – Math learner May 12 '23 at 09:00
  • 1
    @Ali With the above code, you can't rotate the single parts in a 3D manner, because I did not make use of such libraries. The hemispheres in the first column are just plain circles really. I just thought that this could be a simple solution in certain cases. – Jasper Habicht May 12 '23 at 09:02
  • 1
    The above follows a coordinate system where the x axis is horizontal, the y axis is vertical and the z axis is at 45 degrees (and scaled to 50%). – Jasper Habicht May 12 '23 at 09:14