From 673f03e59525a6cdfd97739906d50c9510a94d0d Mon Sep 17 00:00:00 2001 From: jean-pierre charras Date: Fri, 19 Jan 2018 21:10:40 +0100 Subject: [PATCH] Convert circle to polygon: minimize rounding errors. Fixes: lp:1735206 https://bugs.launchpad.net/kicad/+bug/1735206 --- common/convert_basic_shapes_to_polygon.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/common/convert_basic_shapes_to_polygon.cpp b/common/convert_basic_shapes_to_polygon.cpp index f2efe03c08..c70240b38a 100644 --- a/common/convert_basic_shapes_to_polygon.cpp +++ b/common/convert_basic_shapes_to_polygon.cpp @@ -4,8 +4,8 @@ /* * This program source code file is part of KiCad, a free EDA CAD application. * - * Copyright (C) 2012 Jean-Pierre Charras, jp.charras at wanadoo.fr - * Copyright (C) 1992-2012 KiCad Developers, see change_log.txt for contributors. + * Copyright (C) 2018 Jean-Pierre Charras, jp.charras at wanadoo.fr + * Copyright (C) 1992-2018 KiCad Developers, see AUTHORS.txt for contributors. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -48,8 +48,8 @@ void TransformCircleToPolygon( SHAPE_POLY_SET& aCornerBuffer, int aCircleToSegmentsCount ) { wxPoint corner_position; - int delta = 3600 / aCircleToSegmentsCount; // rot angle in 0.1 degree - int halfstep = 1800 / aCircleToSegmentsCount; // the starting value for rot angles + double delta = 3600.0 / aCircleToSegmentsCount; // rot angle in 0.1 degree + double halfstep = delta/2; // the starting value for rot angles aCornerBuffer.NewOutline(); @@ -57,7 +57,7 @@ void TransformCircleToPolygon( SHAPE_POLY_SET& aCornerBuffer, { corner_position.x = aRadius; corner_position.y = 0; - int angle = (ii * delta) + halfstep; + double angle = (ii * delta) + halfstep; RotatePoint( &corner_position.x, &corner_position.y, angle ); corner_position += aCenter; aCornerBuffer.Append( corner_position.x, corner_position.y );