From cd7cab979468d5ad4dc1520fc43b0730f6adb6db Mon Sep 17 00:00:00 2001 From: jean-pierre charras Date: Sat, 17 Dec 2022 14:47:26 +0100 Subject: [PATCH] SHAPE_ARC::GetCentralAngle(): ensure a 360 deg arc angle is always returned as 360 deg. An arc having the same start and end points can be 0 or 360 deg arc. In Kicad it is always 360 deg arc (i.e. a circle) Fixes #13182 https://gitlab.com/kicad/code/kicad/issues/13182 --- libs/kimath/src/geometry/shape_arc.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/libs/kimath/src/geometry/shape_arc.cpp b/libs/kimath/src/geometry/shape_arc.cpp index 92b80adccd..b93558a2ce 100644 --- a/libs/kimath/src/geometry/shape_arc.cpp +++ b/libs/kimath/src/geometry/shape_arc.cpp @@ -438,6 +438,12 @@ double SHAPE_ARC::GetLength() const double SHAPE_ARC::GetCentralAngle() const { + // Arcs with same start and end points can be 0 deg or 360 deg arcs. + // However, they are expected to be circles. + // So return 360 degrees as central arc: + if( m_start == m_end ) + return 360.0; + VECTOR2I center = GetCenter(); VECTOR2I p0 = m_start - center; VECTOR2I p1 = m_mid - center;