Skip to content
Snippets Groups Projects
Commit 4e1e7ace authored by Tom Fischer's avatar Tom Fischer
Browse files

[GeoLib] Polygon::containsSegment(): Introduced tol variable.

Using the tol (tolerance) variable makes the code more readable.
parent 5078140c
No related branches found
No related tags found
No related merge requests found
......@@ -137,15 +137,17 @@ bool Polygon::containsSegment(GeoLib::Point const& a, GeoLib::Point const& b) co
return (isPntInPolygon(a));
}
const double tol(std::numeric_limits<float>::epsilon());
// one intersection, intersection in line segment end point
if (s.size() == 1) {
const double sqr_dist_as(MathLib::sqrDist(a,s[0]));
if (sqr_dist_as < std::numeric_limits<float>::epsilon()) {
if (sqr_dist_as < tol) {
return (isPntInPolygon(b));
}
const double sqr_dist_bs(MathLib::sqrDist(b,s[0]));
if (sqr_dist_bs < std::numeric_limits<float>::epsilon()) {
if (sqr_dist_bs < tol) {
return (isPntInPolygon(a));
}
}
......@@ -160,7 +162,7 @@ bool Polygon::containsSegment(GeoLib::Point const& a, GeoLib::Point const& b) co
// remove sub segments with almost zero length
for (std::size_t k(0); k<s.size()-1; ) {
if (MathLib::sqrDist(s[k], s[k+1]) < std::numeric_limits<float>::epsilon()) {
if (MathLib::sqrDist(s[k], s[k+1]) < tol) {
s.erase(s.begin()+k+1);
} else {
k++;
......
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