diff --git a/GeoLib/AnalyticalGeometry.cpp b/GeoLib/AnalyticalGeometry.cpp index 40cffffc1a71f1ad70c1eade4ca13a2421cfe7bd..af0a75929bf0822642adb81b2096585bea8d58fa 100644 --- a/GeoLib/AnalyticalGeometry.cpp +++ b/GeoLib/AnalyticalGeometry.cpp @@ -213,7 +213,7 @@ bool isPointInTriangle(GeoLib::Point const& p, case GeoLib::BARYCENTRIC: return barycentricPointInTriangle(p, a, b, c, eps_pnt_out_of_plane, eps_pnt_out_of_tri); default: - return gaussPointInTriangle(p, a, b, c, eps_pnt_out_of_plane); + return gaussPointInTriangle(p, a, b, c, eps_pnt_out_of_plane, eps_pnt_out_of_tri); } return false; } @@ -222,7 +222,8 @@ bool gaussPointInTriangle(GeoLib::Point const& q, GeoLib::Point const& a, GeoLib::Point const& b, GeoLib::Point const& c, - double eps) + double eps_pnt_out_of_plane, + double eps_pnt_out_of_tri) { MathLib::Vector3 const v(a, b); MathLib::Vector3 const w(a, c); @@ -240,7 +241,7 @@ bool gaussPointInTriangle(GeoLib::Point const& q, MathLib::GaussAlgorithm<MathLib::DenseMatrix<double>, double*> gauss(mat); gauss.solve(y); - const double lower (std::numeric_limits<float>::epsilon()); + const double lower (eps_pnt_out_of_tri); const double upper (1 + lower); if (-lower <= y[0] && y[0] <= upper && -lower <= y[1] && y[1] <= upper && y[0] + y[1] <= @@ -250,7 +251,7 @@ bool gaussPointInTriangle(GeoLib::Point const& q, a[1] + y[0] * v[1] + y[1] * w[1], a[2] + y[0] * v[2] + y[1] * w[2] ); - if (MathLib::sqrDist(q, q_projected) < eps) + if (MathLib::sqrDist(q, q_projected) < eps_pnt_out_of_plane) return true; } diff --git a/GeoLib/AnalyticalGeometry.h b/GeoLib/AnalyticalGeometry.h index 2cc1c30ea6c5877322069b7c30fa8ef8b46d8243..cb2708a9451dd925b618ca17f91133dbca989ff4 100644 --- a/GeoLib/AnalyticalGeometry.h +++ b/GeoLib/AnalyticalGeometry.h @@ -147,12 +147,15 @@ bool isPointInTriangle(GeoLib::Point const& p, * @param a edge node of triangle * @param b edge node of triangle * @param c edge node of triangle - * @param eps size of neighbourhood (orthogonal distance to the plane spaned by triangle) + * @param eps_pnt_out_of_plane eps allowing for p to be slightly off the plane spanned by abc + * ((orthogonal distance to the plane spaned by triangle) + * @param eps_pnt_out_of_tri eps allowing for p to be slightly off outside of abc * @return true if the test point p is within the 'epsilon'-neighbourhood of the triangle */ bool gaussPointInTriangle(GeoLib::Point const& p, GeoLib::Point const& a, GeoLib::Point const& b, GeoLib::Point const& c, - double eps = std::numeric_limits<float>::epsilon()); + double eps_pnt_out_of_plane = std::numeric_limits<float>::epsilon(), + double eps_pnt_out_of_tri = std::numeric_limits<float>::epsilon()); /** * Tests if the given point p is within the triangle, defined by its edge nodes a, b and c.