Skip to main content
14 of 15
Removed picture duplication

Mapping a cube to a sphere

I have been looking for a way to map a unit cube (with vertices $x^2=1$, $y^2=1$, $z^2=1$) to a unit sphere ($x^2+y^2+z^2=1$) with minimal distortion of the great circles formed by mapping the coordinate lines on the cube face. As can be seen from the following picture, a simple radial contraction onto the sphere surface leads to large visible distortion of the great circles.

Radial contraction onto sphere

Phil Nowell here derived an elegant mapping that generates a much more uniform subdivision of the great circles.

Nowell mapping

However, close inspection shows that there is still some room for improvement. Points near the center of the cube faces get more compressed than those near the edges.

By using the rotation of central planes to map points on the cube to equidistant points on the sphere, I was able to come up with the following expressions for an improved mapping: $$ \begin{cases} x_\text{sphere}=x_c/\sqrt{x_c^2+ y_c^2+ z_c^2}\\ y_\text{sphere}=y_c/\sqrt{x_c^2+ y_c^2 + z_c^2}\\ z_\text{sphere}=z_c/\sqrt{x_c^2+ y_c^2 + z_c^2} \end {cases} $$

where $$ \begin{cases} x_c=\sqrt{x^p+y^2+z^2} \tan\left(x \arctan\left(\dfrac1{\sqrt{x^p+y^2+z^2} } \right)\right)\\ y_c=\sqrt{x^2+y^p+z^2} \tan\left(y \arctan\left(\dfrac1{\sqrt{x^2+y^p+z^2} } \right)\right)\\ z_c=\sqrt{x^2+y^2+z^p} \tan\left(z\arctan\left(\dfrac1{\sqrt{x^2+y^2+z^p} } \right)\right) \end{cases} $$

  • $p$ is a large even integer and
  • $x$, $y$, $z$ are the coordinates of the cube.

The picture below is obtained with $p=50$

Improved mapping

To express the quality $Q$ of the mapping, I calculate the ratio of the maximum and minimum length of a line segment on the most distorted great circle, $i,$ as follows: $$ Q=\frac{\ell_{i,\min}}{\ell_{i,\max}} \cdot 100\% $$ so that an optimum distribution gives a quality of $100\%.$

With this, the quality of the radial contraction of the 9x9x9 grid depicted above becomes $58\%,$ that of Nowell’s mapping becomes $79\%$ and that of my improved mapping becomes $96\%.$ It is also worth noting that the quality on the central coordinate lines and the edges is $100\%.$

Now, my question is: “can my mapping be improved further to yield a quality of $100\%$ everywhere on the sphere?”

Update 1

The following iterative scheme gives a further improvement:

$x_{c,0} = x$, $y_{c,0} = y$, $z_{c,0} = z$

$\begin{gathered}x_{c,i+1}=\sqrt{x^{p}_{c,i}+y^{2}_{c,i}+z^{2}_{c,i}} tan(x\ arctan(\frac{1}{\sqrt{x^{p}_{c,i}+y^{2}_{c,i}+z^{2}_{c,i}} } ))\\ y_{c,i+1}=\sqrt{x^{2}_{c,i}+y^{p}_{c,i}+z^{2}_{c,i}} tan(y\ arctan(\frac{1}{\sqrt{x^{2}_{c,i}+y^{p}_{c,i}+z^{2}_{c,i}} } ))\\ z_{c,i+1}=\sqrt{x^{2}_{c,i}+y^{2}_{c,i}+z^{p}_{c,i}} tan(z\ arctan(\frac{1}{\sqrt{x^{2}_{c,i}+y^{2}_{c,i}+z^{p}_{c,i}} } ))\end{gathered} $

With this, the quality of the mapped 9x9x9 grid increases after 2 iterations from 96.1% to 97.7%

For finer grids the improvement is more pronounced. A 50x50x50 grid (with p=500) achieves an improvement from 95.3% to 97.1% after 1 iteration and a grid of 500x500x500 (with p=5000) shows an improvement from 95.2% to 97.0% with 1 iteration.