public static double BezierSextic(double t, double a, double b, double c, double d, double e, double f, double g)
        {
            var abcdef = InterpolateBezierQuintic1DTests.BezierQuintic(t, a, b, c, d, e, f);
            var bcdefg = InterpolateBezierQuintic1DTests.BezierQuintic(t, b, c, d, e, f, g);

            return(InterpolateLinear1DTests.BezierLinear(t, abcdef, bcdefg));
        }
        public static double BezierQuadratic(double t, double A, double B, double C)
        {
            var AB = InterpolateLinear1DTests.BezierLinear(t, A, B);
            var BC = InterpolateLinear1DTests.BezierLinear(t, B, C);

            return(InterpolateLinear1DTests.BezierLinear(t, AB, BC));
        }
예제 #3
0
        public static double BezierQuintic(double t, double a, double b, double c, double d, double e, double f)
        {
            var abcde = InterpolateBezierQuartic1DTests.BezierQuartic(t, a, b, c, d, e);
            var bcdef = InterpolateBezierQuartic1DTests.BezierQuartic(t, b, c, d, e, f);

            return(InterpolateLinear1DTests.BezierLinear(t, abcde, bcdef));
        }
        public static double BezierCubic(double t, double A, double B, double C, double D)
        {
            var ABC = InterpolateBezierQuadratic1DTests.BezierQuadratic(t, A, B, C);
            var BCD = InterpolateBezierQuadratic1DTests.BezierQuadratic(t, B, C, D);

            return(InterpolateLinear1DTests.BezierLinear(t, ABC, BCD));
        }
예제 #5
0
        public static double BezierQuartic(double t, double a, double b, double c, double d, double e)
        {
            var abcd = InterpolateBezierCubic1DTests.BezierCubic(t, a, b, c, d);
            var bcde = InterpolateBezierCubic1DTests.BezierCubic(t, b, c, d, e);

            return(InterpolateLinear1DTests.BezierLinear(t, abcd, bcde));
        }
예제 #6
0
 public static (double X, double Y, double Z) LinearInterpolate3D2(double t, double x1, double y1, double z1, double x2, double y2, double z2)
 {
     return(
         InterpolateLinear1DTests.LinearInterpolate1D(t, x1, x2),
         InterpolateLinear1DTests.LinearInterpolate1D(t, y1, y2),
         InterpolateLinear1DTests.LinearInterpolate1D(t, z1, z2)
         );
 }
        public static double QuadraticBezierInterpolate1D1(double t, double v0, double v1, double v2)
        {
            // point between a and b
            var ab = InterpolateLinear1DTests.LinearInterpolate1D(t, v0, v1);

            // point between b and c
            var bc = InterpolateLinear1DTests.LinearInterpolate1D(t, v1, v2);

            // point on the bezier-curve
            return(InterpolateLinear1DTests.LinearInterpolate1D(t, ab, bc));
        }
        public static Point2D Envelope1(
            Point2D point,
            Rectangle2D bounds,
            Point2D topLeft, Point2D topLeftH, Point2D topLeftV,
            Point2D topRight, Point2D topRightH, Point2D topRightV,
            Point2D bottomRight, Point2D bottomRightH, Point2D bottomRightV,
            Point2D bottomLeft, Point2D bottomLeftH, Point2D bottomLeftV)
        {
            var norm   = NormalizeBoundedPoint2DTests.NormalizePoint(bounds, point);
            var left   = InterpolateBezierCubic1DTests.CubicBezier(norm.Y, topLeft.X, topLeftV.X, bottomLeftV.X, bottomLeft.X);
            var right  = InterpolateBezierCubic1DTests.CubicBezier(norm.Y, topRight.X, topRightV.X, bottomRightV.X, bottomRight.X);
            var top    = InterpolateBezierCubic1DTests.CubicBezier(norm.X, topLeft.Y, topLeftH.Y, topRightH.Y, topRight.Y);
            var bottom = InterpolateBezierCubic1DTests.CubicBezier(norm.X, bottomLeft.Y, bottomLeftH.Y, bottomRightH.Y, bottomRight.Y);
            var x      = InterpolateLinear1DTests.LinearInterpolate1D(norm.X, left, right);
            var y      = InterpolateLinear1DTests.LinearInterpolate1D(norm.Y, top, bottom);

            return(new Point2D(x, y));
        }
예제 #9
0
        public static Intersection QuadraticBezierLineSegmentIntersection1(
            double p1X, double p1Y,
            double p2X, double p2Y,
            double p3X, double p3Y,
            double a1X, double a1Y,
            double a2X, double a2Y,
            double epsilon = Epsilon)
        {
            _ = epsilon;
            var intersections = new Intersection(IntersectionStates.NoIntersection);

            // inverse line normal
            var normal = new Point2D(a1Y - a2Y, a2X - a1X);

            // Q-coefficients
            var c2 = new Point2D(p1X + (p2X * -2) + p3X, p1Y + (p2Y * -2) + p3Y);
            var c1 = new Point2D((p1X * -2) + (p2X * 2), (p1Y * -2) + (p2Y * 2));
            var c0 = new Point2D(p1X, p1Y);

            // Transform to line
            var coefficient = (a1X * a2Y) - (a2X * a1Y);
            var a           = (normal.X * c2.X) + (normal.Y * c2.Y);
            var b           = ((normal.X * c1.X) + (normal.Y * c1.Y)) / a;
            var c           = ((normal.X * c0.X) + (normal.Y * c0.Y) + coefficient) / a;

            // solve the roots
            var roots = new List <double>();
            var d     = (b * b) - (4 * c);

            if (d > 0)
            {
                var e = Sqrt(d);
                roots.Add((-b + Sqrt(d)) / 2d);
                roots.Add((-b - Sqrt(d)) / 2d);
            }
            else if (d == 0)
            {
                roots.Add(-b / 2d);
            }

            // Calculate the solution points
            for (var i = 0; i < roots.Count; i++)
            {
                var minX = Min(a1X, a2X);
                var minY = Min(a1Y, a2Y);
                var maxX = Max(a1X, a2X);
                var maxY = Max(a1Y, a2Y);
                var t    = roots[i];
                if (t >= 0 && t <= 1)
                {
                    // Possible point -- pending bounds check
                    var point = new Point2D(
                        InterpolateLinear1DTests.LinearInterpolate1D(t, InterpolateLinear1DTests.LinearInterpolate1D(t, p1X, p2X), InterpolateLinear1DTests.LinearInterpolate1D((double)t, (double)p2X, (double)p3X)),
                        InterpolateLinear1DTests.LinearInterpolate1D(t, InterpolateLinear1DTests.LinearInterpolate1D(t, p1Y, p2Y), InterpolateLinear1DTests.LinearInterpolate1D(t, p2Y, p3Y)));
                    var x      = point.X;
                    var y      = point.Y;
                    var result = new Intersection(IntersectionStates.Intersection);
                    // bounds checks
                    if (a1X == a2X && y >= minY && y <= maxY)
                    {
                        // vertical line
                        intersections.AppendPoint(point);
                    }
                    else if (a1Y == a2Y && x >= minX && x <= maxX)
                    {
                        // horizontal line
                        intersections.AppendPoint(point);
                    }
                    else if (x >= minX && y >= minY && x <= maxX && y <= maxY)
                    {
                        // line passed bounds check
                        intersections.AppendPoint(point);
                    }
                }
            }
            return(intersections);
        }