From 5d5706b8be0d8150b263a15d65ec5585613cc20f Mon Sep 17 00:00:00 2001 From: jean-pierre charras Date: Mon, 6 Jul 2020 13:50:55 +0200 Subject: [PATCH] Fix incorrect Rotate() functions for shapes circles and arcs. VECTOR2I::Rotate( double aAngle ) returns a rotated point, but does change the object itself. Fixes #4810 https://gitlab.com/kicad/code/kicad/issues/4810 --- libs/kimath/include/geometry/shape_circle.h | 4 +++- libs/kimath/src/geometry/shape_arc.cpp | 7 ++++--- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/libs/kimath/include/geometry/shape_circle.h b/libs/kimath/include/geometry/shape_circle.h index 4e4e4153f8..119474864b 100644 --- a/libs/kimath/include/geometry/shape_circle.h +++ b/libs/kimath/include/geometry/shape_circle.h @@ -106,7 +106,9 @@ public: void Rotate( double aAngle, const VECTOR2I& aCenter = { 0, 0 } ) override { - // That was easy.... + m_center -= aCenter; + m_center = m_center.Rotate( aAngle ); + m_center += aCenter; } bool IsSolid() const override diff --git a/libs/kimath/src/geometry/shape_arc.cpp b/libs/kimath/src/geometry/shape_arc.cpp index b8ff0001f8..178b97def1 100644 --- a/libs/kimath/src/geometry/shape_arc.cpp +++ b/libs/kimath/src/geometry/shape_arc.cpp @@ -279,13 +279,14 @@ void SHAPE_ARC::Rotate( double aAngle, const VECTOR2I& aCenter ) m_end -= aCenter; m_mid -= aCenter; - m_start.Rotate( aAngle ); - m_end.Rotate( aAngle ); - m_mid.Rotate( aAngle ); + m_start = m_start.Rotate( aAngle ); + m_end = m_end.Rotate( aAngle ); + m_mid = m_mid.Rotate( aAngle ); m_start += aCenter; m_end += aCenter; m_mid += aCenter; + update_bbox(); }