diff --git a/src/lol/math/simplex_interpolator.h b/src/lol/math/simplex_interpolator.h index 38fb63c2..256cec27 100644 --- a/src/lol/math/simplex_interpolator.h +++ b/src/lol/math/simplex_interpolator.h @@ -45,9 +45,9 @@ public: // Retrieving simplex samples to use int sign; - this->GetReference(floor_point, decimal_point, reference, sign); + this->GetReference(floor_point, decimal_point, sign); - return this->LastInterp(floor_point, decimal_point, reference, sign); + return this->LastInterp(floor_point, decimal_point, sign); } protected: @@ -70,15 +70,15 @@ protected: for (int i = 0 ; i < N ; ++i) floor_coeff += (1 - decimal_point[i]); - result += (2 * sqrt(floor_coeff) / sqrt(N)) * this->samples[floor_point]; - divider += (2 * sqrt(floor_coeff) / sqrt(N)); + result += (2 * sqrt(floor_coeff) / sqrt((float)N)) * this->samples[floor_point]; + divider += (2 * sqrt(floor_coeff) / sqrt((float)N)); return result / divider; } inline int Mod(int value, int index) { - samples_index[index] %= this->samples.GetSize()[index]; + return value %= this->samples.GetSize()[index]; } inline void GetReference(vec_t & floor_point, vec_t & decimal_point, int & sign) @@ -92,7 +92,7 @@ protected: for (int i = 0 ; i < N ; ++i) cumul += decimal_point[i]; - if (cumul < (sqrt(N) / 2)) + if (cumul < (sqrt((float)N) / 2)) { sign = 1; } @@ -134,22 +134,22 @@ protected: inline void InitBase() { - base.SetSize(vec_t(N, N)); - base_inverse.SetSize(vec_t(N, N)); + this->samples.SetSize(vec_t(N, N)); + this->samples.SetSize(vec_t(N, N)); for (int i = 0 ; i < N ; ++i) { for (int j = i ; j < N ; ++j) { - this->base[i][j] = sqrt((i+2)/(2*i+2)) / (j > i ? i+2 : 1); - this->base_inverse[i][j] = sqrt((2*j+2) / (j+2)) * (j > i ? (1 / (float)(j+1)) : 1); + this->base[i][j] = sqrt((i+2)/((float)(2*i+2))) / (j > i ? i+2 : 1); + this->base_inverse[i][j] = sqrt((2*j+2) / ((float)(j+2))) * (j > i ? (1 / (float)(j+1)) : 1); this->diagonal[i] += (this->base[i][j]); } } } - vec_t > base; - vec_t > base_inverse; + vec_t, N> base; + vec_t, N> base_inverse; arraynd samples; diff --git a/src/t/Makefile.am b/src/t/Makefile.am index e6d91686..11755436 100644 --- a/src/t/Makefile.am +++ b/src/t/Makefile.am @@ -20,7 +20,7 @@ test_math_SOURCES = test-common.cpp \ math/array2d.cpp math/array3d.cpp math/arraynd.cpp math/box.cpp \ math/cmplx.cpp math/half.cpp math/interp.cpp math/matrix.cpp \ math/quat.cpp math/rand.cpp math/real.cpp math/rotation.cpp \ - math/trig.cpp math/vector.cpp + math/trig.cpp math/vector.cpp math/simplex_interpolator.cpp test_math_CPPFLAGS = $(AM_CPPFLAGS) -I$(top_srcdir)/tools/lolunit test_math_DEPENDENCIES = @LOL_DEPS@ diff --git a/src/t/math/arraynd.cpp b/src/t/math/arraynd.cpp index 1b61d4b0..3e052e64 100644 --- a/src/t/math/arraynd.cpp +++ b/src/t/math/arraynd.cpp @@ -12,8 +12,6 @@ #include -#include - namespace lol { diff --git a/src/t/math/simplex_interpolator.cpp b/src/t/math/simplex_interpolator.cpp new file mode 100644 index 00000000..5324b68c --- /dev/null +++ b/src/t/math/simplex_interpolator.cpp @@ -0,0 +1,33 @@ +// +// Lol Engine +// +// Copyright: (c) 2010-2014 Sam Hocevar +// This program is free software; you can redistribute it and/or +// modify it under the terms of the Do What The Fuck You Want To +// Public License, Version 2, as published by Sam Hocevar. See +// http://www.wtfpl.net/ for more details. +// + +#include + +#include + +// To be removed when fully tested +#include + +namespace lol +{ + +lolunit_declare_fixture(SimplexInterpolatorTest) +{ + void SetUp() {} + + void TearDown() {} + + lolunit_declare_test(Interp2D) + { + simplex_interpolator<2> interpolator; + } +}; + +}