Skip to main content

PCURVE_REFINEMENT_TOLERANCE

Constant PCURVE_REFINEMENT_TOLERANCE 

Source
pub const PCURVE_REFINEMENT_TOLERANCE: f64 = 1e-7;
Expand description

The 3D residual a pcurve’s image must reach before build_pcurve_on_surface accepts it, and the sample ceiling it refines up to.

A trimmed face’s boundary is only ever as accurate as these two numbers, and every mass property is an integral over that boundary — so this is the floor under area, volume and centroid for every curved trim in the kernel.

These were min(1e-3, 1e-4 * scale) and 160, where scale is 1 + ||curve midpoint|| — the DISTANCE FROM THE WORLD ORIGIN of the curve’s midpoint, not the part’s size. That expression pinned to an absolute 1e-3 once the midpoint sat more than about nine units from the origin, so on an ordinary part the bar was 1e-3 and tracked nothing.

Measured on offset-shell-box-bore-dished-face, whose dished wall is a closed-form identity at 2468.431782123 (three independent routes agree). The floor is one of TWO errors there; the other is the refitted sphere carrier that sphere_offset_surface now builds in closed form, and before both moved they partly CANCELLED — which is why either alone reads as a regression:

floor     Box_O.S2            abs err     relative   gate total  worst case
1e-3   2468.442270355      +1.049e-02     4.25e-06        (old)
1e-6   2468.431785429      +3.306e-06     1.34e-09       181.4 s     31.2 s
1e-7   2468.431782170      +4.746e-08     1.92e-11       218.5 s     32.1 s
1e-9   2468.431782103      -2.037e-08    -8.25e-12       305.5 s     46.8 s

1e-7 is chosen: 70x the accuracy of 1e-6 for +20% gate time, where 1e-9 costs a further +40% for a 2.3x residual no oracle in this corpus could resolve. All four cells are one session on one binary, so the times are comparable to each other. Every case carrying a closed-form oracle moves TOWARD it and none away (PushFaceTest 339x, PushFaceTest2 275x); no case changes class at any floor.

A flat ABSOLUTE is what was measured, not what was designed. This codebase otherwise keys identity bands to part size (KernelTolerances::heal_band, the 1e-11*(1+scale) blend family), and on a 3000 mm part 1e-7 is 3e-11 relative — refinement will exhaust MAX_PCURVE_SAMPLES and return whatever it reached. Until 2026-09-12 it did so SILENTLY; now the fit’s PcurveFitReport carries the residual actually achieved and a PcurveFitExit::SampleCeiling exit, and the owning operation’s diagnostics count it (pcurve.unmet_floor). That is far better than the 1e-3 it replaces but it is not a size-aware bar; deriving one from the surface’s own extent is separate, unmeasured work. Being absolute does remove this gate’s dependence on distance from the origin as a side effect — a real translation-VARIANCE defect, the same anti-pattern tolerance::merge_scale records being removed elsewhere. drop_tolerance and endpoint_tolerance below still carry it.