From 1d6ad4a52a2f1df88d97e39b03beeaf16c0f2e32 Mon Sep 17 00:00:00 2001 From: jean-pierre charras Date: Wed, 23 Jun 2021 18:28:16 +0200 Subject: [PATCH] SHAPE_ARC::ConvertToPolyline(): fix ugly approximation for some arcs. Arcs with small radius can be approximated with very few segments. However, if the thickness is large, relative to the radius, the approximation must be based on the external radius, not the arc radius. The difference can be significant. This is especially noticeable for these graphic arcs in filled zones. --- libs/kimath/src/geometry/shape_arc.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/libs/kimath/src/geometry/shape_arc.cpp b/libs/kimath/src/geometry/shape_arc.cpp index 344efa23ce..69e0ec100e 100644 --- a/libs/kimath/src/geometry/shape_arc.cpp +++ b/libs/kimath/src/geometry/shape_arc.cpp @@ -424,10 +424,14 @@ const SHAPE_LINE_CHAIN SHAPE_ARC::ConvertToPolyline( double aAccuracy ) const int n; - if( r < aAccuracy ) + // To calculate the arc to segment count, use the external radius instead of the radius. + // for a arc with small radius and large width, the difference can be significant + double external_radius = r+(m_width/2); + + if( external_radius < aAccuracy ) n = 0; else - n = GetArcToSegmentCount( r, aAccuracy, ca ); + n = GetArcToSegmentCount( external_radius, aAccuracy, ca ); // Split the error on either side of the arc. Since we want the start and end points // to be exactly on the arc, the first and last segments need to be shorter to stay within