예제 #1
0
        public bool IntersectCurves()
        {
            bool flag = false;

            if (this.curve1 == null || this.curve2 == null || this.curve1 == this.curve2)
            {
                return(false);
            }
            RectangleF rect1 = (RectangleF) new Rectangle();
            RectangleF rect2 = (RectangleF) new Rectangle();

            this.curveIntersections.Clear();
            for (int index1 = 0; index1 < this.curve1.Points.Length - 1; ++index1)
            {
                rect1 = this.SegmentBoundingRect(rect1, this.curve1.Points[index1], this.curve1.Points[index1 + 1]);
                for (int index2 = 0; index2 < this.curve2.Points.Length - 1; ++index2)
                {
                    rect2 = this.SegmentBoundingRect(rect2, this.curve2.Points[index2], this.curve2.Points[index2 + 1]);
                    rect2.Intersect(rect1);
                    PointF res;
                    if (!rect2.IsEmpty && ShapesIntersection.IntersectSegment(out res, this.curve1.Points[index1].Location, this.curve1.Points[index1 + 1].Location, this.curve2.Points[index2].Location, this.curve2.Points[index2 + 1].Location))
                    {
                        this.curveIntersections.Add(res);
                    }
                }
            }
            return(flag);
        }
예제 #2
0
 public static bool IntersectSegment(out PointF res, PointF a, PointF b, PointF c, PointF d)
 {
     ShapesIntersection.Intersect(out res, a, b, c, d);
     return((double)res.X >= (double)Math.Min(a.X, b.X) && (double)res.X <= (double)Math.Max(a.X, b.X) && ((double)res.Y >= (double)Math.Min(a.Y, b.Y) && (double)res.Y <= (double)Math.Max(a.Y, b.Y)) && ((double)res.X >= (double)Math.Min(c.X, d.X) && (double)res.X <= (double)Math.Max(c.X, d.X) && ((double)res.Y >= (double)Math.Min(c.Y, d.Y) && (double)res.Y <= (double)Math.Max(c.Y, d.Y))));
 }