SPHERE_STEREOGRAPH is a C++ program which implements the standard stereographic mapping between the unit sphere and the plane Z=1, as well as a generalization of this mapping.
The stereographic projection preserves angles, and is a conformal mapping. This implies, for instance, that the Delaunay triangulation of a sphere maps to a corresponding Delaunay triangulation of the plane.
Circles on the sphere that do not pass through the focus will be projected to circles on the plane. Circles on the sphere that do pass through the focus will be projected to straight lines on the plane.
We start with a sphere of radius 1 and center C = (0,0,0).
A plane is chosen, tangent to the sphere, at a point of tangency T which we take to be the "north pole", T = (0,0,1). We use a focus point F, which we take to be the "south pole", (0,0,-1)
For any point P on the sphere, the stereographic projection Q of the point is defined by drawing the line from F through P, and computing Q as the intersection of this line with the plane.
For any point Q on the plane, the stereographic inverse projection P of the point is defined by drawing the line from F through Q, and computing P as the intersection of this line with the sphere.
The function sphere_stereograph carries out the standard projection, and sphere_stereograph_inverse does the inverse.
One way to generalize the projection is to allow the center C and focus point F to be arbitrary. If we assume the point of tangency is antipodal to F then T = 2*C-F. Once these points are defined, the stereographic projection relative to F, C, and T can be set up in the same way as before.
The function sphere_stereograph2 carries out the generalized projection, and sphere_stereograph2_inverse does the inverse.
The computer code and data files described and made available on this web page are distributed under the GNU LGPL license.
SPHERE_STEREOGRAPH is available in a C version and a C++ version and a FORTRAN77 version and a FORTRAN90 version and a MATLAB version.
GEOMETRY, a C++ library which performs geometric calculations in 2, 3 and M dimensional space.
SPHERE_GRID, a C++ 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_STEREOGRAPH_DISPLAY, a MATLAB library which computes and displays the results of several stereographic projections between a sphere and a plane.
You can go up one level to the C++ source codes.