65 for(
int i = 0; i < 4; i++ )
67 SEG side( corners[i], corners[ i + 1] );
70 if( dist_sq < closest_dist_sq )
77 closest_dist_sq = dist_sq;
79 else if( aLocation && dist_sq == closest_dist_sq )
83 if( ( near - aSeg.
A ).SquaredEuclideanNorm()
84 < ( nearest - aSeg.
A ).SquaredEuclideanNorm() )
91 if( closest_dist_sq == 0 || closest_dist_sq <
SEG::Square( aClearance ) )
94 *aActual = sqrt( closest_dist_sq );
107 std::stringstream ss;
109 ss <<
"SHAPE_RECT( ";
ERROR_LOC
When approximating an arc or circle, should the error be placed on the outside or inside of the curve...
constexpr bool Contains(const Vec &aPoint) const
ecoord SquaredDistance(const SEG &aSeg) const
VECTOR2I::extended_type ecoord
const VECTOR2I NearestPoint(const VECTOR2I &aP) const
Compute a point on the segment (this) that is closest to point aP.
static SEG::ecoord Square(int a)
Represent a polyline containing arcs as well as line segments: A chain of connected line and/or arc s...
void SetClosed(bool aClosed)
Mark the line chain as closed (i.e.
void Append(int aX, int aY, bool aAllowDuplication=false)
Append a new point at the end of the line chain.
Represent a set of closed polygons.
SHAPE_LINE_CHAIN & Outline(int aIndex)
Return the reference to aIndex-th outline in the set.
int NewOutline()
Creates a new empty polygon in the set and returns its index.
void TransformToPolygon(SHAPE_POLY_SET &aBuffer, int aError, ERROR_LOC aErrorLoc) const override
Fills a SHAPE_POLY_SET with a polygon representation of this shape.
virtual const std::string Format(bool aCplusPlus=true) const override
bool Collide(const SHAPE *aShape, int aClearance, VECTOR2I *aMTV) const override
Check if the boundary of shape (this) lies closer to the shape aShape than aClearance,...
VECTOR2I m_p0
Top-left corner.
const BOX2I BBox(int aClearance=0) const override
Compute a bounding box of the shape, with a margin of aClearance a collision.
static constexpr extended_type ECOORD_MAX
VECTOR2< int32_t > VECTOR2I