Skip to main content

Module sphere

Module sphere 

Source
Expand description

A sphere as exactly 8 octant faces: 2 rows (north pole to equator, and equator to south pole) x 4 quadrants, each an exact rational quarter of a hemisphere. No approximation — the surfaces are spheres, so a point sampled anywhere on one is exactly radius from the centre.

Built quadrant-column by quadrant-column rather than row by row, which is what makes the count come out at exactly 8. mef always leaves something behind on the face it split from, so a row-by-row construction ends with the starting placeholder still holding an extra, invisible zero-area cap at one pole. Going column-wise makes the last quadrant’s own closing land back on the placeholder itself, consuming it.

That matters beyond tidiness. A leftover placeholder carries NurbSurface::everything, whose every coordinate is ENTIRE, so it could_be_equals any point and silently swallows every containment and intersection query aimed at it; and a zero-area face has no interior point to classify, which is precisely what a boolean needs from every face. Both are asserted against in this module’s own tests.

Functions§

sphere_solid
A sphere of radius centered at center, built as exactly 8 real degree-(2, 2) quadrant faces (no leftover degenerate one) — one column (a north + a south quadrant) at a time, around 4 meridians: mvfs plus two mves bootstrap the very first meridian (pole -> equator -> pole, i.e. the profile, each half an exact 90-degree arc), then per remaining meridian, one mve grows the equator “beam” (also an exact arc) to it and two mefs close off that column’s north and south quadrant. The very last meridian is the first one again (its own closing mef’s new edge is the last beam) closing the loop, so its own closing needs only a single mef (the north quadrant) — the south one is already exactly the boundary still left on the placeholder face, which just needs replace_face to become real.