From 662a2a2393a25baef77e42f74204b11b70a9646c Mon Sep 17 00:00:00 2001 From: NATHALIE GORE Date: Fri, 15 Dec 2023 08:20:15 +0100 Subject: [PATCH] Fix computation height of isocel triangle with base equal zero : NaN --- src/INTERP_KERNEL/VolSurfUser.txx | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/INTERP_KERNEL/VolSurfUser.txx b/src/INTERP_KERNEL/VolSurfUser.txx index 5ba8d86e3..bf370ff3a 100644 --- a/src/INTERP_KERNEL/VolSurfUser.txx +++ b/src/INTERP_KERNEL/VolSurfUser.txx @@ -439,12 +439,19 @@ namespace INTERP_KERNEL template void ComputeTriangleHeight(const double *PA, const double *PB, const double *PC, double *res) { - double AB = getDistanceBtw2Pts(PA,PB); - double BC = getDistanceBtw2Pts(PB,PC); - double CA = getDistanceBtw2Pts(PC,PA); + constexpr double EPS = 1e-12; + double AB = getDistanceBtw2Pts(PA,PB); double maxLength = AB; + double BC = getDistanceBtw2Pts(PB,PC); if (BC > maxLength) maxLength = BC; + double CA = getDistanceBtw2Pts(PC,PA); if (CA > maxLength) maxLength = CA; double perim( (AB+BC+CA)*0.5 ); double num( 2*sqrt(perim*(perim-AB)*(perim-BC)*(perim-CA)) ); res[0] = num/AB; res[1] = num/BC; res[2] = num/CA; + if (AB/maxLength <= EPS) + res[0] = BC; + if (BC/maxLength <= EPS) + res[1] = CA; + if (CA/maxLength <= EPS) + res[3] = AB; } } -- 2.39.2