/// <summary> /// Returns true if any part of this wedge overlaps any part of wedge <paramref name='b'/>. /// </summary> public bool Overlaps(WWedge b) { WWedge a = this; WPoint[] intersections = a.Circle.GetIntersectionPoints(b.Circle); if (intersections == null) { if (!a.Circle.ContainsOrIsContained(b.Circle)) { return(false); } } //line edge overlaps line edge foreach (WLineSegment lineA in this.LineEdges) { foreach (WLineSegment lineB in b.LineEdges) { if (lineA.Overlaps(lineB)) { return(true); } } } //arc overlaps line edge foreach (WLineSegment lineA in this.LineEdges) { if (b.ArcOverlaps(lineA)) { return(true); } } foreach (WLineSegment lineB in b.LineEdges) { if (a.ArcOverlaps(lineB)) { return(true); } } //arc overlaps arc if (a.ArcOverlapsArc(b)) { return(true); } //one wedge entirely contains the other (all three points from one wedge inside the other) // there are cases where all three points are inside, but arc protrudes outside - not important here since that still counts as overlapping if (Contains(b.Circle.Center)) { if (Contains(b.StartPoint)) { if (Contains(b.EndPoint)) { return(true); } } } return(false); }
/// <summary> /// Returns true if this circle entirely contains wedge <paramref name='b'/>. /// </summary> public bool Contains(WWedge b) { foreach (WPoint point in b.FourPoints) { if (!Contains(point)) { return(false); } } return(true); }
/// <summary> /// Returns true if this arc overlaps any part of <paramref name='b'/>'s arc. /// </summary> public bool ArcOverlapsArc(WWedge b) { WWedge a = this; WPoint[] fullCircleIntersections = a.Circle.GetIntersectionPoints(b.Circle); if (fullCircleIntersections == null) { return(false); } foreach (WPoint point in fullCircleIntersections) { if (a.Circle.Center == point || a.Degrees.Overlaps(a.Circle.DegreesAtPoint(point))) { if (b.Circle.Center == point || b.Degrees.Overlaps(b.Circle.DegreesAtPoint(point))) { return(true); } } } return(false); }
/// <summary> /// Returns true if any part of this wedge overlaps any part of circle <paramref name='b'/>. /// </summary> public bool Overlaps(WCircle b) { WWedge a = this; WPoint[] intersections = a.Circle.GetIntersectionPoints(b); if (intersections == null) { if (!a.Circle.ContainsOrIsContained(b)) { return(false); } } //line edge overlaps circle foreach (WLineSegment lineA in this.LineEdges) { if (b.Overlaps(lineA)) { return(true); } } //arc overlaps circle if (a.ArcOverlapsArc(new WWedge(b, 0, WCircle.DEGREES_IN_CIRCLE))) { return(true); } //wedge entirely contains circle or circle entirely contains wedge if (a.Contains(b)) { return(true); } if (b.Contains(a)) { return(true); } return(false); }