Curve.Contains bug

Hi all,

I found a weird case when Curve.Contains() method returns an incorrect result. The curve is dead simple without duplication, self-intersecting or anything like that. The point is exactly in the middle between the bottom corners of the “rectangle” part of the shape.

The code I use is
A = crv.Contains(pt, Plane.WorldXY, 0.01);

If I change the tolerance to anything but 0.01 it will work correctly. If the tolerance argument is not provided it will still return “Inside”. Changing the tolerance in the Rhino document doesn’t seem to have any effect on it.

Rhino 7.37.24107.15001

PointContainment_bug.3dm (24.6 KB)
pointContains_bug.gh (4.6 KB)

@archimax,

Any better?

  private void RunScript(Curve crv, Point3d pt, ref object A)
  {
    Plane plane;
    if (null != crv && crv.TryGetPlane(out plane))
      A = crv.Contains(pt, plane, RhinoDocument.ModelAbsoluteTolerance);
    else
      A = null;
  }

– Dale

1 Like

Yes, it helps!

Do you recommend always using the curve’s plane for point containment?

Yes, 100%.

– Dale

1 Like