cosmotool/sample/testInterpolate.cpp
2010-09-12 21:36:37 +02:00

31 lines
771 B
C++

#include <iostream>
#include "interpolate3d.hpp"
using namespace std;
using namespace CosmoTool;
int main()
{
VectorField<float,2> *vectors = new VectorField<float,2>[8];
for (int i = 0; i < 2; i++)
for (int j = 0; j < 2; j++)
for (int k = 0; k < 2; k++)
{
int idx = i + 2*(j + 2*k);
vectors[idx].vec[0] = i;
vectors[idx].vec[1] = j;
}
GridSampler<VectorField<float,2> > sampler(vectors, 2, 2, 2, 2);
Interpolate3D<GridSampler<VectorField<float,2> > > inter(sampler);
VectorField<float,2> v = inter.get(0.5,0.5,0.5);
VectorField<float,2> v2 = inter.get(1.5,1.5,1.5);
cout << v.vec[0] << " " << v.vec[1] << endl;
cout << v2.vec[0] << " " << v2.vec[1] << endl;
return 0;
}