40#define MIN_SEGCOUNT_FOR_CIRCLE 8
48 aRadius = std::max( 1, aRadius );
51 double rel_error = (double)aErrorMax / aRadius;
53 double arc_increment = 180 / M_PI * acos( 1.0 - rel_error ) * 2;
62 return std::max( segCount, 2 );
75 double alpha = M_PI / aSegCount;
120 if( y < aClipBox->GetY() )
127 if( x < aClipBox->GetX() )
142 while( outcode1 || outcode2 )
145 if( outcode1 & outcode2 )
149 int thisoutcode, x, y;
152 thisoutcode = outcode1;
154 thisoutcode = outcode2;
160 if( thisoutcode & 1 )
163 x = x1 + (x2 - x1) * std::int64_t(y - y1) / (y2 - y1);
165 else if( thisoutcode & 2 )
167 y = aClipBox->
GetY();
168 x = x1 + ( x2 - x1 ) * std::int64_t( y - y1 ) / ( y2 - y1 );
170 else if( thisoutcode & 8 )
173 y = y1 + ( y2 - y1 ) * std::int64_t( x - x1 ) / ( x2 - x1 );
177 x = aClipBox->
GetX();
178 y = y1 + ( y2 - y1 ) * std::int64_t( x - x1 ) / ( x2 - x1 );
183 if( thisoutcode == outcode1 )
coord_type GetRight() const
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.
constexpr ret_type KiROUND(fp_type v)
Round a floating point number to an integer using "round halfway cases away from zero".