Rhino3dm - PointAt() - Getting equal distance points on a curve

Hi there fellow Rhino Developers,
I have a question regarding Nurbs/Control Points and the PointAt() method of the rhino3dm Library.
Let me describe the situation:
There is a 3 Point curve, with equidistant control points (x=0, x=10, x=20). I use “CreateControlPointCurve()” to create a rhino3dm.Curve and change it’s Domain to 0-100 and use it’s PointAt() function to get parameters at 25, 50, 75. All shiny! The parameters are at X=25, x=50 and x=75. Evenly spaced on the curve.

Now the curve changes, it has non equidistant control points (x=0, x=5, x=20) PointAt(25,50,75) does not return the points I would like to get anymore… it gives me uneven spaced points on the curve. Same if I add more points to the curve (see image below). On this image you can see the crosshairs which simbolize parameters 0, 25, 50, 75 and 100 (0 and 100 are ok), the others are not, and you can see a little squares/dots which are the control point locations. You can see that the CP is not in the middle of the curve.

I have discovered a function called Reparameterize() - of which I suspect, that it would do what i want - that takes exactly one float argument and which, if I randomly try out different values, can produce “better” results… For instance for the example above calling it with 0.55 will yield almost perfect distribution of parameters on the curve(see image below), but I do not find any documentation for this and I don’t understand how to calculate the parameter for this function. Also it changes again with the CP count.

Can anyone point me into the right direction to get even/correctly spaced points on the curve say at Parameter = 25, 50, 75,etc. for this kind of setup? Is that even possible with rhino3dm? What would i need to code to make this work? Does it have anything to do with segment/knot count or degree… or … ?

Any advice is very much appreciated! Thank you :slight_smile:
Best regards
Malte

Hi @m112,

Evaluating a curve a normalized parameter locations is not enough to obtain arc-length points. You’ll functions, such as Curve.DivideByLength and at a lower level Curve.NormalizedLengthParameter and Curve.NormalizedLengthParameters, which are found in RhinoCommon but not Rhino3dm.

To access RhinoCommon functions from Rhino3dm, you might consider Rhino.Compute or perhaps Rhino.Inside.

– Dale

Hi Dale,
thank you very much for your post and the contained information. I understand that there will be no “easy” solution for this and I do think, that the easiest for me will be writing a approximation function that works with line segments.
Thank you very much! Appreciate your time.
Compute and Inside are sadly not a viable solution this time. I have been looking at compute before and like it though. Thanks for mentioning.
Best regards
Malte