Curve Side relationship to points


(Ryan Johann) #1

Hi everyone!

I was just wondering if there was a method in Rhinocommon for C# that is the same or similar to (Curve Side) in Grasshopper. I’m trying to determine if a point is left or right of a curve.

Thanks in advance


(Dale Fugier) #2

Hi @ryan_johann,

Sorry no, this function is unique to Grasshopper.

– Dale


#3

Hi,
you could do it like this:



 DataTree<Vector3d> dtProTree = new DataTree<Vector3d>();
    DataTree<Point3d> CloPoTree = new DataTree<Point3d>();
    DataTree<Vector3d> v2pTree = new DataTree<Vector3d>();
    DataTree<Vector3d> tangentTree = new DataTree<Vector3d>();
    DataTree<Vector3d> croPoTree = new DataTree<Vector3d>();


    for (int i = 0; i < pt.Count; i++)
    {

      //closestPoint
      double t; bool cV = crv[i].ClosestPoint(pt[i], out t);
      Point3d cloPo = crv[i].PointAt(t);
      CloPoTree.Add(cloPo, new GH_Path(i));

      //tangentVector
      Vector3d T = crv[i].TangentAt(t);
      tangentTree.Add(T, new GH_Path(i));


      //Vector2Point
      Vector3d v2p = new Vector3d (pt[i] - cloPo);
      v2pTree.Add(v2p, new GH_Path(i));



      //CrossProduct
      Vector3d newVec = new Vector3d(cloPo.X, cloPo.Y, cloPo.Z);//vectorOutOfPoint
      Vector3d crPo = Vector3d.CrossProduct(v2p, newVec);
      croPoTree.Add(crPo, new GH_Path(i));


      if (crPo.Z < 0)
      {
        Print("pt is on the left of the curve ");
      }
      else
      {
        Print("pt is on the right of the curve ");

      }
      
    }