Calculates the surface area of segments of spheres of radius 'r', defined by the azimuth and elevation angles 'theta' and 'phi'. The calculation os based on the expression S = 2 * pi * R * h, given on http://mathworld.wolfram.com/SphericalCap.html. 'h' can be expressed as R * (1-cos(phi)), and for two elevation angles phi2 >= phi1 we get the following surface area of the resulting "disc" (can be illustrated by cutting an orange by two parallel intersections, and calculate the are of the orange skin): S = 2 * pi * R^2 * ( (1-cos(phi2)) - (1-cos(phi1))) = 2 * pi * R^2 * ( cos(phi1) - cos(phi2)). Splitting the resulting surface into parts by azimuth angle is straight foreward: S = R^2 * ( (1-cos(phi2)) - (1-cos(phi1))) * (theta2 - theta1).

1 |

`r` |
is the radii of the spheres. |

`theta` |
is either a vector of two elements representing the lower and upper azimuth angle of the spherical sector, or a two column matrix of the same. |

`phi` |
is either a vector of two elements representing the lower and upper elevation angle of the spherical sector, or a two column matrix of the same. |

`deg` |
is TRUE if the angles are given in degrees. |

Embedding an R snippet on your website

Add the following code to your website.

For more information on customizing the embed code, read Embedding Snippets.