NURBS-Python icon indicating copy to clipboard operation
NURBS-Python copied to clipboard

Incorrect control points calculation in knot insertion procedure, under certain circumstances

Open portnov opened this issue 1 year ago • 0 comments

Describe the bug When using curves with unclamped knotvector, if you try to insert a knot near the right end of knotvector (more precisely, try to insert u_bar which is greater than u[-p-1], where u is knotvector, p is curve's degree) - control points are calculated incorrectly.

To Reproduce As simple example, consider the curve of degree = 2, with control points:

[[0, 0, 0], [1, 1, 0], [2,1,0], [3, 0, 0]]

and knotvector = [0, 1, ..., 6]. Now try to call operations.insert_knot with u_bar = 4. Expected control points of resulting curve are:

[[0.0,  0.0,  0.0 ],
 [1.0,  1.0,  0.0 ],
 [2.0, 1.0,  0.0 ],
 [2.5,  0.5,  0.0 ],
 [3.0,  0.0,  0.0 ]]

but Geomdl calculates:

[[0. 0. 0.]
 [1. 1. 0.]
 [2. 1. 0.]
 [2. 1. 0.]
 [3. 0. 0.]]

Configuration:

  • geomdl install source: PyPI

Additional Details (Optional)

I believe the problem is here: https://github.com/orbingol/NURBS-Python/blob/5.x/geomdl/operations.py#L82 find_span_linear is implemented in such a way that it never returns value greater than num_ctrlpts. Maybe it is good in some situations, but not in this one. I had similar problem in Sverchok, and for me the solution was

        k = u.searchsorted(u_bar, side='right')-1

portnov avatar Nov 04 '22 16:11 portnov