35 int bestDistance = std::numeric_limits<int>::max();
39 const VECTOR2I nearestSegPt = seg.NearestPoint( aPt );
40 const int thisDistance = nearestSegPt.
Distance( aPt );
42 if( thisDistance <= bestDistance )
44 nearest = nearestSegPt;
45 bestDistance = thisDistance;
59 [&](
const auto& geom )
61 using GeomType = std::decay_t<
decltype( geom )>;
63 if constexpr( std::is_same_v<GeomType, LINE> || std::is_same_v<GeomType, HALF_LINE>
64 || std::is_same_v<GeomType, SEG> || std::is_same_v<GeomType, CIRCLE>
65 || std::is_same_v<GeomType, SHAPE_ARC> || std::is_same_v<GeomType, SHAPE_ELLIPSE> )
69 nearest = geom.NearestPoint( aPt );
71 else if constexpr( std::is_same_v<GeomType, BOX2I> )
74 nearest = NearestPoint( geom, aPt );
76 else if constexpr( std::is_same_v<GeomType, VECTOR2I> )
93 int bestDistance = std::numeric_limits<int>::max();
98 const int thisDistance = thisNearest.
Distance( aPt );
100 if( !nearestPointOnAny || thisDistance < bestDistance )
102 nearestPointOnAny = thisNearest;
103 bestDistance = thisDistance;
107 return nearestPointOnAny;
double Distance(const VECTOR2< extended_type > &aVector) const
Compute the distance between two vectors.
std::array< SEG, 4 > BoxToSegs(const BOX2I &aBox)
Decompose a BOX2 into four segments.
VECTOR2I GetNearestPoint(const NEARABLE_GEOM &aGeom, const VECTOR2I &aPt)
Get the nearest point on a geometry to a given point.
std::variant< LINE, HALF_LINE, SEG, CIRCLE, SHAPE_ARC, SHAPE_ELLIPSE, BOX2I, VECTOR2I > NEARABLE_GEOM
A variant type that can hold any of the supported geometry types for nearest point calculations.
std::optional< VECTOR2I > OPT_VECTOR2I
Utility functions for working with shapes.
A type that is always false.
VECTOR2< int32_t > VECTOR2I