40#define MIN_SEGCOUNT_FOR_CIRCLE 8 
   48    aRadius = std::max( 1, aRadius );
 
   49    aErrorMax = std::max( 1, aErrorMax );
 
   52    double rel_error = (double)aErrorMax / aRadius;
 
   54    double arc_increment = 180 / 
M_PI * acos( 1.0 - rel_error ) * 2;
 
   63    return std::max( segCount, 2 );
 
 
   76    double alpha = 
M_PI / aSegCount;
 
 
  121    if( y < aClipBox->GetY() )
 
  128    if( x < aClipBox->GetX() )
 
 
  143    while( outcode1 || outcode2 )
 
  146        if( outcode1 & outcode2 )
 
  150        int thisoutcode, x, y;
 
  153            thisoutcode = outcode1;
 
  155            thisoutcode = outcode2;
 
  161        if( thisoutcode & 1 ) 
 
  164            x = x1 + (x2 - x1) * std::int64_t(y - y1) / (y2 - y1);
 
  166        else if( thisoutcode & 2 ) 
 
  168            y = aClipBox->
GetY();
 
  169            x = x1 + ( x2 - x1 ) * std::int64_t( y - y1 ) / ( y2 - y1 );
 
  171        else if( thisoutcode & 8 ) 
 
  174            y = y1 + ( y2 - y1 ) * std::int64_t( x - x1 ) / ( x2 - x1 );
 
  178            x = aClipBox->
GetX();
 
  179            y = y1 + ( y2 - y1 ) * std::int64_t( x - x1 ) / ( x2 - x1 );
 
  184        if( thisoutcode == outcode1 )
 
 
  214    if( aHitteeContained )
 
 
  230                         const VECTOR2I& aHitteeRotationCenter, 
bool aHitteeContained )
 
  233    if( aHitteeRotation.
IsZero() )
 
  244    const std::vector<VECTOR2I> corners =
 
  253    shape.
Rotate( aHitteeRotation, aHitteeRotationCenter );
 
 
  265                return aHittee.
Collide( &aHitter );
 
  272                if( 
const auto compoundHittee = 
dynamic_cast<const SHAPE_COMPOUND*
>( &aHittee ) )
 
  275                    return std::ranges::all_of(
 
  276                                compoundHittee->Shapes(),
 
  277                                [&]( 
const SHAPE* subshape )
 
  279                                    return subshape && subshape->Collide( &aHitter );
 
  285                    return aHittee.
Collide( &aHitter );
 
  295                for( 
int i = 0; i < count; ++i )
 
  306        if( aHitteeContained )
 
  309            return collidesAll() && !intersectsAny();
 
  312            return collidesAny();
 
  317        return intersectsAny();
 
 
constexpr BOX2I KiROUND(const BOX2D &aBoxD)
 
constexpr const Vec GetEnd() const
 
constexpr coord_type GetY() const
 
constexpr coord_type GetX() const
 
constexpr coord_type GetLeft() const
 
constexpr bool Contains(const Vec &aPoint) const
 
constexpr BOX2< Vec > GetInflated(coord_type aDx, coord_type aDy) const
Get a new rectangle that is this one, inflated by aDx and aDy.
 
constexpr const Vec & GetOrigin() const
 
const BOX2< Vec > GetBoundingBoxRotated(const VECTOR2I &aRotCenter, const EDA_ANGLE &aAngle) const
Useful to calculate bounding box of rotated items, when rotation is not cardinal.
 
constexpr coord_type GetRight() const
 
constexpr coord_type GetTop() const
 
constexpr bool Intersects(const BOX2< Vec > &aRect) const
 
constexpr coord_type GetBottom() const
 
~DISABLE_ARC_RADIUS_CORRECTION()
 
DISABLE_ARC_RADIUS_CORRECTION()
 
Represent a polyline containing arcs as well as line segments: A chain of connected line and/or arc s...
 
bool IsClosed() const override
 
int SegmentCount() const
Return the number of segments in this line chain.
 
const SEG CSegment(int aIndex) const
Return a constant copy of the aIndex segment in the line chain.
 
Represent a simple polygon consisting of a zero-thickness closed chain of connected line segments.
 
void Rotate(const EDA_ANGLE &aAngle, const VECTOR2I &aCenter={ 0, 0 }) override
 
An abstract shape on 2D plane.
 
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,...
 
int GetCircleToPolyCorrection(int aMaxError)
 
static bool s_disable_arc_correction
 
int CircleToEndSegmentDeltaRadius(int aRadius, int aSegCount)
 
int clipOutCode(const BOX2I *aClipBox, int x, int y)
 
bool ClipLine(const BOX2I *aClipBox, int &x1, int &y1, int &x2, int &y2)
Test if any part of a line falls within the bounds of a rectangle.
 
int GetArcToSegmentCount(int aRadius, int aErrorMax, const EDA_ANGLE &aArcAngle)
 
#define MIN_SEGCOUNT_FOR_CIRCLE
 
a few functions useful in geometry calculations.
 
bool ShapeHitTest(const SHAPE_LINE_CHAIN &aHitter, const SHAPE &aHittee, bool aHitteeContained)
Perform a shape-to-shape hit test.
 
bool BoxHitTest(const VECTOR2I &aHitPoint, const BOX2I &aHittee, int aAccuracy)
Perform a point-to-box hit test.
 
EDA_ANGLE abs(const EDA_ANGLE &aAngle)
 
VECTOR2< int32_t > VECTOR2I