Reconstruct a sphere from 6 patches

62 Views Asked by At

Let's say that I need to reconstruct a surface that could be cloned 6 times to create a perfect sphere.

It is sampled in some finite N elements per side so the patch will have NxN elements (vertex)

So I will iterate from -0.5 to 0.5 in XY axis being 0 0 the center of my patch.

Ideally I was about iterating like that

sphericalTheta = xpos * (pi / 2.0);
sphericalPhi = ypos * (pi / 2.0);

Being xpos and ypos the iterators over that -0.5 0.5 range

so I expected that this should work:

mX = cos(sphericalPhi) * sin(sphericalTheta);
mY = cos(sphericalPhi) * cos(sphericalTheta);
mZ = sin(sphericalPhi);

but obviously it didn't workFirst try

Seeing that result intuitively I notice that I should modify my iterators since -0.5 0.5 only works when the other coordinate in the pair is 0

newypos = ypos * cos(abs(xpos)* (pi / 3.0));
newxpos = xpos * cos(abs(ypos)* (pi / 3.0));
sphericalTheta = newxpos * (pi / 2.0);
sphericalPhi = newypos * (pi / 2.0);

Test 2

It gets better but still it has some overlaps.

Side note: this is NOT the same as Sphere parameterization with 6 patches

Thank you in advance.