Skip to content

Commit

Permalink
Fixed a numerical issue leading to an infinite loop on some compilers
Browse files Browse the repository at this point in the history
  • Loading branch information
Matthias Koefferlein committed Jan 23, 2024
1 parent cb3d7bc commit 6ad1f3f
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/db/db/dbTriangles.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
2 changes: 1 addition & 1 deletion src/db/unit_tests/dbTrianglesTests.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down

0 comments on commit 6ad1f3f

Please sign in to comment.