I am wondering if there is a way to figure out what side of a curve a point is on? I hate to be the guy saying “In Grasshopper, blah blah blah”, but In Grasshopper, there is a component called “Curve Side” which tells you exactly this. I have been doing this for the time being:
But this really only works if the points are clearly above or below the curve. In the case of more spliney curves, this doesn’t always work, because even if a point is technically above the curve, it’s closest point may be below it. Thanks!
If you have a closed planar polygon without self intersections you can use a polygon containment test which returns a true value if the point is inside the extents of the polygon. For other types of closed curves you can make a surface by patch and check for an intersection. Here’s an example of the former and two examples of the later.
Project each point into the curve (nearest/tangent) and store the vector of the projection. Get the tangent on the curve at the projected point. Compute the cross product of the two vectors. Now compute the dot of this vector against the global Z axis. The scalars which are positive will identify all the points on the right side of the curve, negative are the ones on the left side.
Offset the curve by [0,1].
Get the distance from each point to both curves in the offset list.
Transpose as needed for larger lists.
If D1 < D2 it’s outside, otherwise it’s inside.
Likely could break this (or any method for that matter) with complex enough curves (in my case non-planar curves, self intersecting curves, etc), but either my method or @Thomas_Mahon’s are a good start point.
Thomas, thanks for this. I’m assuming that this method is assuming the curve is drawn in the XY plane? Is that why you are doing the dot product against the global Z? If the curve was drawn in an arbitrary plane, would you be doing the dot product against the Normal vector of that plane?
Both methods are great help! I’m not going crazy with non planar curves so they both seem to do the trick for me. The vector based method that @Thomas_Mahon proposed is closest to what I have found about how the grasshopper component works. Thanks for your help Thomas and @jacob.small. Solution below:
@Dennis_Goff Thats right although it should work even if your curve is non-planar. The only limitations would be if your curve is overlapping itself (if its helical for example) or intersecting, as Jacob mentioned.