C#_Fillet curve

rhinocommon

(OmKar) #1

I want to fillet curve in c#

i have made function for creating close polyline and I am trying to fillet the corners of the polygon. exactly as polygon component in grasshopper. I tried looking at curve.CreateFillet method but dont understand how i can use it here

any help in this regard would be great
here is the code

  // polygon function
  Curve Polygon(Plane pln, double radius, int segments) //double fillet???
  {
    Circle cir = new Circle(pln, pln.Origin, radius);
    Curve crv = cir.ToNurbsCurve();
    
    Point3d[] pts;
    crv.DivideByCount(segments, true, out pts);
    
    List<Point3d> myPts = pts.ToList();
    myPts.Add(myPts[0]);
    
    Polyline pl = new Polyline(myPts);
    Curve cp = pl.ToNurbsCurve();
    return cp;
  }

(David Rutten) #2

Since fillets on regular polygons can be analytically described with a few sines and cosines, I’d recommend making them yourself as arc segments rather than relying on the much slower curve filet api in Rhino.


(OmKar) #3

ok, but I also do not how to make arc segments at every corner! It would be great if you can give some idea how I can do that.


(David Rutten) #4

You can define arcs in RhinoCommon using startpoint, endpoint and start tangent. So all you have to do is figure out how much shorter the line segments need to be compared to an unfilleted polygon, and then you can connect them all up with arcs using the line endpoints and tangents.