Skip to main content

Module centroid

Module centroid 

Source
Expand description

centroid(&g) — the geometric centre of g.

Mirrors boost::geometry::centroid(g, p) from boost/geometry/algorithms/centroid.hpp — except Boost returns through an out-parameter while Rust returns the point by value. Per geometry kind (all Cartesian in LA6; spherical / geographic siblings land in LA8):

The per-kind strategy is selected type-level via [geometry_strategy::CentroidStrategyForKind], a tag-keyed picker that routes G::Kind to the right per-kind strategy struct. Because it keys on the tag, any concept-adapted foreign type resolves through the same path as the equivalent geometry-model value. centroid_with takes an explicit strategy.

§Spherical / geographic centroid — deferred (LA8.T3)

Unlike length / area / azimuth — whose LA8 free functions dispatch by coordinate-system family — centroid stays Cartesian. Boost ships no validated spherical / geographic centroid reference values, so shipping that math would be unverifiable; see the deferral note on [geometry_strategy::CentroidStrategyForKind]. A spherical or geographic geometry is therefore a compile error here; use centroid_with with an explicit strategy in the meantime.

Functions§

centroid
Centroid of g using the per-kind Cartesian strategy.
centroid_with
Centroid of g using an explicitly supplied strategy.