rs.PointInPlanarClosedCurve false positives

I’m trying to use rs.PointInPlanarClosedCurve to test if some points are in a curve. However, it seems to be reporting that the points are coincident with the curve in cases where they’re clearly outside. Any ideas?

point in curve (7.8 KB)

Hi @matt.johnson1253,

If you don’t specify a plane for the containment test, the active construction plane - usually the XY plane - is used!
Since the plane of your curve is the XZ-plane, and in the XY-plane all points fall apparently on the curve, the test returns 2.

If you want an accurate result, you need to provide the right plane. In your case, you can get it from the curve:

import rhinoscriptsyntax as rs
a = []

plane = rs.CurvePlane(y)

for pt in x:
    a.append(rs.PointInPlanarClosedCurve(pt, y, plane, 0.01))

The tolerance (i.e. 0.01) is optional, but it doesn’t hurt.

Furthermore, you should really use more descriptive variable names. Noboby understands at first glance that x is a list of points and y a curve.

1 Like

Duh! Thanks for the tip, and sorry for the unclear variable names.