瀏覽代碼

simplex_interpolator: removing tests and correcting skew matrix

undefined
Guillaume Bittoun Sam Hocevar <sam@hocevar.net> 10 年之前
父節點
當前提交
06dfb3b0c0
共有 3 個檔案被更改,包括 24 行新增12 行删除
  1. +0
    -2
      src/lol/math/all.h
  2. +23
    -9
      src/lol/math/simplex_interpolator.h
  3. +1
    -1
      src/t/Makefile.am

+ 0
- 2
src/lol/math/all.h 查看文件

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


+ 23
- 9
src/lol/math/simplex_interpolator.h 查看文件

@@ -124,18 +124,32 @@ protected:

inline void InitBase()
{
/* Matrix coordinate transformation to skew simplex referential is done
by inversing the base matrix M which is written as follows:

M = | a b b b … | M^(-1) = | c d d d … |
| b a b b … | | d c d d … |
| b b a b … | | d d c d … |
| … | | … |

where a and b are computed below ↴
*/

T b = (1 - sqrt((N+1)))/(N * N * N));
T a = b + sqrt((N+1)/N);

// determinant of matrix M
T det = a * (a + (N-2) * b) - (b * b) * (N-1);

T c = (a + (N-2)*b) / det;
T d = b / det;

for (int i = 0; i < N; ++i)
{
for (int j = 0; j < i; ++j)
{
m_base[j][i] = 0;
m_base_inverse[j][i] = 0;
}

for (int j = i; j < N; ++j)
for (int j = 0; j < N; ++j)
{
m_base[j][i] = sqrt((i+2)/((float)(2*i+2))) / (j > i ? i+2 : 1);
m_base_inverse[j][i] = sqrt((2*j+2) / ((float)(j+2))) * (j > i ? (-1 / (float)(j+1)) : 1);
m_base[i][j] = (i == j ? a : b);
m_base_inverse[i][j] = (i == j ? c : d);
}
}
}


+ 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/simplex_interpolator.cpp
math/trig.cpp math/vector.cpp
test_math_CPPFLAGS = $(AM_CPPFLAGS) -I$(top_srcdir)/tools/lolunit
test_math_DEPENDENCIES = @LOL_DEPS@



Loading…
取消
儲存