how do you find the tangent of point to curve in autocad api

how do you find the tangent of point to curve in autocad api

Dannyisrael
Enthusiast Enthusiast
1,676 Views
5 Replies
Message 1 of 6

how do you find the tangent of point to curve in autocad api

Dannyisrael
Enthusiast
Enthusiast

danny_0-1644662561351.png

 

0 Likes
Accepted solutions (3)
1,677 Views
5 Replies
Replies (5)
Message 2 of 6

Jeff_M
Consultant
Consultant
Accepted solution

Option 1: Calculate the angle with a little Trig. You know that you have a triangle formed by the radius (R), the tangent line (T) and the line from point to radius point (H), You know (or can easily get) the lengths of the last 2 so the angle from the H to T would be arcsine (r/h). Now add or subtract the found angle to/from the angle of H.

 

Option 2: Similarly, you can calculate the length of the Tangent line since it a basic right triangle. Construct a temporary circle from the known point having that radius and use IntersectWith between the circle and arc to find the point of tangency.

Jeff_M, also a frequent Swamper
EESignature
0 Likes
Message 3 of 6

R.Gerritsen4967
Advocate
Advocate
Accepted solution

I use this piece of code from @_gile :

Public Function GetTangentsTo(ByVal arc As CircularArc2d, ByVal pt As Point2d) As Point2d
        Dim center As Point2d = arc.Center
        If pt.GetDistanceTo(center) <= arc.Radius Then Return Nothing
        Dim vec As Vector2d = center.GetVectorTo(pt) / 2.0
        Dim tmp As CircularArc2d = New CircularArc2d(center + vec, vec.Length)
        Dim inters As Point2d() = arc.IntersectWith(tmp)
        If inters Is Nothing Then Return Nothing
        Dim tanPt As Point2d

        If inters(0).X > inters(1).X Then
            tanPt = inters(0)
        Else
            tanPt = inters(1)
        End If

        Return New Point3d(tanPt.X, tanPt.Y)
    End Function
Message 4 of 6

norman.yuan
Mentor
Mentor
Accepted solution
Message 5 of 6

Dannyisrael
Enthusiast
Enthusiast
Thank
0 Likes
Message 6 of 6

Dannyisrael
Enthusiast
Enthusiast
Thank you
0 Likes