Fixed degenerated case of plane fitting to a linear set of points.

This commit is contained in:
Sven Oesau 2022-04-22 15:36:38 +02:00 committed by Sébastien Loriot
parent 6bd510b943
commit 39df59901b
1 changed files with 5 additions and 1 deletions

View File

@ -723,7 +723,11 @@ fitting_plane_3(typename DiagonalizeTraits::Covariance_matrix& covariance, // co
eigen_vectors[1],
eigen_vectors[2]);
plane = Plane(c,normal);
return FT(1) - eigen_values[0] / eigen_values[1];
if (eigen_values[1] == 0)
return FT(0); // line case
else
return FT(1) - eigen_values[0] / eigen_values[1]; // regular case
} // end regular case
}