25 #ifndef __SHAPE_SEGMENT_H 26 #define __SHAPE_SEGMENT_H 62 const BOX2I BBox(
int aClearance = 0 )
const override 72 bool Collide(
const SHAPE* aShape,
int aClearance = 0,
int* aActual =
nullptr,
73 VECTOR2I* aLocation =
nullptr )
const override 78 bool Collide(
const SEG& aSeg,
int aClearance = 0,
int* aActual =
nullptr,
79 VECTOR2I* aLocation =
nullptr )
const override 81 int min_dist = (
m_width + 1 ) / 2 + aClearance;
84 if( dist_sq == 0 || dist_sq <
SEG::Square( min_dist ) )
90 *aActual = std::max( 0, (
int) sqrt( dist_sq ) - (
m_width + 1 ) / 2 );
99 VECTOR2I* aLocation =
nullptr )
const override 101 int min_dist = (
m_width + 1 ) / 2 + aClearance;
104 if( dist_sq == 0 || dist_sq <
SEG::Square( min_dist ) )
110 *aActual = std::max( 0, (
int) sqrt( dist_sq ) - (
m_width + 1 ) / 2 );
161 virtual const std::string
Format( )
const override;
void SetSeg(const SEG &aSeg)
bool Collide(const SHAPE *aShape, int aClearance=0, int *aActual=nullptr, VECTOR2I *aLocation=nullptr) const override
void Rotate(double aAngle, const VECTOR2I &aCenter={ 0, 0 }) override
const BOX2I BBox(int aClearance=0) const override
Compute a bounding box of the shape, with a margin of aClearance a collision.
ecoord SquaredDistance(const SEG &aSeg) const
static SEG::ecoord Square(int a)
virtual const std::string Format() const override
virtual bool Collide(const VECTOR2I &aP, int aClearance=0, int *aActual=nullptr, VECTOR2I *aLocation=nullptr) const
Check if the boundary of shape (this) lies closer to the point aP than aClearance,...
const SEG & GetSeg() const
void Move(const VECTOR2I &aVector) override
bool Collide(const VECTOR2I &aP, int aClearance=0, int *aActual=nullptr, VECTOR2I *aLocation=nullptr) const override
Check if the boundary of shape (this) lies closer to the point aP than aClearance,...
const VECTOR2I NearestPoint(const VECTOR2I &aP) const
Compute a point on the segment (this) that is closest to point aP.
An abstract shape on 2D plane.
SHAPE_SEGMENT(const SEG &aSeg, int aWidth=0)
bool Collide(const SEG &aSeg, int aClearance=0, int *aActual=nullptr, VECTOR2I *aLocation=nullptr) const override
Check if the boundary of shape (this) lies closer to the segment aSeg than aClearance,...
BOX2< Vec > & Inflate(coord_type dx, coord_type dy)
Function Inflate inflates the rectangle horizontally by dx and vertically by dy.
VECTOR2< T > Rotate(double aAngle) const
Rotate the vector by a given angle.
SHAPE * Clone() const override
Return a dynamically allocated copy of the shape.
VECTOR2I::extended_type ecoord
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,...
SHAPE_SEGMENT(const VECTOR2I &aA, const VECTOR2I &aB, int aWidth=0)
bool IsSolid() const override
void SetWidth(int aWidth)