How do you turn a cube into a sphere?
Posted
by
Tom Dalling
on Game Development
See other posts from Game Development
or by Tom Dalling
Published on 2012-11-14T09:12:44Z
Indexed on
2012/11/14
11:19 UTC
Read the original article
Hit count: 370
I'm trying to make a quad sphere based on an article, which shows results like this:
I can generate a cube correctly:
But when I convert all the points according to this formula (from the page linked above):
x = x * sqrtf(1.0 - (y*y/2.0) - (z*z/2.0) + (y*y*z*z/3.0));
y = y * sqrtf(1.0 - (z*z/2.0) - (x*x/2.0) + (z*z*x*x/3.0));
z = z * sqrtf(1.0 - (x*x/2.0) - (y*y/2.0) + (x*x*y*y/3.0));
My sphere looks like this:
As you can see, the edges of the cube still poke out too far. The cube ranges from -1
to +1
on all axes, like the article says.
Any ideas what is wrong?
© Game Development or respective owner