Esempio n. 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);
            }
                                )
                   );
        }