# Stereographic Projections

Take the unit sphere in the three dimensional space. A plane through the half of the sphere perpendicular to the vertical axis.

Pick a point in the plane and draw the line which joins it with the north pole of the sphere. The intersection of this line with the sphere is the stereographic image of that point of the plane (this identifies each point in the plane with each point of the sphere except the north pole. "Stereographic image" is used in both directions. Context allow us to deduce if we go from the plane to the sphere or the other way around, at least as far as I've seen).

Just as in the figure:

Thinking in the plane as the complex plane, I'll refer to its points as ordered pairs (x,y). It will be nice to have some useful way to put images related with stereographic projections in our documents.

Particularly, I'm interested in:

• Given the coordinates (x,y) of a point in the plane, get the stereographic image on that point in the sphere, i.e. draw the point in the plane, draw the corresponding point in the sphere and optionally draw the line which joins (x,y) with the north pole.
• Given a circle in the plane (i.e. its center and its radius) get its stereographic image in the sphere, and optionally perhaps the lines which joins the north pole with two diametrically opposite points of the circle in the plane. This in order to "appreciate" the projection.

The last one can be hard, because depending on the point of view and of the circle, its spherical image might be seen as a segment which makes littles sense.

This is used in technical drawing, however I'm not aware of any package or TeX (that is tikz, pstricks, metapost,...) way of achieve this.

So my question is:

How can we achieve this?

Something like this?

``````size(250,250);
import solids;

projection Prj=orthographic(25,25,6,center=false);
currentprojection=Prj;

void Draw3(guide3 g,pen p=currentpen){
draw(g,p);
}

void FillDraw3(guide3 g,pen fillPen=currentpen, pen linePen=nullpen){
filldraw(project(g),fillPen,linePen);
}

real R=1;

triple O=(0,0,0);

guide3 circ(triple sh=O, real r){
guide3 uc=(r,0,0)..(0,r,0)..(-r,0,0)..(0,-r,0)..cycle;
return shift(sh)*uc;
}

guide3 semicirc(triple sh=O, real r){
guide3 uc=(r,0,0)..(0,r,0)..(-r,0,0);
return shift(sh)*uc;
}

guide3 Parallel(real h, real R){
return circ((0,0,h),sqrt(R^2-h^2));
}

pen dashed=linetype(new real[] {4,3}); // set up dashed pattern

pen dashCircPen=gray(0.4)+dashed+opacity(1)+0.32pt;
pen boldLine=darkblue+1.2pt;
pen floorCircPen=olive+opacity(0.75);
pen sphereSpotPen=blue+opacity(0.382);

Draw3(O--(0,0,R),boldLine);
Draw3(O--(R,0,0),boldLine);
Draw3(O--(0,R,0),boldLine);
Draw3(O--(-R,0,0),boldLine);
Draw3(O--(0,-R,0),boldLine);
Draw3(circ(R),boldLine);

real h=0;
real dphi=10;
real phi=dphi;
for(int i=1;i<9;++i){
h=R*Sin(phi);
Draw3(Parallel(h,R),dashCircPen);
phi+=dphi;
}

for(int i=0;i<6;++i){
Draw3(rotate(30*i,(0,0,1))*rotate(90,(1,0,0))*semicirc(R),dashCircPen);
}

triple P=(0,0,R);
triple A=(2R,0,0);
triple B=(0,1.5R,0);
triple sA,sB;

surface hs=scale(R,R,R)*unithemisphere;

guide3 lin;

lin=subpath(A--P,0.0,0.999);
triple[] p;
p=intersectionpoints(lin,hs);
Draw3(A--p[0],red);
Draw3(p[0]--P,blue+dashed);
sA=p[0];
dot(A);

lin=subpath(B--P,0.0,0.999);
p=intersectionpoints(lin,hs);

Draw3(B--p[0],red);
Draw3(p[0]--P,blue+dashed);
sB=p[0];

real r=0.2;
guide3 g=circ((A.x,A.y+r,0), r);

draw(g);

guide3 sphCirc(guide3 g, int n=100){
guide3 sphg;
triple[] p;
triple v;
guide3 lin;
for(int i=0;i<n;++i){
v=point(g,length(g)*i/(n-1));
lin=subpath(v--P,0.0,0.999);
p=intersectionpoints(lin,hs);
sphg=sphg--p[0];
}
sphg=sphg--cycle;
return (sphg);
}

draw(sphCirc(g),red+dashed);

g=B--(B.x+0.7R,B.y+0.3R,0)--(B.x-0.5R,B.y-0.5R,0)--cycle;

draw(g,orange);
draw(sphCirc(g),red);

dot(new triple[]{(0,0,0),A,sA,B,sB,P});

label("\$P\$",P,N);
label("\$A\$",A,NW);
label("\$B\$",B,SE);
label("\$A'\$",sA,NW);
label("\$B'\$",sB,NE);
``````

Compile this `s.asy` file with `asy -f pdf -noprc -render=0 s.asy` to get a standalone `s.pdf`.