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 )
constexpr BOX2I KiROUND(const BOX2D &aBoxD)
constexpr coord_type GetY() const
constexpr coord_type GetX() 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 coord_type GetRight() const
constexpr bool Intersects(const BOX2< Vec > &aRect) const
constexpr coord_type GetBottom() const
~DISABLE_ARC_RADIUS_CORRECTION()
DISABLE_ARC_RADIUS_CORRECTION()
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 BoxHitTest(const VECTOR2I &aHitPoint, const BOX2I &aHittee, int aAccuracy)
Perform a point-to-box hit test.
EDA_ANGLE abs(const EDA_ANGLE &aAngle)