66 for(
int i = 0; i < 4; i++ )
68 SEG side( corners[i], corners[ i + 1] );
71 if( dist_sq < closest_dist_sq )
78 closest_dist_sq = dist_sq;
80 else if( aLocation && dist_sq == closest_dist_sq )
84 if( ( near - aSeg.
A ).SquaredEuclideanNorm()
85 < ( nearest - aSeg.
A ).SquaredEuclideanNorm() )
92 if( closest_dist_sq == 0 || closest_dist_sq <
SEG::Square( aClearance ) )
95 *aActual = sqrt( closest_dist_sq );
108 std::stringstream ss;
110 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
A round rectangle shape, based on a rectangle and a radius.
void TransformToPolygon(SHAPE_POLY_SET &aBuffer) const
Get the polygonal representation of the roundrect.
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 SHAPE_LINE_CHAIN Outline() const
void Normalize()
Ensure that the height and width are positive.
const BOX2I BBox(int aClearance=0) const override
Compute a bounding box of the shape, with a margin of aClearance a collision.
int m_radius
Corner radius.
static constexpr extended_type ECOORD_MAX
VECTOR2< int32_t > VECTOR2I