Explorar el Código

simplex_interpolator: adding first test on 2D samples

undefined
Guillaume Bittoun Sam Hocevar <sam@hocevar.net> hace 10 años
padre
commit
6f5c15b165
Se han modificado 2 ficheros con 12 adiciones y 8 borrados
  1. +1
    -0
      src/lol/math/all.h
  2. +11
    -8
      src/t/math/simplex_interpolator.cpp

+ 1
- 0
src/lol/math/all.h Ver fichero

@@ -22,4 +22,5 @@
#include <lol/math/geometry.h>
#include <lol/math/interp.h>
#include <lol/math/rand.h>
#include <lol/math/simplex_interpolator.h>


+ 11
- 8
src/t/math/simplex_interpolator.cpp Ver fichero

@@ -2,6 +2,8 @@
// Lol Engine
//
// Copyright: (c) 2010-2014 Sam Hocevar <sam@hocevar.net>
// (c) 2013-2014 Benjamin "Touky" Huet <huet.benjamin@gmail.com>
// (c) 2013-2014 Guillaume Bittoun <guillaume.bittoun@gmail.com>
// 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
@@ -12,10 +14,6 @@

#include <lolunit.h>

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

@@ -25,13 +23,18 @@ lolunit_declare_fixture(SimplexInterpolatorTest)

void TearDown() {}

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

interpolator.GetSamples() = arraynd<2, float>({{1, 1, 2}, {1, 1, 2}, {2, 2, 2}});
interpolator.GetSamples() = arraynd<2, float>({{1, 1, 2}, {1, 2, 2}, {2, 2, 2}});

std::cout << interpolator.Interp(vec_t<float, 2>{0, 0}) << std::endl;
lolunit_assert_equal(interpolator.Interp(vec_t<float, 2>{0, 0}), 1);
lolunit_assert_equal(interpolator.Interp(vec_t<float, 2>{1, 0}), 1);
lolunit_assert_doubles_equal(interpolator.Interp(vec_t<float, 2>{(float)cos(3.14159/3), (float)sin(3.14159/3)}), 1, 1e-5f);

lolunit_assert(interpolator.Interp(vec_t<float, 2>{0, 0.5}) > 1);
lolunit_assert(interpolator.Interp(vec_t<float, 2>{0, 0.5}) < 2);
}
};



Cargando…
Cancelar
Guardar