Curve Fitting Approximation.

155 views
Skip to first unread message

Keith Sloan

unread,
Jan 30, 2021, 8:07:03 AM1/30/21
to nurbs-...@googlegroups.com

I have three curves I am trying to fit, they have 38, 106 and 33 points and are basically arcs of a circle.
The reason there are so many points for arcs of a circle is that they come from a section of a scan.

With

  curveI = fitting.interpolate_curve(points, degree)
  print(len(curveI._control_points)

The number printed is the same as the number of points.

With

    curve = fitting.approximate_curve(points, degree)
    print(len(curve._control_points)

The number printed is one more than the number of points.
Is there a way to perform a fit reducing/minimising the number of control points

Note : As I need to process the Spline in some other software I have to get details via calls to curve ( curveI )

========== Art & Ceramics ===========
https://www.instagram.com/ksloan1952/

Onur Bingol

unread,
Jan 30, 2021, 8:42:27 AM1/30/21
to nurbs-...@googlegroups.com
It is controlled by the "ctrlpts_size" keyword argument.

--
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/a32b4cb3-f18b-bef6-3b58-59ac432c8e0f%40sloan-home.co.uk.

Keith Sloan

unread,
Jan 30, 2021, 11:07:25 AM1/30/21
to NURBS-Python
I could not find an explanation of centripetal in the book, tried it but it did not reduce the number of control points. ctripts_size seems to set the number of control points and I am trying to code something that is generic i.e. I don't want to specify the number of control points but want the number to be determined by the data even if it means a lot of iteration checking a specified accuracy .

Onur Bingol

unread,
Jan 30, 2021, 12:10:35 PM1/30/21
to nurbs-...@googlegroups.com
"centripetal" is for knot vector generation, please refer to p365 of The NURBS Book.

Automatically determining number of control points sounds like an optimization question, e.g. compare the geometry generated by the data points with the evaluted NURBS geometry. The geometry generated by the data points would be constant but NURBS evaluated geometry would change. It might be possible to utilize 1st and/or 2nd derivatives for the optimization question.

The fitting methods in geomdl might generate the same NURBS geometry from the same data points, but in reality, there are many combinations of control points, degrees and knot vectors which can evaluate into the same geometry within the desired tolerance.

---- On Sat, 30 Jan 2021 08:07:25 -0800 ke...@sloan-home.co.uk wrote ----

Keith Sloan

unread,
Oct 22, 2022, 4:07:21 PM10/22/22
to NURBS-Python
I am revisiting this.

I am trying to replace a whole series of short lines with a spline

For simple curves a fit of a spline with Degree 3 works well. The
challenge is to be able to handle more complex curves.

For example the following example where the red bars represent the short lines.

The second figure (white curve) shows the result of trying to fit a spline with Degree 3

Now I would expect the situation would require a number of curves with Degree3
or one line with much higher degree.

As the code has to handle all cases, I am thinking along the lines of try initial
fit with Degree3, measure how well the curve matches the data, increasing the
Degree until one gets an acceptable match.

Now I could try looping through all the short lines and calculating the shortest distance
to each of the evaluation points but this seems be a very intense calculation,
which leads me to some questions.

1) Is there a way / algorithm,  of breaking the series of red lines into 3 or 4 curves rather than
one?

2) Is there a better way of evaluating the fit, i.e. straight from the result of the
curve = fitting.interpolate_curve(points, degree) call?

3) If I have to resort to calculating minimum distances from source points to
evaluation points, is there a good way of loading the evaluation points into
a numpy array?

Thanks

Image 22-10-2022 at 20.41.jpg


Image 22-10-2022 at 20.42.jpg
Reply all
Reply to author
Forward
0 new messages