1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45
|
template <typename T> std::pair<float, float> pointInterpolation(std::pair <int, int>& H,
std::vector< std::pair <int, int> >& depart, const cimg_library::CImg<T>& u, constfloat coeff_mul) {std::pair< float, float> H_v; //vecteur déplacement pour le point à remplir
int a = depart.size();
/* Allocation dynamique de mémoire */
std::vector< std::pair <int, int> > pointschoisis;
// calcul des points nécessaires pour l'interpolation
nProchePoints(H, depart, NBPOINTSCHOISIS, pointschoisis);
int x,y; // point de controle regardé
float d; // distance entre le point courant et le point de controle
float D=0; // distance totale
float v_x,v_y; // vecteur déplacement du point de controle
for (int i=0; i<NBPOINTSCHOISIS; i++ ) {x = (pointschoisis.begin() +i)->first;
y = (pointschoisis.begin() +i)->second;
v_x = u(x,y,0);
v_y = u(x,y,1);
d = dist(H, pointschoisis[i]);
D+=1/d;
// pour la normalisation
H_v.first += v_x / d;
H_v.second += v_y / d;
}
H_v.first = H_v.first/D;
H_v.second = H_v.second/D;
return H_v;
}
|