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>
64 || std::is_same_v<GeomType, HALF_LINE>
65 || std::is_same_v<GeomType, SEG>
66 || std::is_same_v<GeomType, CIRCLE>
67 || std::is_same_v<GeomType, SHAPE_ARC> )
71 nearest = geom.NearestPoint( aPt );
73 else if constexpr( std::is_same_v<GeomType, BOX2I> )
76 nearest = NearestPoint( geom, aPt );
78 else if constexpr( std::is_same_v<GeomType, VECTOR2I> )
95 int bestDistance = std::numeric_limits<int>::max();
100 const int thisDistance = thisNearest.
Distance( aPt );
102 if( !nearestPointOnAny || thisDistance < bestDistance )
104 nearestPointOnAny = thisNearest;
105 bestDistance = thisDistance;
109 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, 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