Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
portnov opened this issue Nov 4, 2022 · 0 comments
Labels
bug There is a problem with the coding or algorithms

Comments

@portnov
Copy link

portnov commented Nov 4, 2022

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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug There is a problem with the coding or algorithms
Projects
None yet
Development

No branches or pull requests

1 participant