Horizon
Loading...
Searching...
No Matches
Public Member Functions | Static Public Member Functions | List of all members
SHAPE_ARC Class Reference
Inheritance diagram for SHAPE_ARC:
SHAPE SHAPE_BASE

Public Member Functions

 SHAPE_ARC (const VECTOR2I &aArcCenter, const VECTOR2I &aArcStartPoint, double aCenterAngle, int aWidth=0)
 Construct and arc using center, start, angle.
 
 SHAPE_ARC (const VECTOR2I &aArcStart, const VECTOR2I &aArcMid, const VECTOR2I &aArcEnd, int aWidth)
 
 SHAPE_ARC (const SEG &aSegmentA, const SEG &aSegmentB, int aRadius, int aWidth=0)
 Build a SHAPE_ARC which is tangent to two segments and a given radius.
 
 SHAPE_ARC (const SHAPE_ARC &aOther)
 
SHAPEClone () const override
 Return a dynamically allocated copy of the shape.
 
SHAPE_ARCConstructFromStartEndAngle (const VECTOR2I &aStart, const VECTOR2I &aEnd, double aAngle, double aWidth=0)
 Construct this arc from the given start, end and angle.
 
SHAPE_ARCConstructFromStartEndCenter (const VECTOR2I &aStart, const VECTOR2I &aEnd, const VECTOR2I &aCenter, bool aClockwise=false, double aWidth=0)
 Constructs this arc from the given start, end and center.
 
const VECTOR2IGetP0 () const
 
const VECTOR2IGetP1 () const
 
const VECTOR2IGetArcMid () const
 
VECTOR2I GetCenter () const
 
const BOX2I BBox (int aClearance=0) const override
 Compute a bounding box of the shape, with a margin of aClearance a collision.
 
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, indicating a collision.
 
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, indicating a collision.
 
bool Collide (const SHAPE *aShape, int aClearance=0, int *aActual=nullptr, VECTOR2I *aLocation=nullptr) const override
 
int IntersectLine (const SEG &aSeg, std::vector< VECTOR2I > *aIpsBuffer) const
 Find intersection points between this arc and aSeg, treating aSeg as an infinite line.
 
int Intersect (const SHAPE_ARC &aArc, std::vector< VECTOR2I > *aIpsBuffer) const
 Find intersection points between this arc and aArc.
 
bool IsClockwise () const
 
void SetWidth (int aWidth)
 
int GetWidth () const
 
bool IsSolid () const override
 
void Move (const VECTOR2I &aVector) override
 
void Rotate (double aAngle, const VECTOR2I &aCenter) override
 Rotate the arc by a given angle about a point.
 
void Mirror (bool aX=true, bool aY=false, const VECTOR2I &aVector={ 0, 0 })
 
void Mirror (const SEG &axis)
 
void Reverse ()
 
SHAPE_ARC Reversed () const
 
double GetRadius () const
 
SEG GetChord () const
 
double GetCentralAngle () const
 
double GetStartAngle () const
 
double GetEndAngle () const
 
double GetLength () const
 
const SHAPE_LINE_CHAIN ConvertToPolyline (double aAccuracy=DefaultAccuracyForPCB(), double *aEffectiveAccuracy=nullptr) const
 Construct a SHAPE_LINE_CHAIN of segments from a given arc.
 
bool operator== (SHAPE_ARC const &aArc) const
 
- Public Member Functions inherited from SHAPE
 SHAPE (SHAPE_TYPE aType)
 Create an empty shape of type aType.
 
bool IsNull () const
 Return true if the shape is a null shape.
 
virtual bool Collide (const SHAPE *aShape, int aClearance, VECTOR2I *aMTV) const
 Check if the boundary of shape (this) lies closer to the shape aShape than aClearance, indicating a collision.
 
virtual VECTOR2I Centre () const
 Compute a center-of-mass of the shape.
 
virtual bool Parse (std::stringstream &aStream)
 
virtual const std::string Format () const
 
- Public Member Functions inherited from SHAPE_BASE
 SHAPE_BASE (SHAPE_TYPE aType)
 Create an empty shape of type aType.
 
SHAPE_TYPE Type () const
 Return the type of the shape.
 
virtual bool HasIndexableSubshapes () const
 
virtual size_t GetIndexableSubshapeCount () const
 
virtual void GetIndexableSubshapes (std::vector< SHAPE * > &aSubshapes)
 

Static Public Member Functions

static double DefaultAccuracyForPCB ()
 

Additional Inherited Members

- Static Public Attributes inherited from SHAPE
static const int MIN_PRECISION_IU = 4
 This is the minimum precision for all the points in a shape.
 
- Protected Types inherited from SHAPE
typedef VECTOR2I::extended_type ecoord
 
- Protected Attributes inherited from SHAPE_BASE
SHAPE_TYPE m_type
 < type of our shape
 

Constructor & Destructor Documentation

◆ SHAPE_ARC() [1/3]

SHAPE_ARC::SHAPE_ARC ( const VECTOR2I aArcCenter,
const VECTOR2I aArcStartPoint,
double  aCenterAngle,
int  aWidth = 0 
)

Construct and arc using center, start, angle.

Center and angle are used to calculate the mid and end points of the arc, and are not stored.

Parameters
aArcCenteris the arc center.
aArcStartPointis the arc start point.
aCenterAngleis the arc angle in degrees.
aWidthis the arc line thickness.

◆ SHAPE_ARC() [2/3]

SHAPE_ARC::SHAPE_ARC ( const VECTOR2I aArcStart,
const VECTOR2I aArcMid,
const VECTOR2I aArcEnd,
int  aWidth 
)
Parameters
aArcStartis the arc start point.
aArcEndis the arc end point.
aArcMidis the arc mid point.
aWidthis the arc line thickness.

◆ SHAPE_ARC() [3/3]

SHAPE_ARC::SHAPE_ARC ( const SEG aSegmentA,
const SEG aSegmentB,
int  aRadius,
int  aWidth = 0 
)

Build a SHAPE_ARC which is tangent to two segments and a given radius.

Parameters
aSegmentAis the first segment
aSegmentBis the second segment
aRadiusis the arc radius
aWidthis the arc line thickness

Member Function Documentation

◆ BBox()

const BOX2I SHAPE_ARC::BBox ( int  aClearance = 0) const
overridevirtual

Compute a bounding box of the shape, with a margin of aClearance a collision.

Parameters
aClearancehow much the bounding box is expanded wrs to the minimum enclosing rectangle for the shape.
Returns
the bounding box.

Implements SHAPE.

◆ Clone()

SHAPE * SHAPE_ARC::Clone ( ) const
inlineoverridevirtual

Return a dynamically allocated copy of the shape.

Return values
copyof the shape

Reimplemented from SHAPE.

◆ Collide() [1/3]

bool SHAPE_ARC::Collide ( const SEG aSeg,
int  aClearance = 0,
int *  aActual = nullptr,
VECTOR2I aLocation = nullptr 
) const
overridevirtual

Check if the boundary of shape (this) lies closer to the segment aSeg than aClearance, indicating a collision.

Parameters
aActual[out] an optional pointer to an int to be updated with the actual distance int the event of a collision.
aLocation[out] an option pointer to a point to store a nearby location in the event of a collision.
Returns
true, if there is a collision.

Implements SHAPE.

◆ Collide() [2/3]

bool SHAPE_ARC::Collide ( const SHAPE aShape,
int  aClearance = 0,
int *  aActual = nullptr,
VECTOR2I aLocation = nullptr 
) const
inlineoverridevirtual

Reimplemented from SHAPE.

◆ Collide() [3/3]

bool SHAPE_ARC::Collide ( const VECTOR2I aP,
int  aClearance = 0,
int *  aActual = nullptr,
VECTOR2I aLocation = nullptr 
) const
overridevirtual

Check if the boundary of shape (this) lies closer to the point aP than aClearance, indicating a collision.

Parameters
aActual[out] an optional pointer to an int to store the actual distance in the event of a collision.
aLocation[out] an option pointer to a point to store a nearby location in the event of a collision.
Returns
true, if there is a collision.

Reimplemented from SHAPE.

◆ ConstructFromStartEndAngle()

SHAPE_ARC & SHAPE_ARC::ConstructFromStartEndAngle ( const VECTOR2I aStart,
const VECTOR2I aEnd,
double  aAngle,
double  aWidth = 0 
)

Construct this arc from the given start, end and angle.

Parameters
aStartis the arc starting point
aEndis the arc endpoint
aAngleis the arc included angle
aWidthis the arc line thickness
Returns
this arc.

◆ ConstructFromStartEndCenter()

SHAPE_ARC & SHAPE_ARC::ConstructFromStartEndCenter ( const VECTOR2I aStart,
const VECTOR2I aEnd,
const VECTOR2I aCenter,
bool  aClockwise = false,
double  aWidth = 0 
)

Constructs this arc from the given start, end and center.

Parameters
aStartis the arc starting point
aEndis the arc endpoint
aCenteris the arc center
aClockwisedetermines which of the two solutions to construct
aWidthis the arc line thickness
Returns
*this

◆ ConvertToPolyline()

const SHAPE_LINE_CHAIN SHAPE_ARC::ConvertToPolyline ( double  aAccuracy = DefaultAccuracyForPCB(),
double *  aEffectiveAccuracy = nullptr 
) const

Construct a SHAPE_LINE_CHAIN of segments from a given arc.

Note
The default is #ARC_HIGH_DEF in Pcbnew units. This is to allow common geometry collision functions. Other programs should call this using explicit accuracy values.
Todo:
Unify KiCad internal units.
Parameters
aAccuracymaximum divergence from true arc given in internal units.
aEffectiveAccuracyis the actual divergence from true arc given. the approximation error is between -aEffectiveAccuracy/2 and +aEffectiveAccuracy/2 in internal units
Returns
a SHAPE_LINE_CHAIN.

◆ DefaultAccuracyForPCB()

static double SHAPE_ARC::DefaultAccuracyForPCB ( )
inlinestatic
Note
The default is #ARC_HIGH_DEF in Pcbnew units. This is to allow common geometry collision functions. Other programs should call this using explicit accuracy values.
Todo:
Unify KiCad internal units.
Returns
a default accuracy value for ConvertToPolyline() to build the polyline.

◆ GetCentralAngle()

double SHAPE_ARC::GetCentralAngle ( ) const
Returns
the central angle of the arc shape in degrees, normalized between 0.0, 360.0 deg.

◆ GetEndAngle()

double SHAPE_ARC::GetEndAngle ( ) const
Returns
the end angle of the arc shape in degrees, normalized between 0.0, 360.0 deg.

◆ GetLength()

double SHAPE_ARC::GetLength ( ) const
Returns
the length of the arc shape.

◆ GetStartAngle()

double SHAPE_ARC::GetStartAngle ( ) const
Returns
the start angle of the arc shape in degrees, normalized between 0.0, 360.0 deg.

◆ Intersect()

int SHAPE_ARC::Intersect ( const SHAPE_ARC aArc,
std::vector< VECTOR2I > *  aIpsBuffer 
) const

Find intersection points between this arc and aArc.

Ignores arc width.

Parameters
aSeg
aIpsBufferBuffer to store the resulting intersection points (if any)
Returns
Number of intersection points found

◆ IntersectLine()

int SHAPE_ARC::IntersectLine ( const SEG aSeg,
std::vector< VECTOR2I > *  aIpsBuffer 
) const

Find intersection points between this arc and aSeg, treating aSeg as an infinite line.

Ignores arc width.

Parameters
aSegLine to intersect against (treated as an infinite line)
aIpsBufferBuffer to store the resulting intersection points (if any)
Returns
Number of intersection points found

◆ IsSolid()

bool SHAPE_ARC::IsSolid ( ) const
inlineoverridevirtual

Implements SHAPE.

◆ Move()

void SHAPE_ARC::Move ( const VECTOR2I aVector)
overridevirtual

Implements SHAPE.

◆ Rotate()

void SHAPE_ARC::Rotate ( double  aAngle,
const VECTOR2I aCenter 
)
overridevirtual

Rotate the arc by a given angle about a point.

Parameters
aCenteris the rotation center.
aAnglerotation angle in radians.

Implements SHAPE.


The documentation for this class was generated from the following files: