diff --git a/vcg/math/gen_normal.h b/vcg/math/gen_normal.h index caa08d58..7fb7bddf 100644 --- a/vcg/math/gen_normal.h +++ b/vcg/math/gen_normal.h @@ -110,6 +110,29 @@ static void Perturb(std::vector > &NN) } +/* +Trova la normale piu vicina a quella data. +Assume che tutte normale in ingresso sia normalizzata; +*/ +static int BestMatchingNormal(const Point3x &n, std::vector &nv) +{ + int ret=-1; + ScalarType bestang=-1; + ScalarType cosang; + typename std::vector::iterator ni; + for(ni=nv.begin();ni!=nv.end();++ni) + { + cosang=(*ni)*n; + if(cosang>bestang) { + bestang=cosang; + ret=ni-nv.begin(); + } + } + assert(ret>=0 && ret =0 && i=0 && j