Open portnov opened 3 years ago
According to the NURBS book, it is not always possible to remove a knot as the authors assume that num
-th derivative must be continuous to remove num
number of knots. Some researchers say that knot removal is possible as long as the knot exists in the knot vector but it is not always possible to get the same shape, i.e. it may change parametrically and geometrically. I think it would be a good idea to stick to the NURBS book in this case.
I see that I forgot to add a check to identify if the knot is removable or not. That specific check exists in the algorithm, p.186 of the NURBS book. It looks like I added that function 3 years ago with a note "needs testing" but I am guessing I forgot to test it :)
Thanks for the report @portnov.
In this particular test, I explicitly insert a knot and then try to remove it. Since I inserted the knot, I think it should be possible to remove it :)
In this particular test, I explicitly insert a knot and then try to remove it. Since I inserted the knot, I think it should be possible to remove it :)
Yes, absolutely.
I see that I forgot to add a check to identify if the knot is removable or not. That specific check exists in the algorithm, p.186 of the NURBS book. It looks like I added that function 3 years ago with a note "needs testing" but I am guessing I forgot to test it :)
It looks like I was wrong here. The implementation of the algorithms is always a little bit different than the algorithms in the book and it leads to unintentional mistakes. Having said that, I think I found the error. @portnov, would you change helpers.py line 733 with
ctrlpts_new[j] = ctrlpts_new[k] # line 733 of helpers.py
and test it again? I am guessing you have multiple cases to test :)
Ok, will test
The test case I posted in the description of this ticket is working now. With other cases I have, I'm not so sure: result is changing form, but not so badly as before. But then, I'm not so sure there that knots are removable.
How current implementation is supposed to work if the knot is not removable?
@portnov you are right. For your specific case, if we want to remove knot = 0
instead of knot = 0.5
, it shouldn't allow it. I've implemented a fix and it seems to be working fine for curves.
Before pushing the fix, I need to complete the following:
Describe the bug
remove_knot()
method returns a curve, which is geometrically different from original curve. According to description of this operation (see The NURBS Book, p.5.4), the resulting curve should be geometrically and parametrically identical to original oneTo Reproduce
Output: