diff --git a/include/utils/polygonUtils.h b/include/utils/polygonUtils.h index 825bc62e79..95c9408a31 100644 --- a/include/utils/polygonUtils.h +++ b/include/utils/polygonUtils.h @@ -671,10 +671,10 @@ class PolygonUtils * This creates a regular polygon that is supposed to approximate a circle. * \param mid The center of the circle. * \param radius The radius of the circle. - * \param a_step The angle between segments of the circle. + * \param step_angle The angle between segments of the circle. * \return A new Polygon containing the circle. */ - static Polygon makeCircle(const Point2LL mid, const coord_t radius, const AngleRadians a_step = std::numbers::pi / 8); + static Polygon makeCircle(const Point2LL mid, const coord_t radius, const AngleRadians step_angle = std::numbers::pi / 8); /*! * Create a "wheel" shape. diff --git a/src/utils/polygonUtils.cpp b/src/utils/polygonUtils.cpp index 085bca049c..22f03ddfff 100644 --- a/src/utils/polygonUtils.cpp +++ b/src/utils/polygonUtils.cpp @@ -1431,12 +1431,14 @@ double PolygonUtils::relativeHammingDistance(const Shape& poly_a, const Shape& p return hamming_distance / total_area; } -Polygon PolygonUtils::makeCircle(const Point2LL mid, const coord_t radius, const AngleRadians a_step) +Polygon PolygonUtils::makeCircle(const Point2LL mid, const coord_t radius, const AngleRadians step_angle) { Polygon circle; - for (double a = 0; a < 2 * std::numbers::pi; a += a_step) + const size_t steps = (2 * std::numbers::pi) / step_angle; + for (size_t step = 0; step < steps; ++step) { - circle.emplace_back(mid + Point2LL(radius * cos(a), radius * sin(a))); + const double angle = step * step_angle; + circle.emplace_back(mid + Point2LL(radius * cos(angle), radius * sin(angle))); } return circle; }