Esempio n. 1
0
        public static ICurve <V> Bezier2 <V>(this IVectorSpace <Fraction, V> space, IArray <V> vectors)
        {
            return(new Curve <V>(
                       atF: scale =>
            {
                if (vectors.Size == 0)
                {
                    return space.Zero;
                }

                if (vectors.Size == 1)
                {
                    return vectors[0];
                }

                var left = space.Bezier2(vectors.Range(0, vectors.Size - 1))[scale];
                var right = space.Bezier2(vectors.Range(1, vectors.Size))[scale];

                return space.Interpolate(left, right)(scale);
            }));
        }
Esempio n. 2
0
        public static ICurve <V> Bezier1 <V>(this IVectorSpace <Fraction, V> space, IArray <V> vectors)
        {
            return(new Curve <V>(
                       atF: scale =>
            {
                if (vectors.Size == 0)
                {
                    return space.Zero;
                }

                if (vectors.Size == 1)
                {
                    return vectors[0];
                }

                IArray <V> segments = new Array <V>(
                    size: vectors.Size - 1U,
                    atF: index => space.Interpolate(vectors[index], vectors[index + 1])(scale));

                segments = segments.Concrete().Abstract();

                return space.Bezier1 <V>(segments)[scale];
            }));
        }