/** * This method tests if the point is on the edge. */ public bool PointInEdge(Point2d p, double epsilon = MathUtils.EPSILON) { if (!this.BoundingBox.IsInterior(p, epsilon)) { return(false); } return(PolygonUtils.PointInEdge(this.Vertices, p, this.robust, epsilon)); }
public void TestPointInEdge() { IList <Point2d> points = AsList(new Point2d(10, 0), new Point2d(10, 10), new Point2d(0, 10), new Point2d(0, 0)); Assert.IsTrue(PolygonUtils.PointInEdge(points, new Point2d(5, 0), true, MathUtils.EPSILON)); Assert.IsTrue(PolygonUtils.PointInEdge(points, new Point2d(10, 5), true, MathUtils.EPSILON)); Assert.IsTrue(PolygonUtils.PointInEdge(points, new Point2d(5, 10), true, MathUtils.EPSILON)); Assert.IsTrue(PolygonUtils.PointInEdge(points, new Point2d(0, 5), true, MathUtils.EPSILON)); Assert.IsFalse(PolygonUtils.PointInEdge(points, new Point2d(5, 5), true, MathUtils.EPSILON)); Assert.IsFalse(PolygonUtils.PointInEdge(points, new Point2d(5, 15), true, MathUtils.EPSILON)); Assert.IsFalse(PolygonUtils.PointInEdge(points, new Point2d(5, -5), true, MathUtils.EPSILON)); // Using epsilon. Assert.IsFalse(PolygonUtils.PointInEdge(points, new Point2d(5, 5), true, 4.9)); Assert.IsTrue(PolygonUtils.PointInEdge(points, new Point2d(5, 5), true, 5)); }