示例#1
0
        public List <Vector2d> FindIntersections(Polygon2d o)
        {
            List <Vector2d> v = new List <Vector2d>();

            if (!this.GetBounds().Intersects(o.GetBounds()))
            {
                return(v);
            }

            foreach (Segment2d seg in SegmentItr())
            {
                foreach (Segment2d oseg in o.SegmentItr())
                {
                    IntrSegment2Segment2 intr = new IntrSegment2Segment2(seg, oseg);
                    if (intr.Find())
                    {
                        v.Add(intr.Point0);
                        if (intr.Quantity == 2)
                        {
                            v.Add(intr.Point1);
                        }
                        break;
                    }
                }
            }
            return(v);
        }
示例#2
0
        public bool Intersects(Polygon2d o)
        {
            if (!this.GetBounds().Intersects(o.GetBounds()))
            {
                return(false);
            }

            foreach (Segment2d seg in SegmentItr())
            {
                foreach (Segment2d oseg in o.SegmentItr())
                {
                    IntrSegment2Segment2 intr = new IntrSegment2Segment2(seg, oseg);
                    if (intr.Find())
                    {
                        return(true);
                    }
                }
            }
            return(false);
        }
 public override AxisAlignedBox2d Bounds()
 {
     return(polygon.GetBounds());
 }