sphereql-core
Spherical math primitives for the sphereQL project.
This is the foundational crate. Every other crate in the workspace re-exports types from here, so changes to this surface ripple everywhere — keep them deliberate.
What's here
- Coordinate types —
SphericalPoint { r, theta, phi }(physics convention: theta in [0, 2π), phi in [0, π]),CartesianPoint,GeoPointfor lat/lon/alt input. - Distance metrics —
angular_distance(Vincenty, numerically stable across the antipodal seam), great-circle, chord, and a cosine-similarity helper that returnsResultso caller code handles zero vectors explicitly. - Interpolation —
slerp(spherical linear) andnlerp(normalized lerp) with an antipodal branch in slerp for numerically safe interpolation through the pole. - Region primitives —
Cone,Cap,Shell,Band,Wedge, plus booleanRegion::Intersection/Region::Union. All implement theContainstrait (containment test against aSphericalPoint). - Errors —
SphereQlErroris#[non_exhaustive]; new variants can be added without breaking downstreammatcharms.
Example
use ;
Versioning
Part of the sphereQL workspace, currently 0.3.0. Public API is
stable enough to ship against, but reserve the right to break on minor
bumps before 1.0. See the workspace
CHANGELOG.
Documentation
Crate-level rustdoc lives at the top of src/lib.rs. For algorithmic
detail and tradeoff discussion, see the workspace
architecture.md
and coordinate-system.md.