Преглед изворни кода

simplex_interpolator: adding test skeleton + build fixes

undefined
Guillaume Bittoun Sam Hocevar <sam@hocevar.net> пре 10 година
родитељ
комит
d513d8ac8c
4 измењених фајлова са 46 додато и 15 уклоњено
  1. +12
    -12
      src/lol/math/simplex_interpolator.h
  2. +1
    -1
      src/t/Makefile.am
  3. +0
    -2
      src/t/math/arraynd.cpp
  4. +33
    -0
      src/t/math/simplex_interpolator.cpp

+ 12
- 12
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<T, N> & floor_point, vec_t<T, N> & 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<int, 2>(N, N));
base_inverse.SetSize(vec_t<int, 2>(N, N));
this->samples.SetSize(vec_t<int, 2>(N, N));
this->samples.SetSize(vec_t<int, 2>(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<N, vec_t<N, T> > base;
vec_t<N, vec_t<N, T> > base_inverse;
vec_t<vec_t<T, N>, N> base;
vec_t<vec_t<T, N>, N> base_inverse;

arraynd<N, T> samples;



+ 1
- 1
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@



+ 0
- 2
src/t/math/arraynd.cpp Прегледај датотеку

@@ -12,8 +12,6 @@

#include <lolunit.h>

#include <iostream>

namespace lol
{



+ 33
- 0
src/t/math/simplex_interpolator.cpp Прегледај датотеку

@@ -0,0 +1,33 @@
//
// Lol Engine
//
// Copyright: (c) 2010-2014 Sam Hocevar <sam@hocevar.net>
// 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 <lol/engine-internal.h>

#include <lolunit.h>

// To be removed when fully tested
#include <lol/math/simplex_interpolator.h>
namespace lol
{

lolunit_declare_fixture(SimplexInterpolatorTest)
{
void SetUp() {}

void TearDown() {}

lolunit_declare_test(Interp2D)
{
simplex_interpolator<2> interpolator;
}
};

}

Loading…
Откажи
Сачувај