# Calculate the limit of spherical cap in spherical coordinate [duplicate]

I am using spherical coordinate system $$r,\theta, \phi$$ like this picture.

Consider I have a sphere with radius $$R$$, is divided into two hemisphere $$S$$ and $$P$$.

With this given information I am able to calculate $$\phi$$ limits for $$P$$ portion over $$T$$ using the following method:

$$\begin{split} \tan \beta = z/y,\\ z=R\cos\theta, \end{split}\quad \iff \quad y={R\cos\theta\over\tan\beta}$$

$$\begin{split} R\sin\theta\sin\phi={R\cos\theta\over\tan\beta}, \\ \sin\phi={1\over\tan\beta\tan\theta}, \end{split}\quad \iff \quad \phi=\arcsin{1\over\tan\beta\tan\theta}.$$ So the $$\phi$$ can go until $$\pi -\phi$$.

Now consider my $$P$$ is not a hemisphere: rather it is a spherical cap, where the cap size can be defined by an angle $$\gamma$$.

What will be my $$\phi$$ in this case to calculate the $$P$$ portion over the line $$T$$?