r/cpp • u/parkotron • Apr 23 '26
Libraries for general purpose 2D/3D geometry vocabulary types?
I work in the geospatial industry and have worked on plenty of large projects that have their own internal geometry libraries. Some good, some bad, most with interesting historical choices. I recently joined a new project that hasn't yet really defined its vocabulary types yet, and I'm finding that extremely inconvenient, so I'm looking around at what is common
The kinds of things I'm looking for are:
Vector<typename T, size_t Dimension>: Basically astd::array<T,Dimension>with a vector-like APIPoint: A wrapper around aVectorwith point semanticsSize: A wrapper around aVectorwith size semanticsRange: A basic min/max intervalAxisAlignedBox: A set ofRanges in N dimensionsRotatedBox: AAxisAlignedBoxwith a basisVectorPolyline: Astd::vector<Point>assumed to be openPolygon: Astd::vector<Point>assumed to be closedMatrix: An NxM matrix- ...
I know there are plenty of vector/matrix/linear algebra libraries out there, often focused on flexibilty and raw computational performance. I'm more interested in nice vocabulary types that implement proper semantics via convenient methods and operators.
It seems these things are often provided by game engines, but pulling in an entire game engine for a non-gaming project feels silly.
So if you were starting a new, greenfield C++ application dealing with 3D geometric data, which existing library, if any, would you reach for?
View all comments
Show parent comment
10
u/parkotron Apr 23 '26
I've worked with
Boost.Geometrybefore. Its extreme flexibilty make it possible to employ its algorithms on lots of different types, but also makes it a poor choice for application-level vocabulary types, where I want simple, concrete behaviours.For example,
boost::geometry::model::d2::point_xyrecommendsget<1>(myPoint)overmyPoint.y(). I understand why it does that, but that's not the world I want to work in day-to-day.I could certainly build the types I want by wrapping
Boost.Geometryand have considered doing so, but am ideally looking for something higher-level and more opinionated out of the box. But thank you for the suggestion.