3D Plots of charts, vector fields and curves on $\mathbb{S}^2$¶

This worksheet is based on SageMath 7.5.beta4 and the three.js viewer developed at trac #12402.

NB: a version of SageMath at least equal to 7.5.beta4 is required:

In [1]:
version()

Out[1]:
'SageMath version 7.5.beta4, Release Date: 2016-11-24'

First we set up the notebook to display mathematical objects using LaTeX formatting:

In [2]:
%display latex


We also define a viewer for 3D plots (use 'threejs' or 'jmol' for interactive 3D graphics):

In [3]:
viewer3D = 'threejs' # must be 'jmol', 'tachyon', 'threejs' or None (default)


$\mathbb{S}^2$ as a 2-dimensional differentiable manifold¶

We declare $\mathbb{S}^2$ as a differentiable manifold of dimension 2 over $\mathbb{R}$ and we endow it with the stereographic charts from the North pole (stereoN) and the South pole (stereoS):

In [4]:
S2 = Manifold(2, 'S^2', latex_name=r'\mathbb{S}^2', start_index=1)
U = S2.open_subset('U')
V = S2.open_subset('V')
S2.declare_union(U, V)
stereoN.<x,y> = U.chart()
stereoS.<xp,yp> = V.chart(r"xp:x' yp:y'")
stereoN_to_S = stereoN.transition_map(stereoS, (x/(x^2+y^2), y/(x^2+y^2)),
intersection_name='W',
restrictions1= x^2+y^2!=0,
restrictions2= xp^2+xp^2!=0)
stereoS_to_N = stereoN_to_S.inverse()
W = U.intersection(V)
eU = stereoN.frame()
eV = stereoS.frame()
S2.frames()

Out[4]:

Spherical coordinates

The standard spherical (or polar) coordinates $(\theta,\phi)$ are defined on the open domain $A\subset W \subset \mathbb{S}^2$ that is the complement of the "origin meridian"; since the latter is the half-circle defined by $y=0$ and $x\geq 0$, we declare:

In [5]:
A = W.open_subset('A', coord_def={stereoN.restrict(W): (y!=0, x<0),
stereoS.restrict(W): (yp!=0, xp<0)})
spher.<th,ph> = A.chart(r'th:(0,pi):\theta ph:(0,2*pi):\phi')
spher_to_stereoN = spher.transition_map(stereoN.restrict(A),
(sin(th)*cos(ph)/(1-cos(th)),
sin(th)*sin(ph)/(1-cos(th))) )
spher_to_stereoN.set_inverse(2*atan(1/sqrt(x^2+y^2)), atan2(-y,-x)+pi)
spher_to_stereoN.display()

Out[5]:

Embedding of $\mathbb{S}^2$ into $\mathbb{R}^3$¶

Let us first declare $\mathbb{R}^3$ as a 3-dimensional manifold covered by a single chart (Cartesian coordinates):

In [6]:
R3 = Manifold(3, 'R^3', r'\mathbb{R}^3', start_index=1)
cart.<X,Y,Z> = R3.chart() ; cart

Out[6]:

The embedding of the sphere is defined as a differential mapping $\Phi: \mathbb{S}^2 \rightarrow \mathbb{R}^3$:

In [7]:
Phi = S2.diff_map(R3, {(stereoN, cart): [2*x/(1+x^2+y^2), 2*y/(1+x^2+y^2),
(x^2+y^2-1)/(1+x^2+y^2)],
(stereoS, cart): [2*xp/(1+xp^2+yp^2), 2*yp/(1+xp^2+yp^2),
(1-xp^2-yp^2)/(1+xp^2+yp^2)]},
name='Phi', latex_name=r'\Phi')

In [8]:
Phi.expr(stereoN.restrict(A), cart)
Phi.display()

Out[8]:

3D plots of coordinate charts on $\mathbb{S}^2$¶

Let us use $\Phi$ to draw the grid of spherical coordinates $(\theta,\phi)$ in terms of the Cartesian coordinates $(X,Y,Z)$ of $\mathbb{R}^3$:

In [9]:
graph_spher = spher.plot(chart=cart, mapping=Phi, number_values=11, color='blue',
label_axes=False)

In [10]:
show(graph_spher, viewer=viewer3D)


We may also use the embedding $\Phi$ to display the stereographic coordinate grid in terms of the Cartesian coordinates in $\mathbb{R}^3$. First for the stereographic coordinates from the North pole:

In [11]:
graph_stereoN = stereoN.plot(chart=cart, mapping=Phi, number_values=25,
label_axes=False)
show(graph_stereoN, viewer=viewer3D)


and then have a view with the stereographic coordinates from the South pole superposed (in green):

In [12]:
graph_stereoS = stereoS.plot(chart=cart, mapping=Phi, number_values=25,
color='green', label_axes=False)
show(graph_stereoN + graph_stereoS, viewer=viewer3D)


Let us add the North and South poles to the graphic:

In [13]:
N = V.point((0,0), chart=stereoS, name='N')
S = U.point((0,0), chart=stereoN, name='S')
graph_N = N.plot(chart=cart, mapping=Phi, color='red', label_offset=0.05)
graph_S = S.plot(chart=cart, mapping=Phi, color='green', label_offset=0.05)
show(graph_stereoN + graph_stereoS + graph_N + graph_S, viewer=viewer3D)