Comments (9)
I made a nurbs library which computes the remove_knot
by fitting the curve into another.
That is, since we know the knotvector before and after removal, we have the basis functions and we can find the best control points that approximates the curve with more knots.
For this example, the 'approximation' is in fact the original curve before knot insertion.
It's better described here:
https://compmec-nurbs.readthedocs.io/en/latest/rst/theory-fitting.html
from nurbs-python.
I made a test function with a random number of insert at random positions
from geomdl import BSpline
from geomdl.operations import insert_knot, remove_knot
import numpy as np
def test_curve_insertremove_oneknot_random():
ntests = 1000
dim = 3
for i in range(ntests):
p = np.random.randint(1, 6)
n = np.random.randint(p+1, p+11)
ctrlpts = np.random.rand(n, dim).tolist()
curve = BSpline.Curve()
curve.degree = p
curve.ctrlpts = ctrlpts
curve.knotvector = p*[0] + list(np.linspace(0, 1, n-p+1)) + p*[1]
knot = np.random.rand()
times = np.random.randint(1, max(2, p))
insert_knot(curve, [knot], [times])
remove_knot(curve, [knot], [times])
np.testing.assert_allclose(curve.ctrlpts, ctrlpts)
from nurbs-python.
Why should the resulting control points be identical to the initial ones?
from nurbs-python.
Well, because knot insertion and knot removal are the opposite processes for one another, so they should cancel each other, shouldn't they? :)
from nurbs-python.
As far as I understood, implementation of knot insertion and removal processes in geomdl is taken directly from The NURBS Book. Unfortunately, the book has a number of typos :/
from nurbs-python.
They appear to be opposite processes, but are they really wrt the control points?
from nurbs-python.
IMHO they should be. Refer to The NURBS Book, 2nd ed, p. 5.4.
from nurbs-python.
In Sverchok, for example, this test works: https://github.com/nortikin/sverchok/blob/master/tests/nurbs_tests.py#L422
Note that in Sverchok insertion and removal of a knot several times is implemented very straightforward, by repeating the whole procedure several times. In the NURBS Book there is an algorithm which requires less calculations, but as far as I understood there are typos there — at least it did not work correctly for me right away; I tried to debug it for some time, but in the end I just reverted to the dumb but working algorithm.
from nurbs-python.
I don't understand why this issue was closed as completed since it still a problem
from nurbs-python.
Related Issues (20)
- Nurbs.Surfac Normal method
- Question: deviation estimation HOT 2
- fitting nurbs surface into mesh model HOT 1
- Surfaces: evaluating z for given (x, y)
- fitting error when use approximate_curve HOT 1
- NURBS.surfaces: derivatives evaluation HOT 1
- Incorrect control points calculation in knot insertion procedure, under certain circumstances
- [Suggesion] The Axes3D is not an appropriate way to create the 3D axis handle HOT 1
- Import obj fails with ValueError invalid literal for `int()` with base 10 '1//1' HOT 1
- numpy v1.24 compatibility HOT 2
- operations.split_curve
- Visualization (VisMPL) is showing an empty figure HOT 4
- Interpolating a hemispherical shape leads to ZeroDivisionError HOT 3
- VisPlotly not return the figure object HOT 1
- Help wanted: unknown ZeroDivisionError HOT 3
- Visualizing surface without ordering control points HOT 3
- BSpline interpolation and approximation boundary conditions
- Problem in Visualization for Sample code HOT 1
- export 3D nurbs curves
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from nurbs-python.