Improve contour FindPointInPolygon() reliability (3).

This commit is contained in:
wo80
2022-02-28 11:47:26 +01:00
parent 227e9d9c66
commit e8ca95960f
2 changed files with 22 additions and 0 deletions
@@ -63,5 +63,24 @@ namespace TriangleNet.Tests.Geometry
i = j;
}
}
[Test]
public void TestFindInteriorPointDup()
{
// Rectangle contour with duplicate point.
var points = new List<Vertex>()
{
new Vertex(0.0, 0.0),
new Vertex(0.0, 1.0),
new Vertex(2.0, 1.0),
new Vertex(2.0, 0.5),
new Vertex(2.0, 0.5), // duplicate
new Vertex(2.0, 0.0)
};
var contour = new Contour(points);
Assert.DoesNotThrow(() => contour.FindInteriorPoint());
}
}
}
+3
View File
@@ -36,6 +36,9 @@ namespace TriangleNet.Tools
// Length of the segment.
double ab = (b.X - a.X) * (b.X - a.X) + (b.Y - a.Y) * (b.Y - a.Y);
// Ignore duplicate input points.
if (ab == 0) return false;
// Check if test point is actually between a and b (right of b).
if (dot > ab) return false;