DEV Community

Cover image for Stereographic equations
ccarcaci
ccarcaci

Posted on

Stereographic equations

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=xR3:x12+x22+x32=1x=(x1,x2,x3)SN=(0,0,1) North poleSf(S)R2yR2,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} \\

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_3 :

x1 x3 plan

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

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

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

m=N3y3N1y1=100y1=1y1 m=\frac{N_3-y_3}{N_1-y_1}=\frac{1-0}{0-y_1}=-\frac{1}{y_1}

The same reasoning could be done with the plane x2x3x_2x_3 :

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

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

x3=x1y1+1    y1=x11x3x3=x2y2+1    y2=x21x3 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} \\

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} .

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

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

x1 x2 plan

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

r:x3=x1y1+1 \vec{r}: x_3=-\frac{x_1}{y_1}+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 \\

The equation for SS 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

Then:

x12+y22y12x12+x12y122x1y1+1=1x12+y22y12x12+x12y122x1y1=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 \\

This equation has 2 solutions:

first: x1=0second: x1+y22y12x1+x1y122y1=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}

The same is valid for x2x_2 :

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

Last, x3x_3 is:

x3=x1y1+1x3=1y1(2y1y12+y22+1)+1x3=12y12+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} \\

Top comments (0)