Skip to content
Snippets Groups Projects
Commit b3f99d70 authored by Karsten Rink's avatar Karsten Rink
Browse files

added second eps to old function to unify interface

parent 985bf1de
No related branches found
No related tags found
No related merge requests found
...@@ -213,7 +213,7 @@ bool isPointInTriangle(GeoLib::Point const& p, ...@@ -213,7 +213,7 @@ bool isPointInTriangle(GeoLib::Point const& p,
case GeoLib::BARYCENTRIC: case GeoLib::BARYCENTRIC:
return barycentricPointInTriangle(p, a, b, c, eps_pnt_out_of_plane, eps_pnt_out_of_tri); return barycentricPointInTriangle(p, a, b, c, eps_pnt_out_of_plane, eps_pnt_out_of_tri);
default: 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; return false;
} }
...@@ -222,7 +222,8 @@ bool gaussPointInTriangle(GeoLib::Point const& q, ...@@ -222,7 +222,8 @@ bool gaussPointInTriangle(GeoLib::Point const& q,
GeoLib::Point const& a, GeoLib::Point const& a,
GeoLib::Point const& b, GeoLib::Point const& b,
GeoLib::Point const& c, 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 v(a, b);
MathLib::Vector3 const w(a, c); MathLib::Vector3 const w(a, c);
...@@ -240,7 +241,7 @@ bool gaussPointInTriangle(GeoLib::Point const& q, ...@@ -240,7 +241,7 @@ bool gaussPointInTriangle(GeoLib::Point const& q,
MathLib::GaussAlgorithm<MathLib::DenseMatrix<double>, double*> gauss(mat); MathLib::GaussAlgorithm<MathLib::DenseMatrix<double>, double*> gauss(mat);
gauss.solve(y); gauss.solve(y);
const double lower (std::numeric_limits<float>::epsilon()); const double lower (eps_pnt_out_of_tri);
const double upper (1 + lower); const double upper (1 + lower);
if (-lower <= y[0] && y[0] <= upper && -lower <= y[1] && y[1] <= upper && y[0] + y[1] <= 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, ...@@ -250,7 +251,7 @@ bool gaussPointInTriangle(GeoLib::Point const& q,
a[1] + y[0] * v[1] + y[1] * w[1], a[1] + y[0] * v[1] + y[1] * w[1],
a[2] + y[0] * v[2] + y[1] * w[2] 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; return true;
} }
......
...@@ -147,12 +147,15 @@ bool isPointInTriangle(GeoLib::Point const& p, ...@@ -147,12 +147,15 @@ bool isPointInTriangle(GeoLib::Point const& p,
* @param a edge node of triangle * @param a edge node of triangle
* @param b edge node of triangle * @param b edge node of triangle
* @param c 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 * @return true if the test point p is within the 'epsilon'-neighbourhood of the triangle
*/ */
bool gaussPointInTriangle(GeoLib::Point const& p, bool gaussPointInTriangle(GeoLib::Point const& p,
GeoLib::Point const& a, GeoLib::Point const& b, GeoLib::Point const& c, 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. * Tests if the given point p is within the triangle, defined by its edge nodes a, b and c.
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment