public override Point[] Intersect(ShapeGeometry other) { switch (other) { case LineGeometry line: return(IntersectionHelper.LineCircleIntersection(line, this)); case CircleGeometry circle: return(IntersectionHelper.CircleCircleIntersection(this, circle)); case PolygonGeometry polygon: return(IntersectionHelper.GeometryPolygonIntersection(this, polygon)); default: return(new Point[0]); } }
public static Point[] GeometryPolygonIntersection(ShapeGeometry geometry, PolygonGeometry polygon) { if (geometry == null || polygon == null) { return(null); } if (!geometry.Bounds.IntersectsWith(polygon.Bounds)) { return(new Point[0]); } LineGeometry[] edges = polygon.Edges; Point[] intersections = null; foreach (LineGeometry edge in edges) { intersections = intersections == null ? geometry.Intersect(edge) : intersections.Union(geometry.Intersect(edge)).ToArray(); } return(intersections); }
public abstract Point[] Intersect(ShapeGeometry other);