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):
Polygon→geometry_strategy::CartesianPolygonCentroidRing→geometry_strategy::CartesianRingCentroidLinestring→geometry_strategy::CartesianLinestringCentroidSegment→geometry_strategy::CartesianSegmentCentroidBox→geometry_strategy::CartesianBoxCentroidMultiPoint→geometry_strategy::CartesianMultiPointCentroid
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
gusing the per-kind Cartesian strategy. - centroid_
with - Centroid of
gusing an explicitly supplied strategy.