KiCad PCB EDA Suite
Loading...
Searching...
No Matches
CIRCLE Class Reference

Represent basic circle geometry with utility geometry functions. More...

#include <circle.h>

Public Member Functions

 CIRCLE ()
 
 CIRCLE (const VECTOR2I &aCenter, int aRadius)
 
 CIRCLE (const CIRCLE &aOther)
 
bool operator== (const CIRCLE &aOther) const =default
 
CIRCLEConstructFromTanTanPt (const SEG &aLineA, const SEG &aLineB, const VECTOR2I &aP)
 Construct this circle such that it is tangent to the given segments and passes through the given point, generating the solution which can be used to fillet both segments.
 
bool Contains (const VECTOR2I &aP) const
 Return true if aP is on the circumference of this circle.
 
VECTOR2I NearestPoint (const VECTOR2I &aP) const
 Compute the point on the circumference of the circle that is the closest to aP.
 
VECTOR2D NearestPoint (const VECTOR2D &aP) const
 Compute the point (floating point version) on the circumference of the circle that is the closest to aP.
 
std::vector< VECTOR2IIntersect (const CIRCLE &aCircle) const
 Compute the intersection points between this circle and aCircle.
 
std::vector< VECTOR2IIntersect (const SEG &aSeg) const
 Compute the intersection points between this circle and aSeg.
 
std::vector< VECTOR2IIntersectLine (const SEG &aLine) const
 Compute the intersection points between this circle and aLine.
 
bool Contains (const VECTOR2I &aP)
 Check whether point aP is inside this circle.
 

Public Attributes

int Radius
 Public to make access simpler.
 
VECTOR2I Center
 Public to make access simpler.
 

Detailed Description

Represent basic circle geometry with utility geometry functions.

Definition at line 32 of file circle.h.

Constructor & Destructor Documentation

◆ CIRCLE() [1/3]

CIRCLE::CIRCLE ( )

Definition at line 30 of file circle.cpp.

References Center, and Radius.

◆ CIRCLE() [2/3]

CIRCLE::CIRCLE ( const VECTOR2I aCenter,
int  aRadius 
)

Definition at line 37 of file circle.cpp.

References Center, and Radius.

◆ CIRCLE() [3/3]

CIRCLE::CIRCLE ( const CIRCLE aOther)

Definition at line 44 of file circle.cpp.

References Center, and Radius.

Member Function Documentation

◆ ConstructFromTanTanPt()

CIRCLE & CIRCLE::ConstructFromTanTanPt ( const SEG aLineA,
const SEG aLineB,
const VECTOR2I aP 
)

Construct this circle such that it is tangent to the given segments and passes through the given point, generating the solution which can be used to fillet both segments.

The caller is responsible for ensuring it is providing a solvable problem. This function will assert if this is not the case.

Parameters
aLineAis the first tangent line. Treated as an infinite line except for the purpose of selecting the solution to return.
aLineBis the second tangent line. Treated as an infinite line except for the purpose of selecting the solution to return.
aPis the point to pass through.
Returns
this circle.

Definition at line 51 of file circle.cpp.

References SEG::A, SEG::ApproxParallel(), SEG::B, CalcArcMid(), Center, SEG::Center(), IntersectLine(), SEG::IntersectLines(), SEG::LineDistance(), SEG::LineProject(), SEG::ParallelSeg(), SEG::PerpendicularSeg(), and Radius.

Referenced by BOOST_AUTO_TEST_CASE(), and EDIT_TOOL::DragArcTrack().

◆ Contains() [1/2]

bool CIRCLE::Contains ( const VECTOR2I aP)

Check whether point aP is inside this circle.

Parameters
aPThe point to check.
Returns
true if the point is inside, false otherwise.

Definition at line 355 of file circle.cpp.

References Center, and Radius.

◆ Contains() [2/2]

bool CIRCLE::Contains ( const VECTOR2I aP) const

Return true if aP is on the circumference of this circle.

Note that there is an accepted margin of error of SHAPE::MIN_PRECISION_IU to account for integer rounding errors.

Parameters
aPA point to test
Returns
true if aP is on the circumference.

Definition at line 188 of file circle.cpp.

References Center, distance(), SHAPE::MIN_PRECISION_IU, and Radius.

Referenced by segCircleIntersection().

◆ Intersect() [1/2]

std::vector< VECTOR2I > CIRCLE::Intersect ( const CIRCLE aCircle) const

Compute the intersection points between this circle and aCircle.

Parameters
aCircleThe other circle to intersect with this.
Returns
std::vector containing:
  • 0 elements if the circles do not intersect.
  • 1 element if the circles are tangent.
  • 2 elements if the circles intersect.

Definition at line 221 of file circle.cpp.

References std::abs(), Center, VECTOR2< T >::EuclideanNorm(), KiROUND(), Radius, and RotatePoint().

Referenced by SHAPE_ARC::Collide(), SHAPE_CIRCLE::Collide(), ComputeDogbone(), SHAPE_ARC::Intersect(), segCircleIntersection(), and SHAPE_LINE_CHAIN::SelfIntersectingWithArcs().

◆ Intersect() [2/2]

std::vector< VECTOR2I > CIRCLE::Intersect ( const SEG aSeg) const

Compute the intersection points between this circle and aSeg.

Parameters
aSegThe segment to intersect with this circle (end points ignored).
Returns
std::vector containing up to two intersection points.

Definition at line 286 of file circle.cpp.

References SEG::Contains(), and IntersectLine().

◆ IntersectLine()

std::vector< VECTOR2I > CIRCLE::IntersectLine ( const SEG aLine) const

Compute the intersection points between this circle and aLine.

Parameters
aLineThe line to intersect with this circle (end points ignored).
Returns
std::vector containing:
  • 0 elements if there is no intersection.
  • 1 element if the line is tangent to the circle.
  • 2 elements if the line intersects the circle.

Definition at line 300 of file circle.cpp.

References SEG::A, SEG::B, Center, SEG::LineProject(), SHAPE::MIN_PRECISION_IU, and Radius.

Referenced by ConstructFromTanTanPt(), Intersect(), and SHAPE_ARC::IntersectLine().

◆ NearestPoint() [1/2]

VECTOR2D CIRCLE::NearestPoint ( const VECTOR2D aP) const

Compute the point (floating point version) on the circumference of the circle that is the closest to aP.

In other words: finds the intersection point of this circle and a line that passes through both this circle's center and aP.

Parameters
aP.
Returns
nearest point to aP.

Definition at line 209 of file circle.cpp.

References Center, Radius, VECTOR2< T >::Resize(), VECTOR2< T >::x, and VECTOR2< T >::y.

◆ NearestPoint() [2/2]

VECTOR2I CIRCLE::NearestPoint ( const VECTOR2I aP) const

Compute the point on the circumference of the circle that is the closest to aP.

In other words: finds the intersection point of this circle and a line that passes through both this circle's center and aP.

Parameters
aP.
Returns
nearest point to aP.

Definition at line 197 of file circle.cpp.

References Center, Radius, VECTOR2< T >::Resize(), VECTOR2< T >::x, and VECTOR2< T >::y.

Referenced by SHAPE_ARC::Collide(), ConnectBoardShapes(), EDIT_TOOL::DragArcTrack(), and SHAPE_ARC::NearestPoint().

◆ operator==()

bool CIRCLE::operator== ( const CIRCLE aOther) const
default

Member Data Documentation

◆ Center

◆ Radius


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