SPHERE_QUAD is a FORTRAN90 library which estimates the integral of a scalar function F(X,Y,Z) over the surface of the unit sphere centered at the origin.

The library includes one function, SPHERE01_QUAD_MC, which estimates the integral using a Monte Carlo approach. It randomly samples points on the surface, and estimates the integral as the average of these values times the area of the surface.

The library includes three functions based on the idea of a latitudinal/longitudinal grid: SPHERE01_QUAD_LLC, SPHERE01_QUAD_LLV and SPHERE01_QUAD_LLM. The surface of the sphere is divided into rectangles whose sides are always lines of latitude or longitude. Each rectangle is then split diagonally into a pair of triangles (except for the degenerate rectangles that include the north or south pole as a vertex.)

The user controls the accuracy of the integral estimate by specifying a maximum side length H. The functions determine angular increments that guarantee the size restriction. Of course, this means that the restriction on latitude, enforced at the equator, will result in excessively small triangles away from the equator. That is a penalty of using this simple subdivision scheme.

The library includes three functions based on the idea of first subdividing the surface into 20 congruent spherical triangles, based on the projection of a regular icosahedron. The functions SPHERE01_QUAD_ICOS1C, SPHERE01_QUAD_ICOS1V and SPHERE01_QUAD_ICOS1M use this idea, along with subdivision.

The function SPHERE01_QUAD_ICOS2V is similar to SPHERE01_QUAD_ICOS1V but uses a more sophisticated algorithm to project points from the planar triangle to the unit sphere. However, the modifications seem to make little difference to the resulting integral estimate.

### Languages:

SPHERE_QUAD is available in a C version and a C++ version and a FORTRAN77 version and a FORTRAN90 version and a MATLAB version.

### Related Data and Programs:

RANDOM_DATA, a FORTRAN90 library which generates sample points for various probability distributions, spatial dimensions, and geometries;

SPHERE_CVT, a FORTRAN90 library which creates a mesh of well-separated points on a unit sphere using Centroidal Voronoi Tessellations.

SPHERE_DELAUNAY, a FORTRAN90 program which computes and plots the Delaunay triangulation of points on the unit sphere.

SPHERE_DESIGN_RULE, a FORTRAN90 library which returns point sets on the surface of the unit sphere, known as "designs", which can be useful for estimating integrals on the surface, among other uses.

SPHERE_EXACTNESS, a FORTRAN90 program which tests the polynomial exactness of a quadrature rule for the unit sphere;

SPHERE_GRID, a FORTRAN90 library which provides a number of ways of generating grids of points, or of points and lines, or of points and lines and faces, over the unit sphere.

SPHERE_INTEGRALS, a FORTRAN90 library which defines test functions for integration over the surface of the unit sphere in 3D.

SPHERE_LEBEDEV_RULE, a FORTRAN90 library which computes Lebedev quadrature rules for the unit sphere;

SPHERE_MONTE_CARLO, a FORTRAN90 library which applies a Monte Carlo method to estimate the integral of a function over the surface of the sphere in 3D;

SPHERE_TRIANGLE_QUAD, a FORTRAN90 library which estimates the integral of a function over a spherical triangle.

SPHERE_VORONOI, a FORTRAN90 program which computes the Voronoi diagram of points on a sphere.

STRIPACK, a FORTRAN90 library which computes the Voronoi diagram or Delaunay triangulation of pointsets on a sphere, by Robert Renka.

STROUD, a FORTRAN90 library which approximates the integral of a function on the surface or in the interior of a variety of geometric shapes.

XYZ_DISPLAY, a MATLAB program which reads XYZ information defining points in 3D, and displays an image in the MATLAB graphics window.

XYZ_DISPLAY_OPENGL, a C++ program which reads XYZ information defining points in 3D, and displays an image using OpenGL.

### Reference:

• James Arvo,
Stratified sampling of spherical triangles,
Computer Graphics Proceedings, Annual Conference Series,
ACM SIGGRAPH '95, pages 437-438, 1995.
• Philip Davis, Philip Rabinowitz,
Methods of Numerical Integration,
Second Edition,
Dover, 2007,
ISBN: 0486453391,
LC: QA299.3.D28.
• Gerald Folland,
How to Integrate a Polynomial Over a Sphere,
American Mathematical Monthly,
Volume 108, Number 5, May 2001, pages 446-448.
• Jacob Goodman, Joseph ORourke, editors,
Handbook of Discrete and Computational Geometry,
Second Edition,
CRC/Chapman and Hall, 2004,
ISBN: 1-58488-301-4,
LC: QA167.H36.

### List of Routines:

• ARC_COSINE computes the arc cosine function, with argument truncation.
• ARC_SINE computes the arc sine function, with argument truncation.
• ATAN4 computes the inverse tangent of the ratio Y / X.
• ICOS_SHAPE describes an icosahedron.
• ICOS_SIZE gives "sizes" for an icosahedron in 3D.
• R8_GAMMA evaluates Gamma(X) for a real argument.
• R8_UNIFORM_01 returns a unit pseudorandom R8.
• R8VEC_NORM returns the L2 norm of an R8VEC.
• R8VEC_POLARIZE decomposes an R8VEC into normal and parallel components.
• S_CAT concatenates two strings to make a third string.
• SPHERE01_DISTANCE_XYZ computes great circle distances on a unit sphere.
• SPHERE01_MONOMIAL_INTEGRAL returns monomial integrals on the unit sphere.
• SPHERE01_QUAD_ICOS1C: centroid rule, subdivide then project.
• SPHERE01_QUAD_ICOS1M: midside rule, subdivide then project.
• SPHERE01_QUAD_ICOS1V: vertex rule, subdivide then project.
• SPHERE01_QUAD_ICOS2V: vertex rule, subdivide then project.
• SPHERE01_QUAD_LLC: Longitude/Latitude grid with centroid rule.
• SPHERE01_QUAD_LLM: longitude/latitude grid plus midside rule.
• SPHERE01_QUAD_LLV: longitude/latitude grid with vertex rule.
• SPHERE01_SAMPLE_3D picks random points on a sphere in 3D.
• SPHERE01_TRIANGLE_ANGLES_TO_AREA computes the area of a spherical triangle.
• SPHERE01_TRIANGLE_PROJECT projects from a plane triangle to a spherical triangle.
• SPHERE01_TRIANGLE_PROJECT2 projects from a plane triangle to a spherical triangle.
• SPHERE01_TRIANGLE_SAMPLE: sample points from triangle on unit sphere.
• SPHERE01_TRIANGLE_SIDES_TO_ANGLES computes spherical triangle angles.
• SPHERE01_TRIANGLE_VERTICES_TO_AREA computes the area of a spherical triangle.
• SPHERE01_TRIANGLE_VERTICES_TO_CENTROID gets a spherical triangle "centroid".
• SPHERE01_TRIANGLE_VERTICES_TO_MIDPOINTS gets the midsides of a spherical triangle.
• SPHERE01_TRIANGLE_VERTICES_TO_SIDES computes spherical triangle sides.
• TIMESTAMP prints the current YMDHMS date as a time stamp.
• TP_TO_XYZ converts spherical TP coordinates to XYZ coordinates.

You can go up one level to the FORTRAN90 source codes.

Last revised on 23 September 2010.