TransformOvalToPolygon: make segments align at 45 deg angles.

This commit is contained in:
Alex Shvartzkop 2023-11-06 14:50:36 +03:00
parent 24ca7add42
commit 648b4a7689
1 changed files with 5 additions and 2 deletions

View File

@ -131,6 +131,9 @@ void TransformOvalToPolygon( SHAPE_POLY_SET& aBuffer, const VECTOR2I& aStart, co
int numSegs = GetArcToSegmentCount( radius, aError, FULL_CIRCLE );
numSegs = std::max( aMinSegCount, numSegs );
// Round up to 8 to make segment approximations align properly at 45-degrees
numSegs = ( numSegs + 7 ) / 8 * 8;
EDA_ANGLE delta = ANGLE_360 / numSegs;
if( aErrorLoc == ERROR_OUTSIDE )
@ -168,7 +171,7 @@ void TransformOvalToPolygon( SHAPE_POLY_SET& aBuffer, const VECTOR2I& aStart, co
// add right rounded end:
for( EDA_ANGLE angle = ANGLE_0; angle < ANGLE_180; angle += delta )
for( EDA_ANGLE angle = delta / 2; angle < ANGLE_180; angle += delta )
{
corner = VECTOR2I( 0, radius );
RotatePoint( corner, angle );
@ -181,7 +184,7 @@ void TransformOvalToPolygon( SHAPE_POLY_SET& aBuffer, const VECTOR2I& aStart, co
polyshape.Append( corner.x, corner.y );
// add left rounded end:
for( EDA_ANGLE angle = ANGLE_0; angle < ANGLE_180; angle += delta )
for( EDA_ANGLE angle = delta / 2; angle < ANGLE_180; angle += delta )
{
corner = VECTOR2I( 0, -radius );
RotatePoint( corner, angle );