diff --git a/rotation.cpp b/rotation.cpp index 56fa935..bcdc155 100644 --- a/rotation.cpp +++ b/rotation.cpp @@ -143,10 +143,11 @@ DPoint get_mapped_point(Image const& src, Point const& p, double const rotation) void round_if_very_small(double& d) { - if (abs(d) < 1.0e-10) + double const sigma = 1.0e-10; + if (abs(d) < sigma) d = 0.0; - if (abs(d - 1) < 1.0e-10) + if (abs(d - 1) < sigma) d = 1.0; } @@ -513,7 +514,11 @@ Image* rotate(Image const& src, double angle) DPoint src_delta_x = get_mapped_point(*rotated, Point(src.width, 0), -rotation); DPoint src_delta_y = get_mapped_point(*rotated, Point(0, src.height), -rotation); src_delta_x -= src_origin; + round_if_very_small(src_delta_x.x); + round_if_very_small(src_delta_x.y); src_delta_y -= src_origin; + round_if_very_small(src_delta_y.x); + round_if_very_small(src_delta_y.y); // Quantized position on a grid int const q_pos_pow = 10;