public static NurbsCurve Polyline(List <Vector> points) { KnotArray knots = new KnotArray() { 0.0, 0.0 }; double lsum = 0.0; for (int i = 0; i < points.Count - 1; i++) { lsum += Constants.DistanceTo(points[i], points[i + 1]); knots.Add(lsum); } knots.Add(lsum); var weights = points.Select(x => 1.0).ToList(); points.ForEach(x => weights.Add(1.0)); return(new NurbsCurve(1, knots, Eval.Homogenize1d(points, weights))); }
public static NurbsCurve RationalBezierCurve(List <Vector> controlPoints, List <double> weights = null) { var degree = controlPoints.Count - 1; var knots = new KnotArray(); for (int i = 0; i < degree + 1; i++) { knots.Add(0.0); } for (int i = 0; i < degree + 1; i++) { knots.Add(1.0); } if (weights == null) { weights = Sets.RepeatData(1.0, controlPoints.Count); } return(new NurbsCurve(degree, knots, Eval.Homogenize1d(controlPoints, weights))); weights = Constants.Rep(controlPoints.Count, 1.0); //return new NurbsCurveData(degree, knots, Eval.Homogenize1d(controlPoints, weights)); return(null); }