From fe5f9ac38212e3c65c351c225784fe42603a72de Mon Sep 17 00:00:00 2001 From: Filip Sykala Date: Tue, 11 May 2021 18:04:22 +0200 Subject: [PATCH] FIX crop parallel line with y --- src/libslic3r/SLA/SupportIslands/LineUtils.cpp | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/libslic3r/SLA/SupportIslands/LineUtils.cpp b/src/libslic3r/SLA/SupportIslands/LineUtils.cpp index 7434ec525f..8da1f48036 100644 --- a/src/libslic3r/SLA/SupportIslands/LineUtils.cpp +++ b/src/libslic3r/SLA/SupportIslands/LineUtils.cpp @@ -36,11 +36,12 @@ std::optional LineUtils::crop_ray(const Line & ray, coord_t abs_diff = abs(diff); if (abs_diff > radius) return {}; // create cross points - double move_y = sqrt(radius * radius - (double) x * x); - coord_t y = std::round(move_y); - Point first(x, y); - Point second(x,-y); - return Line(first + center, second + center); + double move_y = sqrt(radius * radius - static_cast(x) * x); + coord_t y = static_cast(std::round(move_y)); + coord_t cy = center.y(); + Point first(x, cy + y); + Point second(x,cy - y); + return Line(first, second); } else { Line moved_line(ray.a - center, ray.b - center); double a, b, c; @@ -87,7 +88,7 @@ std::optional LineUtils::crop_half_ray(const Line & half_ray, { std::optional segment = crop_ray(half_ray, center, radius); if (!segment.has_value()) return {}; - Point dir = half_ray.b - half_ray.a; + Point dir = LineUtils::direction(half_ray); using fnc = std::function; fnc use_point_x = [&half_ray, &dir](const Point &p) -> bool { return (p.x() > half_ray.a.x()) == (dir.x() > 0);