bug operations.split_curve

30 views
Skip to first unread message

Gabriel Jesus

unread,
Apr 5, 2023, 8:46:33 AM4/5/23
to NURBS-Python
Hello Dr. Onur Bingol,

First, thank you very much for sharing this library with the community.


I'm having some problems while trying to use operations.split_curve() method. I put one test case in the issue.

ctrlpts = [[1.15172946556, -0.793717672594, 0.933672039573],
[1.1518952086, -0.793708770555, 0.933608435395],
[1.15206095164, -0.793699868517, 0.933544831218],
[1.15222669467, -0.793690966478, 0.93348122704],
[1.15272633787, -0.793664130701, 0.933289488101],
[1.1531929054699999, -0.7934084417080001, 0.9331344375280001],
[1.1534493163300001, -0.7931431955970001, 0.933061562775],
[1.15370516404, -0.7926548375820001, 0.9330119698329999],
[1.1537477257400002, -0.7921211122790001, 0.9330501527689999],
[1.15376183642, -0.791944163861, 0.9330628117349999],
[1.1537759471, -0.7917672154430001, 0.9330754707],
[1.1537900577800002, -0.791590267025, 0.933088129665]]

curve = BSpline.Curve()
curve. Degree= 5
curve.ctrlpts = ctrlpts
curve.knotvector = [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.24999999999999975, 0.24999999999999975, 0.24999999999999975, 0.75, 0.75, 0.75,
1.0, 1.0, 1.0, 1.0, 1.0, 1.0]
curves = operations.split_curve(curve, 0.2499999955077846)


I think maybe the problem is related to the span_func or helpers.find_multiplicity, because we use these functions to calculate ks and r in lines 942-945 and them these values are used to define the ctrlpts list in lines 963-964.

# Find multiplicity of the knot and define how many times we need to add the knot
ks = span_func(obj.degree, obj.knotvector, len(obj.ctrlpts), param) - obj.degree + 1
s = helpers.find_multiplicity(param, obj.knotvector)

# Control points (use Pw if rational)
cpts = temp_obj.ctrlptsw if obj.rational else temp_obj.ctrlpts
curve1_ctrlpts = cpts[0:ks + r]
curve2_ctrlpts = cpts[ks + r - 1:]

See the error below:

File "Python\Python310\site-packages\geomdl\operations.py", line 969, in split_curve
curve1.set_ctrlpts(curve1_ctrlpts)
File "Python\Python310\site-packages\geomdl\abstract.py", line 957, in set_ctrlpts
raise GeomdlException("Number of control points should be at least degree + 1")
geomdl.exceptions.GeomdlException: GEOMDL ERROR: Number of control points should be at least degree + 1

Onur Bingol

unread,
Apr 6, 2023, 12:42:11 AM4/6/23
to nurbs-...@googlegroups.com
Hi Gabriel,

Could it be a floating point error? What happens when you split the curve at u=0.25?

Thanks,
-Onur


---- On Wed, 05 Apr 2023 05:46:33 -0700 gabrieljesu...@gmail.com wrote ----

--
You received this message because you are subscribed to the Google Groups "NURBS-Python" group.
To unsubscribe from this group and stop receiving emails from it, send an email to nurbs-python...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/nurbs-python/e36ebc0a-9de5-49f8-a23c-fbf7f1386042n%40googlegroups.com.

Reply all
Reply to author
Forward
0 new messages