From eb926d7fe48f27ca99e40b79bf5450ce52761408 Mon Sep 17 00:00:00 2001 From: Erwan MATHIEU Date: Sat, 1 Jun 2024 12:43:06 +0200 Subject: [PATCH] Fix missing segment on prime tower circles --- include/utils/polygonUtils.h | 4 ++-- src/sliceDataStorage.cpp | 2 +- src/utils/polygonUtils.cpp | 8 ++++---- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/include/utils/polygonUtils.h b/include/utils/polygonUtils.h index 80bb0109f2..cefc8e2fe6 100644 --- a/include/utils/polygonUtils.h +++ b/include/utils/polygonUtils.h @@ -640,10 +640,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 step_angle The angle between segments of the circle. + * \param steps The numbers of segments (definition) of the generated circle. * \return A new Polygon containing the circle. */ - static Polygon makeCircle(const Point2LL mid, const coord_t radius, const AngleRadians step_angle = std::numbers::pi / 8); + static Polygon makeCircle(const Point2LL mid, const coord_t radius, const size_t steps); /*! * Create a "wheel" shape. diff --git a/src/sliceDataStorage.cpp b/src/sliceDataStorage.cpp index 0270a3ffb7..b16b130794 100644 --- a/src/sliceDataStorage.cpp +++ b/src/sliceDataStorage.cpp @@ -634,7 +634,7 @@ Shape SliceDataStorage::getMachineBorder(int checking_extruder_nr) const Point2LL translation(extruder_settings.get("machine_nozzle_offset_x"), extruder_settings.get("machine_nozzle_offset_y")); prime_pos -= translation; Shape prime_polygons; - prime_polygons.emplace_back(PolygonUtils::makeCircle(prime_pos, prime_clearance, std::numbers::pi / 32)); + prime_polygons.emplace_back(PolygonUtils::makeCircle(prime_pos, prime_clearance, 32)); disallowed_areas = disallowed_areas.unionPolygons(prime_polygons); } diff --git a/src/utils/polygonUtils.cpp b/src/utils/polygonUtils.cpp index 5217f9bbe0..7695ca127d 100644 --- a/src/utils/polygonUtils.cpp +++ b/src/utils/polygonUtils.cpp @@ -1386,14 +1386,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 step_angle) +Polygon PolygonUtils::makeCircle(const Point2LL mid, const coord_t radius, const size_t steps) { Polygon circle; - const size_t steps = (2 * std::numbers::pi) / step_angle; + const double step_angle = (std::numbers::pi * 2) / static_cast(steps); for (size_t step = 0; step < steps; ++step) { - const double angle = step * step_angle; - circle.emplace_back(mid + Point2LL(radius * cos(angle), radius * sin(angle))); + const double angle = static_cast(step) * step_angle; + circle.emplace_back(mid + Point2LL(std::llrint(static_cast(radius) * cos(angle)), std::llrint(static_cast(radius) * sin(angle)))); } return circle; }