From 3342fa1df49d51f450c569466910a0dcedbbd1c8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florian=20M=C3=A4rkl?= Date: Wed, 10 Jan 2018 14:02:16 +0100 Subject: Tiled Cloned: Apply shift exponent to absolute shift --- src/ui/dialog/clonetiler.cpp | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/src/ui/dialog/clonetiler.cpp b/src/ui/dialog/clonetiler.cpp index 71edcf259..b31eed39c 100644 --- a/src/ui/dialog/clonetiler.cpp +++ b/src/ui/dialog/clonetiler.cpp @@ -1315,8 +1315,20 @@ Geom::Affine CloneTiler::get_transform( if( !shifty_excludeh ) shiftj += j; // Add exponential shift if necessary - if ( shiftx_exp != 1.0 ) shifti = pow( shifti, shiftx_exp ); - if ( shifty_exp != 1.0 ) shiftj = pow( shiftj, shifty_exp ); + if (shiftx_exp != 1.0) { + if (shifti >= 0.0) { + shifti = pow(shifti, shiftx_exp); + } else { + shifti = -pow(-shifti, shiftx_exp); + } + } + if (shifty_exp != 1.0) { + if (shiftj >= 0.0) { + shiftj = pow(shiftj, shifty_exp); + } else { + shiftj = -pow(-shiftj, shifty_exp); + } + } // Final shift Geom::Affine rect_translate (Geom::Translate (w * shifti, h * shiftj)); -- cgit v1.2.3 From f7c1a4aed08fc3124638307b90eb46ebf826db6c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florian=20M=C3=A4rkl?= Date: Wed, 10 Jan 2018 14:48:09 +0100 Subject: Tiled Cloned: Simplify shift exponent code --- src/ui/dialog/clonetiler.cpp | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/src/ui/dialog/clonetiler.cpp b/src/ui/dialog/clonetiler.cpp index b31eed39c..30cc98736 100644 --- a/src/ui/dialog/clonetiler.cpp +++ b/src/ui/dialog/clonetiler.cpp @@ -1316,18 +1316,12 @@ Geom::Affine CloneTiler::get_transform( // Add exponential shift if necessary if (shiftx_exp != 1.0) { - if (shifti >= 0.0) { - shifti = pow(shifti, shiftx_exp); - } else { - shifti = -pow(-shifti, shiftx_exp); - } + double sign = (shifti > 0.0) ? 1.0 : -1.0; + shifti = sign * pow(fabs(shifti), shiftx_exp); } if (shifty_exp != 1.0) { - if (shiftj >= 0.0) { - shiftj = pow(shiftj, shifty_exp); - } else { - shiftj = -pow(-shiftj, shifty_exp); - } + double sign = (shiftj > 0.0) ? 1.0 : -1.0; + shiftj = sign * pow(fabs(shiftj), shifty_exp); } // Final shift -- cgit v1.2.3 From 559da6cb3f4c75c2ec8ae95d61ce99366b4834e4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florian=20M=C3=A4rkl?= Date: Wed, 10 Jan 2018 14:56:48 +0100 Subject: Tiled Cloned: Remove check for 1.0 in shift exponent code --- src/ui/dialog/clonetiler.cpp | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/src/ui/dialog/clonetiler.cpp b/src/ui/dialog/clonetiler.cpp index 30cc98736..2abd6af6b 100644 --- a/src/ui/dialog/clonetiler.cpp +++ b/src/ui/dialog/clonetiler.cpp @@ -1315,14 +1315,10 @@ Geom::Affine CloneTiler::get_transform( if( !shifty_excludeh ) shiftj += j; // Add exponential shift if necessary - if (shiftx_exp != 1.0) { - double sign = (shifti > 0.0) ? 1.0 : -1.0; - shifti = sign * pow(fabs(shifti), shiftx_exp); - } - if (shifty_exp != 1.0) { - double sign = (shiftj > 0.0) ? 1.0 : -1.0; - shiftj = sign * pow(fabs(shiftj), shifty_exp); - } + double shifti_sign = (shifti > 0.0) ? 1.0 : -1.0; + shifti = shifti_sign * pow(fabs(shifti), shiftx_exp); + double shiftj_sign = (shiftj > 0.0) ? 1.0 : -1.0; + shiftj = shiftj_sign * pow(fabs(shiftj), shifty_exp); // Final shift Geom::Affine rect_translate (Geom::Translate (w * shifti, h * shiftj)); -- cgit v1.2.3