Stereographic Projection

By Xah Lee. Date: . Last updated: .
Stereographic Projection 2023-03-07
Stereographic Projection. Associating points on the plane and points on the sphere.
xgridLen = 0.2;
xBoundary = 2;

projectF = ( With[{xx = 1 + #.#}, {#[[1]]/xx, #[[2]]/xx, 1 - 1/xx}] &);

grid2d = Table[{Hue[0], Line[{{x, y}, {x, y + xgridLen}}], GrayLevel[ 0.5 ],
    Line[{{x, y}, {x + xgridLen, y}}]}, {x, -xBoundary, xBoundary, xgridLen}, {y, -xBoundary,
     xBoundary, xgridLen}];

Graphics[grid2d]

grid3d = grid2d /. Line[xpts_] :> Line[(({#[[1]],#[[2]],0}) &) /@ xpts];
Graphics3D[grid3d]

xball = grid2d /. Line[xpts_] :> Line[projectF /@ xpts];

Graphics3D[xball]

Graphics3D[{grid3d, xball}]

sqrCorners = ({{0, 0}, {1, 0}, {1, 1}, {0, 1}} xgridLen) ;

patch2dRed = { Red, Polygon[ ((#+{0, -4} xgridLen) &) /@ sqrCorners ]}
patch2dGreen = { Green, Polygon[ ((#+{2, -4} xgridLen) &) /@ sqrCorners ]}
patch2dBlue = {Blue, Polygon[ ((#+{4, -4} xgridLen) &) /@ sqrCorners ]}
patches2d = {patch2dRed, patch2dGreen, patch2dBlue};

patches3d = (Replace[ {patch2dRed, patch2dGreen, patch2dBlue}, {x_, y_} -> {x, y, 0}, {-2}]);

projLines = ReplaceAll[patches3d, Polygon[pts_] :> Map[ ((Line@{{0,0,1},#}) &), pts]]

projectedPatches = (Replace[ patches2d, {x_, y_} -> projectF@{x, y}, {-2}])

Graphics3D[{grid3d, xball, patches3d }, Axes -> True]

Graphics3D[{grid3d, xball,  patches3d, projLines, projectedPatches }, Axes -> True, PlotRange -> {{-1,1} xBoundary .5 , {-1,1} xBoundary .5 , {-0.1, 1} }]

Graphics3D[{grid3d, xball, patches3d } /. Line -> Tube, Axes -> True]

Graphics3D[{grid3d, xball,  patches3d, projLines, projectedPatches }  /. Line -> Tube, Axes -> True, PlotRange -> {{-1,1} xBoundary .5 , {-1,1} xBoundary .5 , {-0.1, 1} }]

more examples:

star arrow network star arrow network rs
hexagram snowflake hexagram snowflake rs
random hex tiling random hex tiling projection
random hex tiling random hex tiling projection

Notes

The images on this page is generated by the following Mathematica packages: