Using CreateInterpolatedCurve properly

Anyone know why this little loop is happening when I use CreateInterpolatedCurve am I using it properly ?

I derive a series of points and sort them by x axis value; this is the list

  [<Rhino.Geometry.Point3d object at 0x0000000000000109 [-35.1798593977204,120.897956245486,-6.35969337711393]>, <Rhino.Geometry.Point3d object at 0x000000000000010A [-28.7883720588796,123.292883322848,-10.1015207417881]>, <Rhino.Geometry.Point3d object at 0x000000000000010B [-28.2913356222269,123.261632102391,-10.18091015838]>, <Rhino.Geometry.Point3d object at 0x000000000000010C [-21.0361951335006,119.823802598875,-10.5652753713726]>]

Here is the script. s_l is the sorted list

s_l = spba(refined_l)

f_crv = Rhino.Geometry.PolylineCurve.CreateInterpolatedCurve(s_l,3)


f_crv_n = f_crv.ToNurbsCurve()

r_ncb = f_crv_n.Rebuild(6,3,True)

print s_l

Do points carry a vectors naturally ? Is there a way to clear that information.

Assigned to Scripting category.

Almost certainly due to uniform knot spacing being used. Chord knot spacing should eliminate the loop. This is just how interpolated points using NURBS works when the input points have very uneven spacing.
Knots Effect.3dm (2.7 MB)

1 Like

Use a Knot-style of 1 or 2, not 0.

From Rhinocommon documentation for CreateInterpolatedCurve:

  • knots
  • Type: CurveKnotStyle
  • Knot-style to use and specifies if the curve should be periodic.

from CurveKnotStyle documentation:

Values

Uniform = 0

Parameter spacing between consecutive knots is 1.0.


Chord = 1

Chord length spacing, requires degree=3 with CV1 and CVn1 specified.


ChordSquareRoot = 2

Square root of chord length, requires degree=3 with CV1 and CVn1 specified.


UniformPeriodic = 3

Periodic with uniform spacing.


ChordPeriodic = 4

Periodic with chord length spacing.


ChordSquareRootPeriodic = 5

Periodic with square root of chord length spacing.

@davidcockey Ok ! That sounds like it will do the trick. Ill give it a go now.

Thanks !

@davidcockey That did it !

Code that works

s_l = spba(refined_l)


knot = Rhino.Geometry.CurveKnotStyle(1)

f_crv = Rhino.Geometry.PolylineCurve.CreateInterpolatedCurve(s_l,3,knot)