![]() |
Pangolin
Header-only C++20 plane computational geometry library
|
Minkowski sums of two shapes, and the operator+ that spells them. More...
#include "implementation/transformations.hpp"#include <algorithm>#include <cstddef>#include <optional>#include <stdexcept>#include <type_traits>#include <utility>#include <vector>Go to the source code of this file.
Namespaces | |
| namespace | pgl |
Macros | |
| #define | PGL_DEFINE_MINKOWSKI_SUM(SHAPE) |
Functions | |
| template<class A, class B> requires MinkowskiSummableConcept<A, B> | |
| constexpr auto | pgl::operator+ (const A &a, const B &b) |
| Returns the Minkowski sum a ⊕ b, the same as a.minkowskiSum(b). | |
Minkowski sums of two shapes, and the operator+ that spells them.
The Minkowski sum of two shapes is the set
. It is a construction, so it lives here rather than in a shape header, and it is defined only for the pairs whose sum is representable by a Pangolin shape (pgl::MinkowskiSummableConcept):
Every vertex of the result is a sum of two input vertices, so the whole construction is exact in the operands' coordinate type: integers in, integers out. The one operand that is not on the lattice to begin with is a HalfplaneIntersection, whose vertices are line crossings; a sum with one is exact over pgl::division_result_t coordinates instead, the same type that shape's own accessors report a vertex in.
pgl::detail::minkowskiSumOf is the single dispatcher, and pgl::MinkowskiSummableConcept the single gate: widening the set of pairs whose sum is one shape means relaxing that concept and adding one branch to the dispatcher. Nothing else here, and no shape header, encodes which pairs are allowed.
The non-convex sums are not here, and are not a widening of that concept: a sum that can enclose a hole needs a PolygonWithHoles region result, so it needs a triangulation and the boolean engine and lives in implementation/minkowskisum.hpp, as an overload set on pgl::Polygon, pgl::PolygonWithHoles and pgl::Polyline over exactly the pairs this file turns away.
| #define PGL_DEFINE_MINKOWSKI_SUM | ( | SHAPE | ) |