绘制六个半球

绘制六个半球

我试图画出以下六个半球,它们的中心在一条水平线上。我使用 Alenanno 的答案问题
在此处输入图片描述
我已经针对 z > 0 的半球完成了此操作,使用以下代码取自问题

\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}

答案1

欢迎来到 TeX.SE!!

这是另一种方法,使用isometric view(来自perspectiveTiZ 库)和一个\foreach循环。这样,您只需要绘制两个半球并旋转它们。

例如:

\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}

在此处输入图片描述

更新:几乎相同,但使用了\pic。现在它更加可定制,但也需要更多代码:

\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}

在此处输入图片描述

答案2

针对这种情况,带有 3D 模块的 Asymptotethree提供了一种代码简化。

从 开始unithemisphere,我们可以对 XY 平面进行反射,并进行适当的旋转和移动。就是这样!

在此处输入图片描述

// 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);

答案3

不使用任何 3D 相关软件包的三种剪辑(提供一个简单的解决方案,但可能并不适用于所有地方):

\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}

在此处输入图片描述

相关内容