Mathematica Stack Exchange is a question and answer site for users of Mathematica. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Say I want to represent points of the complex plane in the sphere $\Bbb S^2$ using stereographic projection. That is, the Riemann sphere:

Riemann Sphere

Specifically, it would be nice to be able to:

  1. Given the coordinates $(x,y)$ of a point of the plane, see the point and its spherical image, and optionally, the line through the north pole and $(x,y,0)$.
  2. Given a circle in the plane, (that is, its center $(x,y)$ and its radius $r\gt 0$), see the circle and its spherical image.
  3. Optionally: it would be nice as well but is not necessary, being able to project in the sphere other kinds of sets, say polygons, sets of points, maybe straight lines, etc.

How can we do this? Is this already possible in Mathematica, I mean as built in functions?


share|improve this question
This came to me by trying to solve this problem. See this to see where I'm having troubles. I think most of my confusion will disappear by seeing some drawings. – leo Apr 22 '13 at 18:04
btw you might find something useful for you problem in Mathematica. – Silvia Apr 22 '13 at 18:14
also useful: Riemann sphere – cormullion Apr 22 '13 at 18:55
A search on "stereographic" produces many solutions (including in more dimensions). – whuber Apr 22 '13 at 19:45
@J.M. Modesty :-) – whuber Apr 23 '13 at 14:28
up vote 12 down vote accepted

I think you can do like this:

f[{x_, y_}] := {(2 x)/(1 + x^2 + y^2), (2 y)/(
  1 + x^2 + y^2), (-1 + x^2 + y^2)/(1 + x^2 + y^2)}

for points:

 Graphics3D[{{Black, PointSize[Large], Point[{0, 0, 1}]}, {Black, 
    PointSize[Large], Point[Append[pt, 0]]}, {Pink, PointSize[Large], 
    Point[f[pt]]}, {Opacity[0.2], Sphere[]}, {Opacity[0.2], 
    Cuboid[{-2.1, -2.1, -.01}, {2.1, 2.1, 0}]}, {Line[{{0, 0, 1}, 
      f[pt], Append[pt, 0]}]}}, 
  PlotRange -> 2], {pt, {-2, -2}, {2, 2}}]

enter image description here

for a general line:

p = Plot[Sin[2 x], {x, 0, π}];
pts = Cases[p, Line[x__] :> x, ∞][[1]];
Graphics3D[{{Pink, Line[f /@ pts]}, {Opacity[0.2], Sphere[]}, {Black, 
   Line[pts /. {x_, y_} -> {x, y, 0}]}}]

enter image description here

for circle:

 Block[{cc, pts}, 
  cc = ParametricPlot[
    pt0 + {r0 Cos[θ], r0 Sin[θ]}, {θ, 0, 
     2 π}];
  pts = Cases[cc, Line[x__] :> x, ∞][[1]]; 
  Graphics3D[{{Pink, Line[f /@ pts]}, {Opacity[0.2], 
     Sphere[]}, {Black, Line[pts /. {x_, y_} -> {x, y, 0}]}}, 
   PlotRange -> 2.5]], {{pt0, {0, 0}}, {-2, -2}, {2, 2}}, {{r0, 0.2}, 
  0, 1}]

enter image description here

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.