Esempio n. 1
0
        /// <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);
        }
Esempio n. 2
0
        /// <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);
        }