<s>[INST] Can someone please explain the cube to sphere mapping formula to me? I am wondering if anyone could explain how the following formula works, it is supposed to take the input as a point on a cube then map that to points on a sphere, please go gentle on me, I'm in 9th grade O_O
$$\begin{bmatrix}x' \\ y' \\ z'\end{bmatrix}=\begin{bmatrix} x\sqrt{1-\frac{y^2}{2}-\frac{z^2}{2}+\frac{y^2z^2}{3}} \\ y\sqrt{1-\frac{z^2}{2}-\frac{x^2}{2}+\frac{z^2x^2}{3}} \\ z\sqrt{1-\frac{x^2}{2}-\frac{y^2}{2}+\frac{x^2y^2}{3}} \end{bmatrix}$$
Thanks.
 [/INST] Thanks for the explanation by joriki. The above formula has been explained in 1. But the formula has some limitations. The cube length can be 2 (-1 to 1 in all directions). From the above concept, mentioned by joriki or 1 we can generalize for the cube of any length (i.e 2a (-a to a in all directions)). Here 2a is the side length of the cube.
$a^6-(a^2-x^2 )(a^2-y^2)(a^2-z^2)=x^2 a^2 (a^2-\frac{z^2}{2}-\frac{y^2}{2}+\frac{y^2 z^2}{3a^2})+y^2 a^2 (a^2-\frac{z^2}{2}-\frac{x^2}{2}+\frac{x^2 z^2}{3a^2})+z^2 a^2 (a^2-\frac{x^2}{2}-\frac{y^2}{2}+\frac{y^2 x^2}{3a^2})$
So,
$x'=xa \sqrt{a^2-\frac{z^2}{2}-\frac{y^2}{2}+\frac{y^2 z^2}{3a^2}}$,
$y'=ya \sqrt{a^2-\frac{z^2}{2}-\frac{x^2}{2}+\frac{x^2 z^2}{3a^2}}$,
$z'=za \sqrt{a^2-\frac{x^2}{2}-\frac{y^2}{2}+\frac{y^2 x^2}{3a^2}}$.
From the above equation, we can easily separate the (x',y',z') as explained in 1. The above equation will readily find the mapping of the generalized length of the cube to a sphere. I hope this will be helpful.
Form the above equation we can also find the evenly distribution of points within the sphere by varying the grid size of the cube. By discretizing the cube into different grids and simultaneously mapping into the sphere will give the evenly distribution of points within the sphere.
Kindly ignore some typos.
</s>