效果图
sphereical-projection.png
完整代码
\starttext
\startMPcode
u:=10pt;
w:=35u;
h:=20u;
path pat[], pp;
pair t[];
begingroup
save p,plists;
def drawpaths(text plists)=
for p=plists:
pickup defaultpen;
pickup pencircle scaled 1pt;
draw(pat[p]);
pickup defaultpen;
endfor;
enddef;
endgroup;
pat[1]=fullcircle scaled 20u;
pat[2]=halfcircle xscaled 20u yscaled 10u;
pat[3]=pat[2] rotated 180;
z0=(-12u, 6u);
z1=right*w;
z2=dir(-135)*h;
z3=z1+z2;
pat[4]=(origin--z1--z3--z2--cycle) shifted z0;
z4=point 0 of pat[1];
pat[5]=subpath(0,1) of pat[4];
z5=pat[5] intersectionpoint pat[1];
t[5]=pat[5] intersectiontimes pat[1];
z6=pat[5] intersectionpoint reverse pat[1];
pat[6]=subpath(2,3) of pat[4];
z7=pat[6] intersectionpoint pat[1];
t[7]=pat[6] intersectiontimes pat[1]+(2,0);
z8=pat[6] intersectionpoint reverse pat[1];
t[8]=pat[6] intersectiontimes reverse pat[1]+(2,0);
%dotlabels(5,6,7,8);
pat[7]=z0--z6;
pat[8]=subpath(xpart(t[5]),4) of pat[4];
pat[9]=subpath(0,4) of pat[1];
pat[10]=subpath(4, ypart(t[7])) of pat[1];
pat[11]=subpath(8-ypart(t[8]),8) of pat[1];
pat[12]=subpath(ypart(t[7]),8-ypart(t[8])) of pat[1];
z9=point 2 of pat[1];
z10=(-13u,-4u);
%dotlabels(10);
z11=.45[z10,z9];
pat[13]=z10--z11;
pat[14]=z11--z9;
drawpaths(3,7,8,9,12,13);
pickup pencircle scaled 1pt;
draw pat[2] dashed evenly;
draw pat[10] dashed evenly;
draw pat[11] dashed evenly;
draw z5--z6 dashed evenly;
draw pat[14] dashed evenly;
pickup pencircle scaled 3pt;
dotlabel.rt(btex $O$ etex, origin);
dotlabel.bot(btex $P=(x,y)$ etex, z10);
dotlabel.lrt(btex $P^\prime$ etex, z11);
label.top(btex $N$ etex, z9);
label.urt(btex $S^2$ etex, point 1.5 of pat[1]);
%for i=0 upto 8:
% drawdot(point i of pat[1]);
%endfor;
\stopMPcode
\stoptext