>>63240>Nice one.Thanks!
>but how does it get that pseudo-cyllindrical shape?It comes from the particular ryfun passed to addfuns_x
>>63235
spherepoledip: () => Geometry.Sphere.addfuns_xnti (
vertices, normals, texcoords, indices,
0, 0, 0,
(a, b) => 0.7,
(a, b) => 0.2 + 1.0 * Math.sin (b * Math.PI / 64),
(a, b) => 0.7,
64, 0, 1, 64, 0, 1,
false, false
),
Sine, and therefore cosine as well, has the behavior that it changes the slowest at its minima and maxima of -/+1 and changes the fastest at its midpoints of 0. The sphere's parallels, the latitude circles, want to have slow change near the equator, where the latcos term that goes into nx and nz
>>63235 has its maximum of 1. But while normally the height would go monotonically from -radius at the south pole to +radius at the north pole, for the poledip demo the ryfun causes the same amount of parallels to be spent on the height starting above the minimum, going down to the minimum, then going all the way up to the maximum, then dipping below the maximum. So some of the parallels are spent on the polar dips, to go down to the minimum height and to come down from the maximum height. Therefore fewer parallels are available for the minimum to maximum middle phase. The result is that the middle phase is stretched out along the height. But this is precisely the zone where the radius of a parallel changes the slowest, at the vicinity of the equator. Taking the zone where the radius of a parallel changes the slowest and stretching that zone out vertically results in that pseudo-cylinder look.
Here is an alternative method of getting a cylinder-like sphere:
spherelatwaves: () => Geometry.Sphere.addfuns_xnti (
vertices, normals, texcoords, indices,
0, 0, 0,
(a, b) => 0.7 + 0.2 * Math.cos (2 * b * Math.PI / 64),
(a, b) => 0.9,
(a, b) => 0.7 + 0.2 * Math.cos (2 * b * Math.PI / 64),
64, 0, 1, 64, 0, 1,
false, false
),
Instead of taking the zone where the radius of a parallel changes the slowest and stretching that zone out vertically, you can leave the height (ryfun) alone and directly modify the radius of a parallel with a counterwave. Where the radius of a parallel has its maximum, at the equator, you put the minimum of your modifying wave, and where the radius of a parallel has its minima, at the poles, you put the maxima of your modifying wave. This results in a pseudo-cylinder without polar dips. With a real cylinder you would have to add separate end caps, but here the sphere provides the end caps for free.