{ } JustinGeoSci

Computational Geometry

Robust geometric computation, built on exact arithmetic.

Computational geometry rests on decisions rather than measurements. A polygon is valid or it is not, two boxes meet or they do not, a point lies inside a region, on its boundary or outside it. Floating-point arithmetic approximates every value it computes, and an approximation decides such questions correctly only when the configuration is far from the boundary between one answer and the other. Real data lives at that boundary: parcels share edges, roads end exactly on other roads, and coordinates repeat. There an approximate decision can contradict another one made a moment later, and the structure built on both inherits the contradiction without any error to reveal it.

The packages here decide every such question exactly. Each decision begins in ordinary floating-point arithmetic, alongside a proven bound on its error, and the answer stands only when the bound shows it cannot be wrong. When it can, the decision is recomputed in exact arithmetic, which costs more but answers every finite input correctly. Ordinary data rarely needs the second step, and the data that sits on a boundary always receives it. A result the packages cannot establish is refused rather than approximated, so a caller never builds on an answer that is only probably right.

The three packages form layers. arithmetica decides signs, situs filters candidates, and geometres decides geometric relationships exactly on both. Each comes with a user guide that documents every function, the numerical argument behind it, and worked examples that are compiled and run against the published release.