From 9b24748e8caf0278e7f470d0f36a9abb5088fc7c Mon Sep 17 00:00:00 2001 From: Christophe Geuzaine <cgeuzaine@ulg.ac.be> Date: Mon, 18 Dec 2000 08:31:58 +0000 Subject: [PATCH] sys3x3_with_tol --- Mesh/2D_Mesh.cpp | 4 ++-- Mesh/Numeric.cpp | 16 +++++++++++++++- Mesh/Numeric.h | 3 ++- 3 files changed, 19 insertions(+), 4 deletions(-) diff --git a/Mesh/2D_Mesh.cpp b/Mesh/2D_Mesh.cpp index d704da617c..dbde0bbdc5 100644 --- a/Mesh/2D_Mesh.cpp +++ b/Mesh/2D_Mesh.cpp @@ -1,4 +1,4 @@ -/* $Id: 2D_Mesh.cpp,v 1.12 2000-12-13 20:21:48 geuzaine Exp $ */ +/* $Id: 2D_Mesh.cpp,v 1.13 2000-12-18 08:31:58 geuzaine Exp $ */ /* Maillage Delaunay d'une surface (Point insertion Technique) @@ -168,7 +168,7 @@ void Plan_Moyen (void *data, void *dum){ /* by + cz = -x */ - else if (!sys3x3 (sys, b, res, &det)){ + else if (!sys3x3_with_tol (sys, b, res, &det)){ s->d = 0.0; s2s[0][0] = sys[1][1]; s2s[0][1] = sys[1][2]; diff --git a/Mesh/Numeric.cpp b/Mesh/Numeric.cpp index 682821d93c..2e57513a0f 100644 --- a/Mesh/Numeric.cpp +++ b/Mesh/Numeric.cpp @@ -1,4 +1,4 @@ -/* $Id: Numeric.cpp,v 1.9 2000-12-13 20:27:12 geuzaine Exp $ */ +/* $Id: Numeric.cpp,v 1.10 2000-12-18 08:31:58 geuzaine Exp $ */ #include "Gmsh.h" #include "Const.h" @@ -121,6 +121,20 @@ int sys3x3 (double mat[3][3], double b[3], double res[3], double *det){ } +int sys3x3_with_tol (double mat[3][3], double b[3], double res[3], double *det){ + int out; + + out = sys3x3(mat,b,res,det); + + if (fabs(*det) < 1.e-12){ + Msg(INFOS, "Assuming 3x3 Matrix is Singular (Is this OK?)"); + res[0] = res[1] = res[2] = 0.0 ; + return (0); + } + + return out ; +} + int det3x3 (double mat[3][3], double *det){ *det = mat[0][0] * (mat[1][1] * mat[2][2] - mat[1][2] * mat[2][1]) - mat[0][1] * (mat[1][0] * mat[2][2] - mat[1][2] * mat[2][0]) + diff --git a/Mesh/Numeric.h b/Mesh/Numeric.h index e788964a5c..905141c96c 100644 --- a/Mesh/Numeric.h +++ b/Mesh/Numeric.h @@ -1,4 +1,4 @@ -/* $Id: Numeric.h,v 1.3 2000-11-26 15:43:47 geuzaine Exp $ */ +/* $Id: Numeric.h,v 1.4 2000-12-18 08:31:58 geuzaine Exp $ */ #ifndef _NUMERIC_H_ #define _NUMERIC_H_ @@ -11,6 +11,7 @@ void direction (Vertex * v1, Vertex * v2, double d[3]); void Projette (Vertex * v, double mat[3][3]); int sys2x2 (double mat[2][2], double b[2], double res[2]); int sys3x3 (double mat[3][3], double b[3], double res[3], double *det); +int sys3x3_with_tol (double mat[3][3], double b[3], double res[3], double *det); int det3x3 (double mat[3][3], double *det); int inv3x3 (double mat[3][3], double inv[3][3], double *det); void find_bestuv (Surface * s, double X, double Y, -- GitLab