# Mapping from ball into cube

I need to give an example of continuous mapping from ball into cube (with condition that boundary is an image of boundary), but unfortunately I can't come up with it. Any useful advice will be welcome.

• What do you mean by "borders"? Aug 12, 2013 at 11:47
• Try to picture a "distortion" that turn your ball into a cube. In particular it seems enough that the image of any point $x$ is always on the line $(Ox)$. Aug 12, 2013 at 11:49
• I expressed incorrectly, bounds
– cool
Aug 12, 2013 at 11:50
• Actually, I think the word you're looking for is "boundary". Aug 12, 2013 at 11:52
• @dkuper Thanks, I thought about it, but I would like to ask one more question: is there an explicit formula of distortion?
– cool
Aug 12, 2013 at 11:53

A systematic approach would be to decide to scale each ray through the origin by a linear factor that moves the ray's intersection with the unit sphere into the intersection with the "double-unit" cube.

For a nonzero point $(x,y,z)$, the intersection with the unit cube is $$\frac{1}{\max\{|x|,|y|,|z|\}}(x,y,z)$$ and in order to make points inside the sphere map to being inside the cube, we need to scale this by their initial euclidean norms, so we get the transformation:

$$(x,y,z) \mapsto \begin{cases} (0,0,0) & x=y=z=0 \\[1ex] \frac{\sqrt{x^2+y^2+z^2}}{\max\{|x|,|y|,|z|\}}(x,y,z) & \text{otherwise} \end{cases}$$

One easily checks that the scaling factor $\frac{\sqrt{x^2+y^2+z^2}}{\max\{|x|,|y|,|z|\}}$ is the same everywhere on a ray.

This gives you the cube $[-1,1]^3$. If you want to end up with the usual unit cube $[0,1]^3$, apply the obvious affine transform afterwards.

• Going from sphere to cube is a lot easier than going the other way. I should've seen that. Aug 12, 2013 at 12:09
• @Arthur: It's actually much the same -- just interchange the roles of the max-norm and the euclidean norm throughout. Aug 12, 2013 at 12:12

For a point $x \neq \vec 0$ in a cube centered in the origin, let $d(x)$ be the distance from the origin through $x$ to the boundary of the cube. Then the function defined as $f(x) = \frac{x}{d(x)}$ will map the cube to the unit sphere (with the addition that $f(\vec{0}) = \vec{0}$).

Giving an explicit formula is as easy as finding an explicit formula for $d$. While that can be done, it requires quite some work with the Pythagorean theorem and breaking into cases depending on which face of the cube the line through the origin and $x$ intersects.

Edit: After a short discussion with @HenningMakholm, and reading his answer thouroghly, it turns out that for a non-zero vector $(x, y, z)$, the function $d$ is given by $$d(x, y, z) = \frac{\sqrt{x^2 + y^2 + z^2}}{\max\{|x|, |y|, |z|\}}$$ This is still in a sense breaking into cases, depending on which coordinate is largest in magnitude, but it was easier formulated than I initially feared going into this question.

• The great benefit of using the max function instead of an explicit case analysis is that we already know that max is continuous, which makes it much easier to argue that the entire transformation is continuous. Aug 12, 2013 at 18:23

The goal is to turn your ball into a cube by a continuous mapping. We can do it for borders, and hope that it will naturally extend to the whole plain ball.

So the equation of the border of the unit ball is $x^2+y^2+z^2=1$. Whereas for the unit cube, you want $x=1$ or $y=1$ or $z=1$.

First of all, points $(1,0,0)$, $(0,1,0)$ and $(0,0,1)$ must be left unchanged.

On the other extreme, points $(\sqrt{1/3},\sqrt{1/3},\sqrt{1/3})$ must be send on $(1,1,1)$.

Globally, if you have a point $X$ on the unit sphere, you send it to the intersection between the semi-line $[0X)$ and the cube. For points inside the sphere, you do it proportionnally: if your line $[OX)$ encounters the sphere at $A$ and the cube at $B$, you choose the image $X'$ such that $\frac{OX}{OA}=\frac{OX'}{OB}$.

It is not hard to verify that this mapping is continuous.