@@ -197,7 +197,7 @@ function nurbs_curve(control,degree,splinesteps,u, mult,weights,type="clamped",
197197 "Cannot give degree, mult, weights or knots when you provide a NURBS parameter list" )
198198 nurbs_curve(control[2 ], control[1 ], splinesteps, u, weights= control[5 ],mult= control[4 ], type= control[0 ], knots= control[3 ])
199199 : assert(num_defined([splinesteps,u])== 1 , "Must define exactly one of u and splinesteps" )
200- is_finite(u) ? nurbs_curve(control,degree,u= [u],mult,weights,type= type)[0 ]
200+ is_finite(u) ? nurbs_curve(control,degree,u= [u],mult= mult ,weights= weights,knots = knots ,type= type)[0 ]
201201 : assert(is_undef(splinesteps) || (is_int(splinesteps) && splinesteps> 0 ), "splinesteps must be a positive integer" )
202202 let(u= is_range(u) ? list(u) : u)
203203 assert(is_undef(u) || (is_vector(u) && min (u)>= 0 && max (u)<= 1 ), "u must be a list of points on the interval [0,1] or a range contained in that interval" )
@@ -229,11 +229,12 @@ function nurbs_curve(control,degree,splinesteps,u, mult,weights,type="clamped",
229229 "where degree+1 is allowed. The mult vector has bad values at indices: " ,badmult))
230230 assert(is_undef(knots) || is_undef(mult) || len(mult)== len(knots), "If both mult and knots are given they must be vectors of the same length" )
231231 assert(is_undef(mult) || type!= "clamped" || sum(mult)== len(control)- degree+ 1 ,
232- str ("For " ,type, " spline knot count (sum of multiplicity vector) must be " ,len(control)- degree+ 1 ," but is instead " ,mult?sum(mult):0 ))
232+ str ("For clamped spline knot count (sum of multiplicity vector) must be " ,len(control)- degree+ 1 ," but is instead " ,mult?sum(mult):0 ))
233233 assert(is_undef(mult) || type!= "closed" || sum(mult)== len(control)+ 1 ,
234234 str ("For closed spline knot count (sum of multiplicity vector) must be " ,len(control)+ 1 ," but is instead " ,mult?sum(mult):0 ))
235235 assert(is_undef(mult) || type!= "open" || sum(mult)== len(control)+ degree+ 1 ,
236- str ("For closed spline knot count (sum of multiplicity vector) must be " ,len(control)+ degree+ 1 ," but is instead " ,mult?sum(mult):0 )),
236+ str ("For open spline knot count (sum of multiplicity vector) must be " ,len(control)+ degree+ 1 ," but is instead " ,mult?sum(mult):0 ))
237+ assert(uniform || is_increasing(knots), "Knot vector must be increasing" ),
237238 control = type== "open" ? control
238239 : type== "clamped" ? control // concat(repeat(control[0], degree),control, repeat(last(control),degree))
239240 : /* type=="closed"*/ concat(control, select(control,count(degree))),
@@ -267,7 +268,7 @@ function nurbs_curve(control,degree,splinesteps,u, mult,weights,type="clamped",
267268 : type== "clamped" ? assert(len(xknots) == len(control)+ 1 - degree, str ("For clamped spline of degree " ,degree,", knot vector with multiplicity must have length " ,
268269 len(control)+ 1 - degree," but has length " , len(xknots)))
269270 assert(xknots[0 ]!= xknots[1 ] && last(xknots)!= select(xknots,- 2 ),
270- "For clamped splint , first and last knots cannot repeat (must have multiplicity one" )
271+ "For clamped spline , first and last knots cannot repeat (must have multiplicity one" )
271272 concat(repeat(xknots[0 ],degree), xknots, repeat(last(xknots),degree))
272273 : /* type=="closed"*/ assert(len(xknots) == len(control)+ 1 - degree, str ("For closed spline, knot vector (including multiplicity) must have length " ,
273274 len(control)+ 1 - degree," but has length " , len(xknots),control))
@@ -279,7 +280,7 @@ function nurbs_curve(control,degree,splinesteps,u, mult,weights,type="clamped",
279280 adjusted_u = ! is_undef(splinesteps) ?
280281 [for (i= [degree:1 :len(control)- 1 ])
281282 each
282- if (knot[i]!= knot[i+ 1 ])
283+ if (! approx( knot[i], knot[i+ 1 ]) )
283284 lerpn(knot[i],knot[i+ 1 ],splinesteps, endpoint= false ),
284285 if (type!= "closed" ) knot[len(control)]
285286 ]
@@ -356,7 +357,7 @@ function _calc_mult(knots) =
356357 let(
357358 ind= [ 0 ,
358359 for (i= [1 :len(knots)- 1 ])
359- if (knots[i]!= knots[i- 1 ]) i,
360+ if (! approx( knots[i], knots[i- 1 ]) ) i,
360361 len(knots)
361362 ]
362363 )
0 commit comments