Wednesday, July 06, 2005

Mapping a Cube to a Sphere

After the last post, I got to thinking about how to come up with a mapping from the cube

img1

to the points in the unit sphere. In the last post I used the mapping

img2

Taking the length of the new point gives

img3

So you can see that if x or y are either -1 or +1, this yeilds a vector with unit length. So, beginning with this, I decided that I'd work backward from the guess that if I had a mapping from the cube to the unit sphere, the length of a generated point would need to be

img4

Which leads to the mapping

img5

Trying this out yields some pretty nice results. This is the cube and its mapping onto the unit sphere. The thick lines are lines where at least two of the components are -1 or +1.

cubesphere

And here's another view from inside the sphere

sphereInside

Sorry this post is a little light on justification. I might try to explain this by looking at the level curves defined by constant x, y and z, but I'll save that for another day (maybe).

4 Comments:

afp763389 said...

very interesting

... :)

Kappa said...

wow, didn't sphere mapping could be done that way. Sw33t!!!!

Anonymous said...

Nice, but an inverse transform would be nice. How do you take coordinates on the sphere and transform them to coordinates on the cube?

I've been working on it for a few minutes, but the algebra gets a little messy ;)

Daniel said...

That is very elegant - I like it!