This repository was archived by the owner on Oct 2, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 110
Triangulation fails if there are almost colinear points in input #32
Copy link
Copy link
Open
Description
This test:
TEST_CASE( "Delaunay triangulation should be able to handle 3 almost colinear points", "[DelaunayTest]" ) {
std::vector<Vector2<double>> points;
points.push_back(Vector2<double>{0.0, 0.0});
points.push_back(Vector2<double>{1000.0, 0.0});
points.push_back(Vector2<double>{2000.0, 40.0});
Delaunay<double> triangulation;
const std::vector<Triangle<double>> triangles = triangulation.triangulate(points);
REQUIRE(1 == triangles.size());
}Fails because no triangle is found. Note that this is just one example - it's very easy to interactively generate arbitrary input data which doesn't get triangulated properly. It also happens with more than three points, then some triangles are generated, but some of the points are left unconnected.
Although three colinear points are not a valid triangle, I still see two critical issues:
- Compared to floating point accuracy, these points are not really almost a triangle. It's even obvious for a human eye that this is a totally valid triangle:

- The library does not report any failure if it did not connect some of the input points. Depending on the use case, it is extremely important to know if the triangulation failed (e.g. to use an alternative fallback algorithm to still handle all points somehow). But the library silently ignores some of the input points so the user is not able to detect and handle this situation properly.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels