Esempio n. 1
0
        public static IntersectionResult ParaoblaPolyLine(GCurve c, GPolyLine pl)
        {
            IntersectionResult result = new IntersectionResult();

            foreach (var line in pl.Lines)
            {
                var temp = CurveLine(c, line);
                if (temp.IntersectionPoints.Count != 0)

                {
                    result.IntersectionPoints.AddRange(temp.IntersectionPoints);
                }
            }
            return(result);
        }
Esempio n. 2
0
        public static IntersectionResult ParabolaRectangle(GCurve c, GRectangle r)
        {
            IntersectionResult result = new IntersectionResult();

            foreach (var line in r.Lines)
            {
                var temp = CurveLine(c, line);
                if (temp.IntersectionPoints.Count != 0)

                {
                    result.IntersectionPoints.AddRange(temp.IntersectionPoints);
                }
            }
            return(result);
        }
Esempio n. 3
0
        public static IntersectionResult CurveCircle(GCurve c, GCurve pl)
        {
            IntersectionResult result = new IntersectionResult();

            //foreach (var line in pl.Lines)
            //{
            //    var temp = CurveLine(c, line);
            //    if (temp.IntersectionPoints.Count != 0)

            //    {
            //        result.IntersectionPoints.AddRange(temp.IntersectionPoints);
            //    }
            //}
            return(result);
        }
Esempio n. 4
0
        /// <summary>
        /// use  Divide & Conquer Algorithm
        /// </summary>
        /// <param name="c1">Curve 1</param>
        /// <param name="c2">Curve 2</param>
        /// <returns></returns>
        /// http://processingjs.nihongoresources.com/intersections/
        public static IntersectionResult CurveCurve(GCurve c1, GCurve c2)
        {
            IntersectionResult result = new IntersectionResult();
            var coll = c1.Collider.Collide(c2.Collider);

            if (c1.Collider.Area >= GCurve.minCurveSegment &&
                c1.Collider.Area >= GCurve.minCurveSegment && c1.Collider.Collide(c2.Collider) && coll)
            {
                var set1 = c1.Divide();
                var set2 = c2.Divide();
                foreach (var s1 in set1)
                {
                    foreach (var s2 in set2)
                    {
                        result.IntersectionPoints.AddRange(CurveCurve(s1, s2).IntersectionPoints);
                    }
                }

                return(result);
            }
            //if true treat them as line
            else if (c1.Collider.Area <= GCurve.minCurveSegment &&
                     c1.Collider.Area <= GCurve.minCurveSegment && c1.Collider.Collide(c2.Collider))
            {
                var l1  = new GLine(c1.Start, c1.End);
                var l2  = new GLine(c2.Start, c2.End);
                var res = LineLine(l1, l2);
                if (res.IntersectionPoints.Count != 0)
                {
                    result.IntersectionPoints.AddRange(res.IntersectionPoints);
                }
                return(result);
            }
            //there are no intersection points between the two curves
            else
            {
                return(result);
            }
        }
Esempio n. 5
0
        public static IntersectionResult CurveLine(GCurve c, GLine l)
        {
            IntersectionResult result = new IntersectionResult();
            var l1    = new GLine(c.Center, c.Start);
            var l2    = new GLine(c.Center, c.End);
            var lines = new List <GLine>();

            lines.AddRange(Divide(l1, .25f));
            lines.AddRange(Divide(l2, .25f));
            //intersect line 1
            IntersectionResult temp;

            foreach (var line in lines)
            {
                temp = LineLine(l, line);
                if (temp.IntersectionPoints.Count != 0)
                {
                    result.IntersectionPoints.AddRange(temp.IntersectionPoints);
                }
            }

            return(result);
        }