Skip to content

Commit

Permalink
bug fix for specified knots case
Browse files Browse the repository at this point in the history
  • Loading branch information
adrianVmariano committed Dec 7, 2024
1 parent d4a8fdb commit 6b50f2d
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions nurbs.scad
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ include<BOSL2/beziers.scad>
// Example(2D,NoAxes): Explicitly specified knots only change the quadratic clamped curve slightly. Knot count is len(control)-degree+1 = 9.
// pts = [[5,0],[0,20],[33,43],[37,88],[60,62],[44,22],[77,44],[79,22],[44,3],[22,7]];
// knots = [0,1,3,5,9,13,14,19,21];
// debug_nurbs(pts,2);
// debug_nurbs(pts,2,knots=knots);
// Example(2D,NoAxes): Combining explicit knots with mult for the quadratic curve to add a corner
// pts = [[5,0],[0,20],[33,43],[37,88],[60,62],[44,22],[77,44],[79,22],[44,3],[22,7]];
// knots = [0,1,3,9,13,14,19,21];
Expand Down Expand Up @@ -288,7 +288,8 @@ function nurbs_curve(control,degree,splinesteps,u, mult,weights,type="clamped",
;
!done
;
output = (uind<len(adjusted_u) && approx(adjusted_u[uind],knot[kind]) && ((kmultind>=len(kmult)-1 || kind+kmult[kmultind]>=len(control)))) ? kind-kmult[kmultind-1]
output = (uind<len(adjusted_u) && approx(adjusted_u[uind],knot[kind]) && kind>kmult[0]-1 && ((kmultind>=len(kmult)-1 || kind+kmult[kmultind]>=len(control))))
?kind-kmult[kmultind-1]
: (uind<len(adjusted_u) && adjusted_u[uind]>=knot[kind] && adjusted_u[uind]>=knot[kind] && adjusted_u[uind]<knot[kind+kmult[kmultind]]) ? kind
: undef,
done = uind==len(adjusted_u),
Expand All @@ -300,7 +301,7 @@ function nurbs_curve(control,degree,splinesteps,u, mult,weights,type="clamped",
if (is_def(output)) output]
)
[for(i=idx(adjusted_u))
_nurbs_pt(knot,select(control, knotidx[i]-degree,knotidx[i]), adjusted_u[i], 1, degree, knotidx[i])
_nurbs_pt(knot,slice(control, knotidx[i]-degree,knotidx[i]), adjusted_u[i], 1, degree, knotidx[i])
];


Expand Down

0 comments on commit 6b50f2d

Please sign in to comment.