From b015d913312205d26b92b48286e7c88d43714bb0 Mon Sep 17 00:00:00 2001 From: Fabien Freling Date: Wed, 6 Aug 2014 23:01:29 +0200 Subject: [PATCH] Round small deltas to 0. Otherwise it triggers a small change. --- rotation.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) 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;