Closed esacademy-de closed 8 months ago
Hi @esacademy-de,
you are right. This function decomposes the spline into a sequence of Bezier curves encoded as B-Spline. It is currently not very convenient to iterate over each Bezier segment, but I already have some ideas of integrating some sort of iterator pattern to the API. The following Python code serves as a template:
spline = BSpline(5, 2, 3)
spline.control_points = [...]
ctrlps = spline.to_beziers().control_points
offset = spline.order * spline.dimension
for n in range(int(len(ctrlps) / offset)):
p0x = ctrlps[n * offset]
p0y = ctrlps[n * offset + 1]
p1x = ctrlps[n * offset + 2]
p1y = ctrlps[n * offset + 3]
p2x = ctrlps[n * offset + 4]
p2y = ctrlps[n * offset + 5]
p3x = ctrlps[n * offset + 6]
p3y = ctrlps[n * offset + 7]
curve(p0x, p0y, p1x, p1y, p2x, p2y, p3x, p3y)
The following publication may help you to get a better understanding of this function: https://see.uni-bremen.de/wp-content/uploads/2021/03/TinySpline.pdf
Thanks!!
Can this be closed?
Hi, I am passing a Bspline to this function and it is returning degree = 5 and number of points = 12. I expected for degree 5 that there would be six points.
Does this mean there are two fifth-degree beziers in the output in a single array of data? I.e. points 1 - 6 = first bezier and points 7 - 12 = second bezier?
Thanks.