SPHERE_GRID
Grids on a Sphere
SPHERE_GRID
is a C library which
constructs a grid of points
over the surface of the unit sphere in 3D.
A grid on a sphere may mean a set of points, or a set of points and
lines that connect them, or a set of points, lines that connect them,
and the faces that are bounded by those lines.
A grid may be desired which simply organizes areas. In that case,
something like the latitude and longitude lines on a globe may be
sufficient, even though "evenly spaced" latitude and longitude
lines result in grid cells that are close to rectangular near
the equator, but become more asymmetric near the poles.
A grid may also be desired for sampling, that is, for choosing
a set of points that are well spread across the sphere. A simple
Monte Carlo approach can be used, although this means that the
data is only well spread out in the long view; there may be local
clusters and gaps.
Other grids are generated by drawing a spiral on the surface of the
sphere, and choosing points at regular spacings along that line, or
by projecting an icosahedron onto the surface of the sphere, which
divides the surface into 20 congruent spherical triangles, and then
dealing with the simpler issue of choosing points from the triangles.
The test program uses GNUPLOT to make images of some of the grids.
Licensing:
The computer code and data files described and made available on this web page
are distributed under
the GNU LGPL license.
Languages:
SPHERE_GRID is available in
a C version and
a C++ version and
a FORTRAN90 version and
a MATLAB version.
Related Data and Programs:
CUBE_GRID,
a C library which
computes a grid of points
over the interior of a cube in 3D.
DISK_GRID,
a C library which
computes a grid of points
over the interior of a disk in 2D.
GNUPLOT,
C programs which
illustrate how a program can write data and command files
so that gnuplot can create plots of the program results.
HYPERCUBE_GRID,
a C library which
computes a grid of points
over the interior of a hypercube in M dimensions.
LINE_GRID,
a C library which
computes a grid of points
over the interior of a line segment in 1D.
POLYGON_GRID,
a C library which
generates a grid of points
over the interior of a polygon in 2D.
PYRAMID_GRID,
a C library which
computes a grid of points
over the interior of the unit pyramid in 3D;
SIMPLEX_GRID,
a C library which
generates a grid of points
over the interior of a simplex in M dimensions.
SPHERE_FIBONACCI_GRID,
a C library which
computes a grid of points using the Fibonacci spiral
over the surface of a sphere in 3D.
SPHERE_LLQ_GRID,
a C library which
uses longitudes and latitudes to create grids of points,
lines, and quadrilaterals
on the surface of the unit sphere in 3D.
SPHERE_LLT_GRID,
a C library which
uses longitudes and latitudes to create grids of points,
lines, and triangles
on the surface of the unit sphere in 3D.
SQUARE_GRID,
a C library which
computes a grid of points
over the interior of a square in 2D.
TRIANGLE_GRID,
a C library which
computes a grid of points
over the interior of a triangle in 2D.
WEDGE_GRID,
a C library which
computes a grid of points
over the interior of the unit wedge in 3D.
Reference:
-
Edward Saff, Arno Kuijlaars,
Distributing Many Points on a Sphere,
The Mathematical Intelligencer,
Volume 19, Number 1, 1997, pages 5-11.
-
Richard Swinbank, James Purser,
Fibonacci grids: A novel approach to global modelling,
Quarterly Journal of the Royal Meteorological Society,
Volume 132, Number 619, July 2006 Part B, pages 1769-1793.
Source Code:
Examples and Tests:
To see the XYZ data files and images of the sphere grids created by this
example program, go to
the SPHERE_GRID dataset directory.
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.
-
I4_MAX returns the maximum of two I4's.
-
I4_MIN returns the smaller of two I4's.
-
I4_POWER returns the value of I^J.
-
I4MAT_TRANSPOSE_PRINT prints an I4MAT, transposed.
-
I4MAT_TRANSPOSE_PRINT_SOME prints some of an I4MAT, transposed.
-
I4VEC_COPY copies an I4VEC.
-
ICOS_SHAPE describes a icosahedron.
-
ICOS_NUM gives "sizes" for an icosahedron.
-
R8_ABS returns the absolute value of an R8.
-
R8_MODP returns the nonnegative remainder of R8 division.
-
R8_UNIFORM_01 returns a unit pseudorandom R8.
-
R8MAT_TRANSPOSE_PRINT prints an R8MAT, transposed.
-
R8MAT_TRANSPOSE_PRINT_SOME prints some of an R8MAT, transposed.
-
R8MAT_WRITE writes an R8MAT file.
-
R8VEC_COPY copies an R8VEC.
-
R8VEC_DIFF_NORM returns the L2 norm of the difference of R8VEC's.
-
R8VEC_DOT_PRODUCT computes the dot product of a pair of R8VEC's.
-
R8VEC_EQ is true if every pair of entries in two R8VEC's is equal.
-
R8VEC_NORM returns the L2 norm of an R8VEC.
-
R8VEC_POLARIZE decomposes an R8VEC into normal and parallel components.
-
R8VEC_PRINT prints an R8VEC.
-
SPHERE_CUBED_IJK_TO_XYZ: cubed sphere IJK to XYZ coordinates.
-
SPHERE_CUBED_LINE_NUM counts lines on a cubed sphere grid.
-
SPHERE_CUBED_LINES computes the lines on a cubed sphere grid.
-
SPHERE_CUBED_POINTS computes the points on a cubed sphere grid.
-
SPHERE_CUBED_POINTS_FACE: points on one face of a cubed sphere grid.
-
SPHERE_CUBED_POINT_NUM counts the points on a cubed sphere grid.
-
SPHERE_DISTANCE_XYZ computes great circle distances on a sphere.
-
SPHERE_FIBONACCI_POINTS computes sphere points on a Fibonacci spiral.
-
SPHERE_GRID_Q4: rectangular grid on a sphere.
-
SPHERE_GRID_T3 produces a triangle grid on a sphere.
-
SPHERE_ICOS_EDGE_NUM sizes an icosahedral grid on a sphere.
-
SPHERE_ICOS_FACE_NUM sizes an icosahedral grid on a sphere.
-
SPHERE_ICOS_POINT_NUM sizes an icosahedral grid on a sphere.
-
SPHERE_ICOS1_POINTS returns icosahedral grid points on a sphere.
-
SPHERE_ICOS2_POINTS returns icosahedral grid points on a sphere.
-
SPHERE_LINE_PROJECT projects a line onto an implicit sphere.
-
SPHERE_LL_LINES produces lines on a latitude/longitude grid.
-
SPHERE_LL_LINE_NUM counts lines for a latitude/longitude grid.
-
SPHERE_LL_POINTS produces points on a latitude/longitude grid.
-
SPHERE_LL_POINT_NUM counts points for a latitude/longitude grid.
-
SPHERE_LLQ_LINES: latitude/longitude quadrilateral grid lines.
-
SPHERE_LLQ_LINE_NUM counts lines for a latitude/longitude quadrilateral grid.
-
SPHERE_SPIRALPOINTS produces spiral points on an implicit sphere.
-
SPHERE_UNIT_SAMPLE picks a random point on the unit sphere.
-
TIMESTAMP prints the current YMDHMS date as a time stamp.
You can go up one level to
the C source codes.
Last revised on 21 October 2013.