39 int bestDistance = std::numeric_limits<int>::max();
43 const VECTOR2I nearestSegPt = seg.NearestPoint( aPt );
44 const int thisDistance = nearestSegPt.
Distance( aPt );
46 if( thisDistance <= bestDistance )
48 nearest = nearestSegPt;
49 bestDistance = thisDistance;
63 [&](
const auto& geom )
65 using GeomType = std::decay_t<
decltype( geom )>;
67 if constexpr( std::is_same_v<GeomType, LINE>
68 || std::is_same_v<GeomType, HALF_LINE>
69 || std::is_same_v<GeomType, SEG>
70 || std::is_same_v<GeomType, CIRCLE>
71 || std::is_same_v<GeomType, SHAPE_ARC> )
75 nearest = geom.NearestPoint( aPt );
77 else if constexpr( std::is_same_v<GeomType, BOX2I> )
80 nearest = NearestPoint( geom, aPt );
82 else if constexpr( std::is_same_v<GeomType, VECTOR2I> )
99 int bestDistance = std::numeric_limits<int>::max();
104 const int thisDistance = thisNearest.
Distance( aPt );
106 if( !nearestPointOnAny || thisDistance < bestDistance )
108 nearestPointOnAny = thisNearest;
109 bestDistance = thisDistance;
113 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.