Tangent to a Brep

I want to find two tangent lines to a given brep which pass through a specified point.
It is easy to draw these lines on rhino by command _line _Tangent.

I made a GH which can find the tangent lines (see the attached file). But any components (or plug in) can do the same thing?

GK 312C.gh (14.7 KB)

  private void RunScript(Curve curve, Point3d point, double seedParmameter, ref object A)
  {
    double t;
    curve.GetLocalTangentPoint(point, seedParmameter, out t);
    A = curve.PointAt(t);
  }

LocalTangentPoint.gh (14.2 KB)

Dear Mahdiyar, thanks a lot!
I encountered a problem. Please see the attached! What should I do??

It seems you’re using Rhino 5, This script supposed to work on Rhino 6.

This one must work on Rhino 5 too:

private void RunScript(Curve curve, Point3d point, double seedParmameter, ref object A)
{
    var c1 = (new Circle(point, 1.0)).ToNurbsCurve();
    double t1;
    c1.ClosestPoint(curve.PointAt(seedParmameter), out t1);
    Line l;
    Line.TryCreateBetweenCurves(curve, c1, ref seedParmameter, ref t1, false, true, out l);
    A = curve.PointAt(seedParmameter);
}


IntervalSelection.gh (25.6 KB)

1 Like

Dear Mahdiyar
Yes, I use Rhino 5. I can execute your new script now. Thanks a lot!

Here’s a less accurate way without scripting:

20_04_07_tangent_to_curve_mrtn.gh (7.3 KB)

hi, can you explain to me what is the “seed parameter” in that method? I tried to change the “seed parameter” from 0.0 to 1.0 and cannot see the difference. Thanks.

There might be some situations where there is more than one tangent line available. This function uses seed parameter to find the desired tangent point.
Seed
Seed.gh (21.7 KB)

4 Likes