예제 #1
0
        public static double?tryIntersectWithBezier(CubicBezier bezier, BezierEnd end, Func <Point, bool> isPointInside)
        {
            double start = end == BezierEnd.Start ? 0.0 : 1.0;
            double fin   = end == BezierEnd.Start ? 1 : 0;

            // bisect always returns a valid value.

            return(linearBisect(start, fin, DefaultIntersectionIterations,
                                (a, b) =>
            {
                var p1 = bezier.AtT(a);
                var p2 = bezier.AtT(b);
                return (p2 - p1).Length() > DefaultIntersectionTolerance;
            },
                                (h) =>
            {
                var p = bezier.AtT(h);
                return isPointInside(p);
            }
                                )
                   );
        }
예제 #2
0
        public static double? tryIntersectWithBezier(CubicBezier bezier, BezierEnd end, Func<Point, bool> isPointInside)
        {
            double start = end == BezierEnd.Start ? 0.0 : 1.0;
            double fin = end == BezierEnd.Start ? 1 : 0;

            // bisect always returns a valid value.

            return linearBisect(start, fin, DefaultIntersectionIterations,
                (a, b) =>
                {
                    var p1 = bezier.AtT(a);
                    var p2 = bezier.AtT(b);
                    return (p2 - p1).Length() > DefaultIntersectionTolerance;
                },
                (h) =>
                {
                    var p = bezier.AtT(h);
                    return isPointInside(p);
                }
            )
            ;
        }
예제 #3
0
        /*
         *      Intersect a geometry with a bezier.
         *      Assumes that the given bezier end is inside the geometry.
         */

        public static double?TryIntersectWithBezier(this IGeometry geometry, CubicBezier bezier, BezierEnd insideEnd)
        {
            return(tryIntersectWithBezier(bezier, insideEnd, v => geometry.Contains(v.X, v.Y)));
        }
예제 #4
0
 /*
     Intersect a geometry with a bezier.
     Assumes that the given bezier end is inside the geometry.
 */
 public static double? TryIntersectWithBezier(this IGeometry geometry, CubicBezier bezier, BezierEnd insideEnd)
 {
     return tryIntersectWithBezier(bezier, insideEnd, v => geometry.Contains(v.X, v.Y));
 }