I’m trying to find a way to determine on which side of a curve a point is located. Is there a built-in function in Rhinocommon that can check on which side of a curve a point is? How does the offset command do it?

Hi Siemen,

This is all relative to the view you are in.

So my thinking would be to - this is just thinking out loud-

Get the point on the viewplane under your mousepointer.

From the camera point through that point on the viewplane we get an infinite line (or one trimmed by the viewbased boundingbox of the curve)

Next you get the closest points between the line and the offset curve.

The closest point on the line can be used to set the offset direction…

Curious if/how it works so update if you found a solution😉

-Willem

EDIT: you could maybe also intersect that mouseline with the curve plane -assuming a planar curve-

Hi @Willem,

Thanks for giving your thoughts. My title might have been a bad description since I’m after the relation between a point and a curve instead of the location of where the mouse is.

I found a solution which seems to work for now, though feels a bit cumbersome:

```
public static bool CurvePointSideRelation(Curve curve, Point3d point)
{
//closestPoint
bool cV = curve.ClosestPoint(point, out double t);
Point3d cloPo = curve.PointAt(t);
//find Perpendiular Vector
Vector3d tanVector = curve.TangentAt(t);
tanVector.Rotate(RhinoMath.ToRadians(90), RhinoDoc.ActiveDoc.Views.ActiveView.ActiveViewport.ConstructionPlane().ZAxis);
//Create oposite vector
tanVector.Unitize();
Vector3d tanVectorOpp = new Vector3d(tanVector);
tanVectorOpp.Reverse();
//Create point on each side of curve along vector
Point3d pt1 = new Point3d(cloPo);
Transform xform1 = Transform.Translation(tanVector);
pt1.Transform(xform1);
Point3d pt2 = new Point3d(cloPo);
Transform xform2 = Transform.Translation(tanVectorOpp);
pt2.Transform(xform2);
//Check which one is the closest
if (point.DistanceTo(pt1) < point.DistanceTo(pt2))
return false;
else
return true;
}
```

You could use the built-in Curve.Contains method to check whether a point is inside, outside or on a curve. Or you could use the winding number approach as described here:

I didn’t mention I’m dealing with open curves, so that won’t work. Thanks for your suggestion though!