Site Tools

Fillet Curves

Developer: C++
Summary: Demonstrates how to create a fillet between two curves.


I am trying to do some automated geometry generation. At one point, I have two intersecting ON_Lines, each made out of two points, and I want to fillet them with a specific radius. The only function I can see that does this is RhinoGetFilletPoints. What am I missing.


RhinoGetFilletPoints is the function are looking for. From its results, you can calculate the fillet curve and where to trim back your input curves.

The following example demonstrates how to create a fillet curve between two line curve. But you can use this example to fillet more complex curves too.


CRhinoCommand::result CCommandTest::RunCommand( const CRhinoCommandContext& context )
  ON_3dPoint point0( 10.0,  0.0, 0.0 );
  ON_3dPoint point1( 10.0, 10.0, 0.0 );
  ON_3dPoint point2(  0.0, 10.0, 0.0 );
  // Create the line curves to fillet
  ON_LineCurve curve0( point0, point1 );
  ON_LineCurve curve1( point2, point1 );
  // Fillet at the end points of the line curves
  double curve0_t = curve0.Domain().Max();
  double curve1_t = curve1.Domain().Max();
  // Fillet radius
  double radius = 1.0;
  // Do the fillet calculation
  double t0 = 0.0, t1 = 0.0;
  ON_Plane plane;
  if( RhinoGetFilletPoints(curve0, curve1, radius, curve0_t, curve1_t, t0, t1, plane) )
    // Trim back the two line curves
    ON_Interval domain0( curve0.Domain().Min(), t0 );
    curve0.Trim( domain0 );
    ON_Interval domain1( curve1.Domain().Min(), t1 );
    curve1.Trim( domain1 );
    // Compute the fillet curve
    ON_3dVector radial0 = curve0.PointAt(t0) - plane.Origin();
    ON_3dVector radial1 = curve1.PointAt(t1) - plane.Origin();
    double angle = acos( radial0 * radial1 );
    ON_Plane fillet_plane( plane.Origin(), radial0, radial1 );
    ON_Arc fillet( fillet_plane, plane.Origin(), radius, angle );
    // Add the geometry
    context.m_doc.AddCurveObject( curve0 );
    context.m_doc.AddCurveObject( curve1 );
    context.m_doc.AddCurveObject( fillet );
  return CRhinoCommand::success;

developer/sdksamples/filletcurve.txt ยท Last modified: 2020/08/14 (external edit)