使用 tikz 合并两个半球

使用 tikz 合并两个半球

我正在尝试使用 tikz 重现这个复杂的图形:它由两个合并的半球组成,如下所示: 在此处输入图片描述

我不知道这在乳胶中是否真的很难,但我试图从这个网站以前的帖子中启发自己,比如这个代码:

\documentclass[margin=10pt]{standalone}
\usepackage{tikz}
\usepackage{tikz-3dplot}

\begin{document}
\tdplotsetmaincoords{60}{110}

%define polar coordinates for some vector
%TODO: look into using 3d spherical coordinate system
\pgfmathsetmacro{\radius}{1}
\pgfmathsetmacro{\thetavec}{0}
\pgfmathsetmacro{\phivec}{0}

%start tikz picture, and use the tdplot_main_coords style to implement the display 
%coordinate transformation provided by 3dplot
\begin{tikzpicture}[scale=5,tdplot_main_coords]
%draw the main coordinate system axes
\draw[thick,->] (0,0,0) -- (-1,0,0) node[anchor=south]{$z$};
\draw[thick,->] (0,0,0) -- (0,1,0) node[anchor=north west]{$x$};
\draw[thick,->] (0,0,0) -- (0,0,1) node[anchor=south]{$y$};

\tdplotsetthetaplanecoords{\phivec}

%draw some dashed arcs, demonstrating direct arc drawing
\draw[dashed,tdplot_rotated_coords] (\radius,0,0) arc (0:90:\radius);

\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);
% (-z x y)
\draw (0, 1, 0) node [circle, fill=blue, inner sep=.02cm] () {};
\draw (0, 0, 1) node [circle, fill=green, inner sep=.02cm] () {};
\draw (-1, 0, 0) node [circle, fill=red, inner sep=.02cm] () {};
\end{tikzpicture}
\end{document}

但我无法在两侧重现这个图形,然后获得半球之间的合并区域对我来说似乎是不可能的......

有人能提供一些技巧来完成这个复杂的任务吗?

提前感谢您的指示,

此致。

PS:这是使用帖子中提供的代码获得的结果: 在此处输入图片描述

答案1

我不确定你到底想实现什么,但是你的第一个图形的简单草图(使用球体)可以借助 TiZ 库3dperspectiveisometric view您需要计算几个尺寸(相交曲线的角度和半径)。

像这样;

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

\tikzset{hemisphere/.style={#1,shading=ball,ball color=#1,fill opacity=0.75}}

\begin{document}
\begin{tikzpicture}[isometric view,rotate around z=-90,line cap=round,line join=round]
  % some dimensions
  \pgfmathsetmacro\r{1}                       % radius
  \pgfmathsetmacro\d{1.9}                     % distance between centers
  \pgfmathsetmacro\a{acos(\d/(2*\r)}          % angle
  \pgfmathsetmacro\jr{sqrt(\r*\r-0.25*\d*\d)} % join radius
  % x-axis and centers
  \draw[canvas is xy plane at z=0,scale=1.5,fill=gray!15] (-\r,-\r) rectangle (\d+\r,\r);
  \draw[-latex] (0,0) -- (3.5*\r,0) node[right] {$x$};
  \foreach\i in {0,1}
    \fill (\i*\d,0) circle (0.2mm);
  % blue hemisphere
  \draw[blue] (225:\r) arc (225:45:\r);
  \draw[hemisphere=blue] (225:\r) arc (225:360-\a:\r)
      {[canvas is yz plane at x=0.5*\d] arc (180:0:\jr)} arc (\a:45:\r) arc (0:180:\r cm);
  % red hemisphere
  \draw[red] (\d,0) ++ (225:\r) arc (225:180+\a:\r)
      {[canvas is yz plane at x=0.5*\d] arc (180:0:\jr)} arc (180-\a:45:\r);
  \draw[hemisphere=red] (\d,0) ++ (225:\r) arc (225:405:\r) arc (0:180:\r cm);
\end{tikzpicture}
\end{document}

在此处输入图片描述

相关内容