[BUG] Curve.Fit failure

fit_curve_fail.3dm (32.5 KB)
When I run the code below on the curve in the document attached, the resulting curve has 1 control point on the origin, resulting in a very bad curve shape locally.

var res = RhinoGet.GetOneObject("Curve to fit", false, ObjectType.Curve, out var cRef);
if (res != Result.Success)
  return res;

Curve toFit = cRef.Curve();
double fitTolerance = 1e-8;
var smoothed = toFit.Fit(3, fitTolerance, 0.0);


Hi @menno,

Curve.Fit seems to work with a lower tolerance, such as the document tolerance. Why the high value?

– Dale

Yes, I noticed that as well. Still, the strict tolerance gives this weird result, so I thought I would let you know. I suspect it has something to do with the curve being a polycurve and the fitting routine requiring lots of samples to get the required accuracy.

Hi @dale, i see _FitCrv doing this with polycurves often, even with moderate tolerances. Below is an example which deviates 3mm when fitted with a tolerance of 0.1mm.

FitCrvExample.3dm (34.7 KB)


Hi @clement.

The curve is converted to its NURBS form before fitting.

I’ve logged the issues.


– Dale