Pangolin
Header-only C++20 plane computational geometry library
Loading...
Searching...
No Matches
distance.hpp File Reference

Distance and Hausdorff-style measurements between shapes. More...

#include "implementation/intersection.hpp"
#include "shape/convex.hpp"
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstddef>
#include <ranges>

Go to the source code of this file.

Namespaces

namespace  pgl

Macros

#define PGL_HPI_SQUARED_DISTANCE(ConceptName, ArgType)

Detailed Description

Distance and Hausdorff-style measurements between shapes.

Every squaredDistance / squaredHausdorffDistance overload is templated on a ResultNumber coordinate type that defaults to the calling shape's NumberType, mirroring the intersection API. Overloads whose closest point lies in a shape's interior divide by a squared length; with an integer ResultNumber that division truncates, so callers that need an accurate result must request a floating-point or pgl::Rational ResultNumber.

Macro Definition Documentation

◆ PGL_HPI_SQUARED_DISTANCE

#define PGL_HPI_SQUARED_DISTANCE ( ConceptName,
ArgType )
Value:
template <class PointType, class LabelType> \
template <class ResultNumber, ConceptName ArgType> \
constexpr auto HalfplaneIntersection<PointType, LabelType>::squaredDistance( \
const ArgType& other) const { \
if (intersects(other)) { \
return ResultNumber{}; \
} \
return detail::regionEdgesSquaredDistance<ResultNumber>(*this, other); \
}