How to find the tangent point on a curve

Hello all,

i have a curve ( planar for example S-shape ) an a point in the same plan

how I can find the tangent point in c#

Thanks Robert

Tangent to what? Can you explain further? Do you have a sample model?

S_curve for Dal.3dm (58.7 KB) Hi Dale,
I uplode a file to explain.

Thanks Robert

@pascal, any tips for Robert?

Not sure if this helps but here is how you can do it in python. I wrote this for a specific case so it may not take into account your specific needs (eg it does not check for multiple tangents).

import rhinoscriptsyntax as rs
import Rhino

def TangentLinePtToCurve(Point,Curve):
    #Create small circle around pt
    PtCircle=rs.AddCircle(EndPt,0.001)
    #get curve domains
    CurveParam=rs.CurveDomain(Curve)[0]
    PtCircleParam=rs.CurveDomain(PtCircle)[0]
    #transform into rhino geometry data
    CurveData=rs.coercecurve(Curve)
    PtCircleData=rs.coercecurve(PtCircle)
    #Find tangent line
    TanLine=Rhino.Geometry.Line.TryCreateBetweenCurves(PtCircleData,CurveData,PtCircleParam,CurveParam,False,False)
    TanPtOnCurve=TanLine[3].To
    #add line to document
    NewMedialEdge=rs.AddLine(TanLine[3].From,TanLine[3].To)
    
    #delete circle
    rs.DeleteObject(PtCircle)
    
    return TanLine,TanPtOnCurve
    


if __name__=="__main__":
    #get curve
    Curve=rs.GetObject("Select Curve",4)
    #get point
    EndPt=rs.GetObject("Select Point",1)
    
    TanLine,TanPtOnCurve=TangentLinePtToCurve(EndPt,Curve)

The key part being "Rhino.Geometry.Line.TryCreateBetweenCurves"
This only works between two curves so firstly you need to create a tiny circle around the point in question.

1 Like