Curve contains point bug

Hey guys,
I do struggle with the Curve.Contains function. I programmed a small command in which a user can select a curve and a point. As a result, Rhino prints out if the point is inside or outside the curve. This worked for many curves; however, not for this one. Can someone explain me how I can solve it? I already tried the functions Simplify and also divide the curve by equidistant and create a new curve. I also tried to create a periodic curve. Nothing worked.


If you need further information, you can find the command attached to the post. If you want to try it yourself, you can use the following file.
testCurve_2.3dm (132.6 KB)
PointContainmentCommand.cs (3.4 KB)

Hi @Heiden,

The curve has overlapping segments.

Try this:

1.) Select the curve
2.) Run SimplifyCrv
3.) Run List

– Dale

Hey @dale,

Thank you for the response. I tried the commands, but unfortunately, it did not work out. The point is still outside. Moreover, I am actually trying to program a command in C#. Can you give me the functions I have to call instead of the Rhino commands?

Hi @Heiden,

The curve you provided is junk. You should not represent a simple rectangle as a degree=3 NURBS curve with 3097 control points.

Select your curve and run the Explode command. Notice how you now have 8 segments and not 4? This is what I mean by overlapping segments. The overlapping segments are causing the "curve contains point` calculation to fail.

SimplifyCrv will clean up the excess control points. In RhinoCommon, use Curve.Simplify.

However, this will not get rid of the overlapping segments. That you’ll need to do on your own.

– Dale

Hey @dale,

thank you a lot for the hint. Now I got it.