Stereographic projection
\[\sigma: \mathbb{R}^n \to S^n \setminus \{\mathbf{n}\}\]
where
\[\mathbf{n}=(0,\ldots,0,1)\in\mathbb{R}^{n+1}\]
is the northpole of $S^n$ is a special case of an inversion: Let us consider the hypersphere $S\subset\mathbb{R}^{n+1}$ with center $\mathbf{n}$ and radius $r=\sqrt{2}$ and look at the image of
\[\mathbb{R}^n =\left\{\mathbf{x}\in\mathbb{R}^{n+1}\,{\large |}\, x_{n+1}=0\right\}\]
under the inversion $g$ in $S$. The points in the image $g(\mathbb{R}^n)$ satisfy
\begin{align*}0&=\left\langle \mathbf{n},\mathbf{n}+2\,\frac{\!\!\!\mathbf{x}-\mathbf{n}}{|\mathbf{x}-\mathbf{n}|^2}\right\rangle\\\\&=\frac{|\mathbf{x}|^2-1}{|\mathbf{x}|^2+1}\end{align*}
And therefore lie on the unit sphere $S^n$. With the notation $\sigma:=\left.g\right|_{\mathbb{R}^n}$ we obtain
\[\sigma(\mathbf{x})=\frac{2\mathbf{x}+(|\mathbf{x}|^2-1)\mathbf{n}}{|\mathbf{x}|^2+1}.\]
Let us compute also $\sigma^{-1}=\left.g\right|_{S^n \setminus \{\mathbf{n}\}}$. For $\mathbf{x} \in S^n \setminus \{\mathbf{n}\}$ we have
\[\sigma^{-1}(\mathbf{x})=\frac{\mathbf{x}-\langle \mathbf{n},\mathbf{x}\rangle \mathbf{n}}{1-\langle \mathbf{n},\mathbf{x}\rangle}.\]
Note that we have
\[\sigma(\mathbf{x})=\lambda \mathbf{x}+\mu \mathbf{n}\]
with $\lambda+\mu=1$. This means that $\mathbf{n}$, $\mathbf{x}$ and $\sigma(\mathbf{x})$ always lie on a straight line. This accounts for the fact that $\sigma$ is called a projection with the north pole as its center. There is a beautiful video by Henry Segerman that illustrates stereographic projection by placing an LED at the north pole of a 3D-printed sphere and watching the shadow on a horizontal plane.
Here the plane on which $\sigma$ is defined touches the sphere, whereas in our case it cuts the sphere in the equator. This is of course irrelevant. Here is another video with more patterns.