/// <summary>Creates a uniform B-spline of the given degree, automatically configuring the knot vector to be uniform</summary> /// <param name="points">The B-spline control points</param> /// <param name="degree">The degree of the curve</param> /// <param name="open">Whether or not it should be open. Open means the curve passes through its endpoints</param> public BSpline2D(Vector2[] points, int degree = 3, bool open = false) { this.points = points; this.degree = degree.AtLeast(1); this.evalBuffer = new Vector2[degree + 1]; this.knots = SplineUtils.GenerateUniformKnots(this.degree, this.points.Length, open); }
public static Nurbs2D GetUniformBSpline(Vector2[] points, int degree = 3, bool open = true) { int ptCount = points.Length; float[] knots = SplineUtils.GenerateUniformKnots(degree, ptCount, open); return(new Nurbs2D(points, knots, null, degree)); }
/// <summary>Creates a B-spline of the given degree, from a set of points and a knot vector</summary> /// <param name="points">The B-spline control points</param> /// <param name="knots">The knot vector defining the parameter space of this B-spline. Note: the number of knots has to be exactly degree+pointCount+1</param> /// <param name="degree">The degree of the spline</param> public BSpline2D(Vector2[] points, float[] knots, int degree = 3) { this.points = points; this.knots = knots; this.degree = degree; this.evalBuffer = new Vector2[degree + 1]; if (knots.Length != SplineUtils.BSplineKnotCount(this.points.Length, this.degree)) { throw new ArgumentException($"The knots array has to be of length (degree+pointCount+1). Got an array of {knots.Length} knots, expected ${KnotCount}", nameof(knots)); } }