Merging 2 hemispheres using tikz

I am trying to reproduce this complicated figure using tikz : this consists of 2 merging hemisphere as shown below :

I don't know if this is really difficult in latex but I have tried to inspire myself from previous posts on this website like for this code :

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

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


But I am not able to reproduce this figure in 2 sides and then obtaining the merged region between the half-sphere seems impossible to me...

Does anyone have some tips in order to achieve this complex task ?

Best regards.

P.S : This is the result obtained with the code provided in the post :

• nice. Can you add a screenshot of your code's result, please? // BTW, you can always act like an artist or designer and sketch w.o. 3D-packages. E.g. use two Bezier lines (thick), a couple of dashed arcs etc. And if you're inspired, you also introduce some vanishing points to give it an even more realistic touch. Commented Sep 18, 2023 at 9:05
• @MS-SPO Thank you for your reply : I think you are right but by doing so I have a lot of difficulties with the little zone between the 2 merged spheres... I think it's easier with a software like Illustrator but in LaTex I am still improving :)) Commented Sep 18, 2023 at 9:27

I'm not sure what you want to achieve exactly, but a simple sketch for your first figure (using hemispheres) can be drawn with the help of TikZ libraries 3d and perspective in isometric view. You'll need to compute a couple of dimensions (angle and radius for the intersection curve).

Something like this;

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

\begin{document}
\begin{tikzpicture}[isometric view,rotate around z=-90,line cap=round,line join=round]
% some dimensions
\pgfmathsetmacro\d{1.9}                     % distance between centers
\pgfmathsetmacro\a{acos(\d/(2*\r)}          % angle
% 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}


• Thank you a lot for your answer : I am progressing to understand how using 3d in tikz : it's not easy. I have a question : how can we specify drawing in the yz plane ? For instance for adding a z-axis and for drawing an arc in the yz plane ? Thank you ! Commented Sep 20, 2023 at 14:25
• @Wiss, with the option canvas is yz plane at x=0 or any other value if you need a parallel plane. There are examples in my code Commented Sep 21, 2023 at 5:15