Fixed a numerical issue leading to an infinite loop on some compilers

This commit is contained in:
Matthias Koefferlein 2024-01-23 16:31:46 +01:00
parent cb3d7bc5f3
commit 6ad1f3f73f
2 changed files with 2 additions and 2 deletions

View File

@ -491,7 +491,7 @@ Triangles::find_closest_edge (const db::DPoint &p, db::Vertex *vstart, bool insi
db::DVector r = p - *cv;
double edge_sp = db::sprod (r, edge_d) / edge_d.length ();
double s_sp = db::sprod (r, e_d) / e_d.length ();
if (s_sp > edge_sp) {
if (s_sp > edge_sp + db::epsilon) {
edge = *e;
vnext = edge->other (v);
}

View File

@ -126,7 +126,7 @@ TEST(insert_vertex_convex)
tris.insert_point (0.6, 0.5);
tris.insert_point (0.7, 0.5);
tris.insert_point (0.6, 0.4);
EXPECT_EQ (tris.to_string (), "((0.2, 0.2), (0.2, 0.8), (0.6, 0.5)), ((0.7, 0.5), (0.6, 0.5), (0.2, 0.8)), ((0.6, 0.5), (0.6, 0.4), (0.2, 0.2)), ((0.6, 0.5), (0.7, 0.5), (0.6, 0.4))");
EXPECT_EQ (tris.to_string (), "((0.2, 0.2), (0.2, 0.8), (0.6, 0.5)), ((0.2, 0.8), (0.7, 0.5), (0.6, 0.5)), ((0.6, 0.4), (0.6, 0.5), (0.7, 0.5)), ((0.6, 0.4), (0.2, 0.2), (0.6, 0.5))");
EXPECT_EQ (tris.check(), true);
}