Skip to content

Commit

Permalink
Fix case value is negative due to numeric instability
Browse files Browse the repository at this point in the history
  • Loading branch information
mdaakir committed Aug 21, 2024
1 parent 5e30bc4 commit 991dfed
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions MMVII/src/Geom3D/GeomsBase3D.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -548,8 +548,9 @@ tREAL8 L2_DegenerateIndex(const std::vector<cPt3dr> & aVPt,size_t aNumEigV)
aStat.Add(aP3.ToVect());
aStat.Normalise();
const cDenseVect<tREAL8> anEV = aStat.DoEigen().EigenValues() ;

if (anEV(2)==0) return 0.0;
// theoretically eigenvalues can't be negavive => treat <0 as =0
if (anEV(2)<=0) return 0.0;
if (anEV(aNumEigV)<0) return 0.0;

return Sqrt(SafeDiv(anEV(aNumEigV),anEV(2)));
}
Expand Down

0 comments on commit 991dfed

Please sign in to comment.