ChordForm

type ChordForm

How the distance from a sample to a crater's center is computed.

2 − 2 cos θ out of one dot product is the cheap form and it is what every canonical rung uses. It cancels: at the ladder's finest canonical level θ is about 2 × 10⁻⁴ and the subtraction costs seven significant figures, which leaves the profile exact to nine and the height to a nanometer.

Three decades further down it is not fine. A one-meter crater on a 1,700 km body subtends 3 × 10⁻⁷, so 2 − 2 cos θ is 4 × 10⁻¹⁴ against a float64 ulp of 2 × 10⁻¹⁶ — half a percent of the value, which is a millimeter on the crater's own depth and, worse, a millimeter that differs between two patches that computed the same direction by different routes. A cube face's gnomonic extension gives the neighboring face's coordinate exactly in real arithmetic and to the last bit in floating point, and the ill-conditioned form turns that last bit into a visible-in-principle seam.

So the presentational tail asks for 'exact': the same number as the sum of squared component differences, where each difference is between two nearby floats and is therefore exact. It costs two divides and three subtractions a crater. The canonical ladder keeps 'fast' deliberately and not for the speed: changing it would move elevationAt in its last bits on every body, and the field the contact test integrates does not move outside a version bump.

'exact' also takes the sphere test in integers, and that is a second cancellation rather than a tidiness. A cell is walked when its nearest corner is inside the unit sphere and its farthest outside, and the corners are m/cells for integer m — so the test is Σ m² > cells², an integer against a float, and Σ (m/cells)² in float64 lands on either side of 1 by rounding whenever the two are equal. They are equal on every tail rung whose cells is a whole number — meanRadius / 8, / 4, / 2, / 1 over a published radius that is one, which is 46 of Sol's 128 tail-bearing bodies and every airless moon with a round radius — and an integer sphere has lattice points on it: hundreds of thousands at Luna's radius in cells, a crater in a million, each decided by which way a product rounded. The integer form decides them exactly, and it is what the GPU port evaluates, so the tail is the same tail on both processors. Measured against the float form over Sol: 167 of ~540k samples move, 0.63 m at most (Miranda), on the 17 bodies with such a rung and on none without. The canonical ladder cannot land there: its cells is meanRadius / (largestCrater / 2ᵏ) over a float largest crater, so cells² is never an integer and no corner sits on the sphere.

universe/src/craters.ts:265

Type

'fast' | 'exact'