On Thu, Jan 20, 2022 at 11:28 AM Robert Kern <robert.k...@gmail.com> wrote:

> On Thu, Jan 20, 2022 at 1:15 PM <roger.dav...@geo-spatial.co.uk> wrote:
>
>> Hi,
>> I use a CAD package called Rhino which lets users write python scripts
>> that run in the cad environment. I have a closed curve that is a design
>> surface border and I have a sparse data set of 2D surveyed points taken
>> around that border, so some error is included in the 2D data set. I would
>> like to know what python function I could use to do a 2D best fit of the
>> points to the curve.
>> Plenty of examples of fitting curves to points but not of best fitting
>> points to a closed curve of which I do not know the formula.
>>
>
> You can use a parametric spline (where X and Y are each functions of a
> "time" coordinate `t`) with periodic boundary conditions. See this
> StackOverflow answer for an example using scipy.interpolate:
>
> https://stackoverflow.com/a/31466013/163633
>
> Whether our spline representation can be converted to Rhino NURBS or if
> Rhino itself can do a periodic parametric NURBS and do the fitting itself,
> I don't know.
>
> --
> Robert Kern
>

Fitting curve is choosing a family of parametrized curves and picking the
best one in the family. The number of parameters should not exceed the
number of data points. Picking that family is a tradeoff between
expectation (theory) and convenience. The splines Robert mentions are one
family of curves which have nice properties and are good when there is
little theory. If you know what the curve *should* be, you can try adding
perturbations, i.e., effectively fitting the deviations. It is a bit of an
art.

Chuck
_______________________________________________
NumPy-Discussion mailing list -- numpy-discussion@python.org
To unsubscribe send an email to numpy-discussion-le...@python.org
https://mail.python.org/mailman3/lists/numpy-discussion.python.org/
Member address: arch...@mail-archive.com

Reply via email to