tikz add tag
Anonymous 1679
I am trying to draw a Spherical Segment like this [here](https://mathworld.wolfram.com/SphericalSegment.html).
I tried
```
\documentclass[border=2mm]{standalone}
 \usepackage{tikz-3dplot-circleofsphere}
 \begin{document}
 \def\r{1.5}
 \tdplotsetmaincoords{60}{125}
 \begin{tikzpicture}[tdplot_main_coords]
 	\begin{scope}
 		\draw[tdplot_screen_coords] (0,0,0) circle (\r);
 		\tdplotCsDrawLatCircle{\r}{20}
 		\tdplotCsDrawLatCircle{\r}{40}
 	\end{scope}
 	
 \end{tikzpicture}
 \end{document}
```
![137633045_160189445594344_5590119534919050660_n.png](/image?hash=4169ce0f5ccd63abddd2674535dc268d8ca67a82742727e3c1f2cde3d49eef13)
How to draw like the link?
Top Answer
user 3.14159
Here is a possible way to do that with the [experimental 3dtools library](https://github.com/marmotghost/tikz-3dtools). Please note that this version assumes that both circles have a hidden and a visible stretch. One *can* generalize this to the general case, but I am not sure if this is needed, and this will definitely make the code longer, so I let it be.
```
\documentclass[tikz,border=3mm]{standalone}
\usetikzlibrary{calc,decorations.pathreplacing,3dtools} % https://github.com/marmotghost/tikz-3dtools
\pgfdeclarelayer{background} 
\pgfdeclarelayer{foreground}
\pgfsetlayers{background,main,foreground}
\begin{document}
\begin{tikzpicture}[3d/install view={phi=0,theta=60},
	declare function={R=3;a=2.9;b=2;h1=sqrt(R*R-a*a);h2=sqrt(R*R-b*b;},
	3d/hidden/.append style={on layer=background},
	3d/visible/.append style={on layer=foreground}]
 \path[3d/hidden/.append style={postaction={store path=H1}},
 	3d/visible/.append style={postaction={store path=V1}}] 
		pic{3d/circle on sphere={R=R,P={(0,0,h1)}}};
 \path[3d/hidden/.append style={postaction={store path=H2}},
 	3d/visible/.append style={postaction={store path=V2}}] 
		pic{3d/circle on sphere={R=R,P={(0,0,h2)}}};
 \draw[3d/hidden] [stored path/first coordinate of=V2] coordinate (aux2)
  		[stored path/first coordinate of=V1] coordinate (aux1)
		(b,0,h2) -- node[below] {$b$}(0,0,h2) -- (0,0,h1)
			 --node[below] {$a$}(a,0,h1);		
 \path[3d/screen coords,fill=cyan,opacity=0.6,stored path/restore reversed path=V2]
   let \p1=(aux1),\p2=(aux2),\n1={atan2(\y1,\x1)},\n2={atan2(\y2,\x2)} in
   -- (aux2) arc[start angle=\n2,end angle=\n1,radius=R]
   [stored path/append path=V1]
   arc[start angle=180-\n1,end angle=180-\n2,radius=R];		
 \path[fill=blue,opacity=0.6,stored path/restore reversed path=V2,
 	stored path/append path=H2] --cycle;
 \draw[3d/screen coords,3d/visible] (0,0) circle[radius=R];
\end{tikzpicture}
\end{document}
```
![Screen Shot 2021-01-15 at 5.27.26 PM.png](/image?hash=1efe461394ecc196e20d2cea96b5135d366629f08a68c7095aaae206b260df18)

Enter question or answer id or url (and optionally further answer ids/urls from the same question) from

Separate each id/url with a space. No need to list your own answers; they will be imported automatically.