Stereographic equations



This content originally appeared on DEV Community and was authored by ccarcaci

This article is the first of a series that treat math topics.

I’ve decided to write some articles reporting interesting exercises and demonstrations that are difficult to find in the web.

The stereographic equations demonstration in this article is a good example. For example, the Wikipedia page about Stereographic projection doesn’t report the step-by-step process.

I’m quite positive that such demonstration could be found in math books.

Author background

My background on math is limited to what I did during my computer science degree. I’m not an expert, and I’m not an expert on graphical projection.

So, any comment, suggestion, error catch is welcome and encouraged.

The problem

3d view

The context is described in the image above. A sphere has its center in the axis origin. The horizontal plane including the origin offers the projecting surface. The projection is made by the function that associates a point onto the sphere with a point on the plane that is the result of the intersection between the plane and the segment between the North pole and the point into the sphere.

In formula:

S=x‾∈R3:x12+x22+x32=1x‾=(x1,x2,x3)∈SN=(0,0,1) North pole∈Sf(S)→R2y‾∈R2,y‾=(y1,y2),f(x‾)=y‾ S = {\underline{x}\in\mathbb{R}^3 : x_1^2+x_2^2+x_3^2=1 } \\ \underline{x}=(x_1,x_2,x_3)\in S \\ N=(0,0,1) \text{ North pole}\in S \\ f(S)\to\mathbb{R}^2 \\ \underline{y}\in\mathbb{R}^2, \underline{y}=(y_1,y_2), f(\underline{x})=\underline{y} \\ S=xR3:x12+x22+x32=1x=(x1,x2,x3)SN=(0,0,1) North poleSf(S)R2yR2,y=(y1,y2),f(x)=y

For the sake of making the math simple, the sphere is the unit radius sphere and is centered in the origin.

Considering the perspective of plane Considering the perspective of plane x1x3x_1x_3x1x3 :

x1 x3 plan

Knowing the coordinates of one point in the sphere x‾\underline{x}x and knowing that y‾\underline{y}y will be on the segment r⃗\vec{r}r connecting x‾\underline{x}x and NNN , it is possible to write the following formulas:

r⃗:x3=−x1y1+1 \vec{r}: x_3=-\frac{x_1}{y_1}+1 r:x3=y1x1+1

The reason is simple, the segment linking underlinexunderline{x}underlinex and r⃗\vec{r}r intersect x3x_3x3 axis in NNN where q=1q=1q=1 and the angular coefficient is:

m=N3−y3N1−y1=1−00−y1=−1y1 m=\frac{N_3-y_3}{N_1-y_1}=\frac{1-0}{0-y_1}=-\frac{1}{y_1} m=N1y1N3y3=0y110=y11

The same reasoning could be done with the plane x2x3x_2x_3x2x3 :

t⃗:x3=−x2y2+1 \vec{t}: x_3=-\frac{x_2}{y_2}+1 t:x3=y2x2+1

Now, the goal is to find the coordinates of y‾\underline{y}y , and this could be done by reversing the r⃗\vec{r}r and t⃗\vec{t}t formulas:

x3=−x1y1+1  ⟹  y1=x11−x3x3=−x2y2+1  ⟹  y2=x21−x3 x_3=-\frac{x_1}{y_1}+1\implies y_1=\frac{x_1}{1-x_3} \\ x_3=-\frac{x_2}{y_2}+1\implies y_2=\frac{x_2}{1-x_3} \\ x3=y1x1+1y1=1x3x1x3=y2x2+1y2=1x3x2

Inverse formula

Now, the challenge begin, find the inverse formula of this projection.

In word: given a point in the plane, find the point on the sphere.

In world: given a point in a map, find the real point in the world.

To find the inverse formula the sphere formula is needed, alongside the equations that represents the segment linking the North pole to the point in the map y‾\underline{y}y .

By looking the plane x1x2x_1x_2x1x2 the North pole is projected over the origin and the equation that connect the North pole with y‾\underline{y}y is:

v⃗:x2=y2y1x1 \vec{v}: x_2=\frac{y_2}{y_1}x_1 v:x2=y1y2x1

x1 x2 plan

By looking the plane x1x3x_1x_3x1x3 the segment connecting the North pole with y‾\underline{y}y has equation:

r⃗:x3=−x1y1+1 \vec{r}: x_3=-\frac{x_1}{y_1}+1 r:x3=y1x1+1

The work evolves around the equations:

v⃗:x2=y2y1x1r⃗:x3=−x1y1+1S:x12+x22+x32=1 \vec{v}: x_2=\frac{y_2}{y_1}x_1 \\ \vec{r}: x_3=-\frac{x_1}{y_1}+1 \\ S: x_1^2+x_2^2+x_3^2=1 \\ v:x2=y1y2x1r:x3=y1x1+1S:x12+x22+x32=1

The equation for SSS could be rewritten as:

x12+(y2y1x1)2+(−x1y1+1)2=1 x_1^2+(\frac{y_2}{y_1}x_1)^2+(-\frac{x_1}{y_1}+1)^2=1 x12+(y1y2x1)2+(y1x1+1)2=1

Then:

x12+y22y12x12+x12y12−2x1y1+1=1×12+y22y12x12+x12y12−2x1y1=0 x_1^2+\frac{y_2^2}{y_1^2}x_1^2+\frac{x_1^2}{y_1^2}-2\frac{x_1}{y_1}+1=1 \\ x_1^2+\frac{y_2^2}{y_1^2}x_1^2+\frac{x_1^2}{y_1^2}-2\frac{x_1}{y_1}=0 \\ x12+y12y22x12+y12x122y1x1+1=1x12+y12y22x12+y12x122y1x1=0

This equation has 2 solutions:

first: x1=0second: x1+y22y12x1+x1y12−2y1=0x1(1+y22y12+1y12)=2y1x1(y12+y22+1y12)=2y1x1=2y1y12+y22+1 \begin{align} \text{first: }&x_1=0 \\ \text{second: }&x_1+\frac{y_2^2}{y_1^2}x_1+\frac{x_1}{y_1^2}-\frac{2}{y_1}=0 \\ &x_1(1+\frac{y_2^2}{y_1^2}+\frac{1}{y_1^2})=\frac{2}{y_1} \\ &x_1(\frac{y_1^2+y_2^2+1}{y_1^2})=\frac{2}{y_1} \\ &x_1=\frac{2y_1}{y_1^2+y_2^2+1} \\ \end{align} first: second: x1=0x1+y12y22x1+y12x1y12=0x1(1+y12y22+y121)=y12x1(y12y12+y22+1)=y12x1=y12+y22+12y1

The same is valid for x2x_2x2 :

x2=2y2y12+y22+1 x_2=\frac{2y_2}{y_1^2+y_2^2+1} x2=y12+y22+12y2

Last, x3x_3x3 is:

x3=−x1y1+1×3=−1y1(2y1y12+y22+1)+1×3=1−2y12+y22+1 x_3=-\frac{x_1}{y_1}+1 \\ x_3=-\frac{1}{y_1}(\frac{2y_1}{y_1^2+y_2^2+1})+1 \\ x_3=1-\frac{2}{y_1^2+y_2^2+1} \\ x3=y1x1+1x3=y11(y12+y22+12y1)+1x3=1y12+y22+12


This content originally appeared on DEV Community and was authored by ccarcaci