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

Witnesses for squaredDistance: which elements realize it, and where. More...

#include "implementation/distance.hpp"
#include <array>
#include <cstddef>
#include <optional>
#include <type_traits>
#include <variant>
#include <utility>

Go to the source code of this file.

Namespaces

namespace  pgl

Detailed Description

Witnesses for squaredDistance: which elements realize it, and where.

closestSegments names the pair of elements — one edge of each shape, degenerate to a vertex where the shape has no edge — whose distance is the distance between the shapes. closestPoints refines that pair to the two points themselves, whose coordinates need a ResultNumber that survives a division. Both answer nothing exactly when squaredDistance is zero.

closestSegments needs both operands to be BoundedPolygonalConcept — the shapes covered by finitely many segments with exact endpoints — because an unbounded operand realizes the distance at a point that is on no edge and at no vertex, so there is no element to name. closestPoints has no such trouble and also accepts an UnboundedConvexConcept operand on one side, working against its boundary pieces. A Disk is out of both: its nearest point is irrational.