Surface area of a sphere bounded by a pyramid I'm trying to calculate the surface area of a sphere that is bounded by the walls of a triangular pyramid.  $o$ is the origin and centre of a sphere of radius $R$, $a$ is a point at the tip of the pyramid, and the edges are in the direction of 3 unit vectors, $v_1$, $v_2$, $v_3$.

My guess is to use a surface integral over the sphere, but I'm unsure of the bounds.  Also $v_i$ and $a$ are in Cartesian coordinates, and I want to make the simplest calculation.  Converting them to polar is fine, if it makes the integral simpler, but I'm using this as part of a program, so I'm trying to limit the precision loss.
 A: WOLOG, we will assume the three unit vectors $\hat{v}_1, \hat{v}_2, \hat{v}_3$ are labeled
in such a way so that $\hat{v}_1 \cdot (\hat{v}_2 \times \hat{v}_3) > 0$.
If the tip of the pyramid $\vec{a}$ coincides with $\vec{0}$, the origin and center of the sphere. Oosterom and Strackee has a simple formula to compute the solid angle $\Omega$ 
"enclosed" by the 3 vectors $\hat{v}_1, \hat{v}_2, \hat{v}_3$:
$$\tan\left(\frac{\Omega}{2}\right) = 
\frac{\hat{v}_1 \cdot (\hat{v}_2 \times \hat{v}_3)}{1 + 
\hat{v}_1 \cdot\hat{v}_2 + \hat{v}_2 \cdot\hat{v}_3 + \hat{v}_3 \cdot\hat{v}_1}
$$
The area one want is simply $\Omega R^2$. Take a look at the wiki entry
of Solid angle,  in particular the section
about Tetrahedron for more details.
If not, then one need a lot more works. If I didn't make any mistake, one can compute
the area by following procedure.


*

*Pick $\lambda_1, \lambda_2, \lambda_3 > 0$ such that the three vectors
$$\begin{cases}
\vec{x}_1 =& \vec{a} + \lambda_1 \hat{v}_1\\
\vec{x}_2 =& \vec{a} + \lambda_2 \hat{v}_2\\
\vec{x}_3 =& \vec{a} + \lambda_3 \hat{v}_3
\end{cases}
\quad\quad
\text{lie on the sphere,  i.e. }
|\vec{x}_1| = |\vec{x}_2| = |\vec{x}_3| = R
$$

*Define 3 unit vectors $\hat{n}_1, \hat{n}_2, \hat{n}_3$ by
$$
\hat{n}_1 = \frac{\hat{v}_2 \times \hat{v}_3}{|\hat{v}_2 \times \hat{v}_3|},
\quad
\hat{n}_2 = \frac{\hat{v}_3 \times \hat{v}_1}{|\hat{v}_3 \times \hat{v}_1|},
\quad\text{ and }\quad
\hat{n}_3 = \frac{\hat{v}_1 \times \hat{v}_2}{|\hat{v}_1 \times \hat{v}_2|},
$$  These are the inward pointing normal vectors for the  3 faces span by 
$\big\{\;\vec{a}, \vec{x}_2, \vec{x}_3\;\big\}$,
$\big\{\;\vec{a}, \vec{x}_3, \vec{x}_1\;\big\}$ and
$\big\{\;\vec{a}, \vec{x}_1, \vec{x}_2\;\big\}$ respectively.
The pyramid itself consists of those points satisfying
$$\vec{n}_1\cdot (\vec{x}-\vec{a})\ge 0 \quad\land\quad
\vec{n}_2\cdot (\vec{x}-\vec{a}) \ge 0  \quad\land\quad
\vec{n}_3\cdot (\vec{x}-\vec{a}) \ge 0$$

*Define 6 more unit vectors $ \hat{t}_{12}, \hat{t}_{13}, \hat{t}_{23},\hat{t}_{21}, \hat{t}_{31}, \hat{t}_{32}$ by
$$\hat{t}_{ij} = \frac{\hat{n}_i \times \vec{x}_j}{|\hat{n}_i \times \vec{x}_j|}$$
The intersection of the pyramid with the sphere is a spherical triangle. It has 3 edges
which are planar circular arcs. $\hat{t}_{12}$ and $\hat{t}_{13}$ are the tangent vectors of the edge lying on the plane $\hat{n}_1 \cdot (\vec{x} - \vec{a}) = 0$ at 
positions $\vec{x}_2$ and $\vec{x}_3$ respectively. The other 4 vectors are defined
in similar manner.
Recall the Gauss-Bonnet theorem for the sphere. One version of it says that if we have a
smooth closed curve $\mathcal{C}$ on our sphere with radius $R$ bounding a
region $\mathcal{D}$, then the area of $\mathcal{D}$ satisfies:
$$\frac{\text{Area}(\mathcal{D})}{R^2} + \int_{\mathcal{C}} k_g ds = 2\pi\tag{*1}$$
where $k_g$ and $ds$ are the geodesic curvature and line element along $\mathcal{C}$. If $\mathcal{C}$ is piecewise smooth instead of smooth, then one should interpret the integral 
$\int_{\mathcal{C}} k_g ds$ as as the sum of corresponding integrals along the smooth portions plus the sum of change of angles of the tangent vectors at the corners.
As I have mentioned before, the intersection of the pyramid and our sphere have 3 edges
which are planar circular arcs. One can show that along any one of these edges, say the
one on the plane $\hat{n}_1 \cdot (\vec{x}-\vec{a}) = 0$, its contribution to
$\;\;\displaystyle \int k_g ds\;\;$ has the form $\;\;\displaystyle \frac{\hat{n}_1\cdot \vec{a}}{R} \cos^{-1}(\hat{t}_{12}\cdot\hat{t}_{13})$.
Collect all these terms and throw it to equation $(*1)$, we find the area of the
intersection is given by following formula.
$$\begin{align}
\text{Area} =& 2\pi R^2 - R^2\left[  \cos^{-1}(\hat{t}_{21}\cdot\hat{t}_{31})
   + \cos^{-1}(\hat{t}_{12}\cdot\hat{t}_{32})
   + \cos^{-1}(\hat{t}_{13}\cdot\hat{t}_{23}) \right]\\
&-R \left[
  \hat{n}_1\cdot\vec{a} \cos^{-1}(\hat{t}_{12}\cdot\hat{t}_{13})
+ \hat{n}_2\cdot\vec{a} \cos^{-1}(\hat{t}_{21}\cdot\hat{t}_{23})
+ \hat{n}_3\cdot\vec{a} \cos^{-1}(\hat{t}_{31}\cdot\hat{t}_{32})
\right]
\end{align}$$
The second term is the contribution from the change of angles at each vertices. 
The third term is the contribution form the 3 edges.
