corrected some interpolation numerical issue in InterpolateField3D

This commit is contained in:
nico 2021-01-11 23:19:04 +11:00
parent 27a4ad3049
commit 89997b915f
1 changed files with 28 additions and 24 deletions

View File

@ -110,7 +110,11 @@ vcg::Point3<ScalarType> InterpolateNRosy3D(const std::vector<vcg::Point3<ScalarT
NF.Normalize();
CoordType Vect=V[i];
Vect.Normalize();
//ScalarType Dot=fabs(Vect*NF);
ScalarType Dot=(Norm[i]*TargetN);
CoordType rotV=V[i];
//std::cout << "Dot " <<Dot<<std::endl;
if (Dot>-0.99999)
{
//std::cout << "V[i] " << V[i].X() << " " << V[i].Y() << std::endl << std::flush;
///rotate the vector to become tangent to the reference plane
@ -118,7 +122,7 @@ vcg::Point3<ScalarType> InterpolateNRosy3D(const std::vector<vcg::Point3<ScalarT
// std::cout << "Norm[i] " << Norm[i].X() << " " << Norm[i].Y() << " " << Norm[i].Z()<< std::endl;
// std::cout << "TargetN " << TargetN.X() << " " << TargetN.Y() << " " << TargetN.Z()<< std::endl<< std::flush;
CoordType rotV=RotNorm*V[i];
rotV=RotNorm*V[i];
//assert(fabs(rotV*TargetN)<0.000001);
rotV.Normalize();
//std::cout << "rotV " << rotV.X() << " " << rotV.Y() << " " << rotV.Z()<< std::endl<< std::flush;
@ -134,7 +138,7 @@ vcg::Point3<ScalarType> InterpolateNRosy3D(const std::vector<vcg::Point3<ScalarT
assert(!isnan(rotV.X()));
assert(!isnan(rotV.Y()));
}
//it's 2D from now on
Cross2D.push_back(vcg::Point2<ScalarType>(rotV.X(),rotV.Y()));