From a815a788e6fa339cc11ac7b2fad970e174f2eb60 Mon Sep 17 00:00:00 2001 From: Guillaume Bittoun Date: Sun, 21 Dec 2014 13:46:44 +0000 Subject: [PATCH] simplex_interpolator: bug fix on negative values. --- src/lol/math/simplex_interpolator.h | 2 +- src/t/math/simplex_interpolator.cpp | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/lol/math/simplex_interpolator.h b/src/lol/math/simplex_interpolator.h index 812fe9c9..d428f1fc 100644 --- a/src/lol/math/simplex_interpolator.h +++ b/src/lol/math/simplex_interpolator.h @@ -117,7 +117,7 @@ protected: { // Finding floor point index for (int i = 0 ; i < N ; ++i) - floor_point[i] = (int) simplex_position[i]; + floor_point[i] = ((int) simplex_position[i]) - (simplex_position[i] < 0 ? 1 : 0); // Extracting decimal part from simplex sample for (int i = 0 ; i < N ; ++i) diff --git a/src/t/math/simplex_interpolator.cpp b/src/t/math/simplex_interpolator.cpp index c8b83888..50d3a629 100644 --- a/src/t/math/simplex_interpolator.cpp +++ b/src/t/math/simplex_interpolator.cpp @@ -226,9 +226,9 @@ lolunit_declare_fixture(SimplexInterpolatorTest) s.SetGradients(gradients); std::cout << std::endl; - for (int i = 0 ; i < 32 ; ++i) + for (int i = -64 ; i < 64 ; ++i) { - for (int j = 0 ; j < 32 ; ++j) + for (int j = -64 ; j < 64 ; ++j) { std::cout << s.Interp(vec_t({i * 0.1f, j * 0.1f})) << ", "; }