Skip to content

Commit

Permalink
Fix missing segment on prime tower circles
Browse files Browse the repository at this point in the history
  • Loading branch information
wawanbreton committed Jun 1, 2024
1 parent 358d12e commit eb926d7
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
4 changes: 2 additions & 2 deletions include/utils/polygonUtils.h
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion src/sliceDataStorage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -634,7 +634,7 @@ Shape SliceDataStorage::getMachineBorder(int checking_extruder_nr) const
Point2LL translation(extruder_settings.get<coord_t>("machine_nozzle_offset_x"), extruder_settings.get<coord_t>("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);
}

Expand Down
8 changes: 4 additions & 4 deletions src/utils/polygonUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<double>(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<double>(step) * step_angle;
circle.emplace_back(mid + Point2LL(std::llrint(static_cast<double>(radius) * cos(angle)), std::llrint(static_cast<double>(radius) * sin(angle))));
}
return circle;
}
Expand Down

0 comments on commit eb926d7

Please sign in to comment.