Find a tangent point on circle?

后端 未结 9 750
别跟我提以往
别跟我提以往 2020-12-09 04:33

Given a line with first end point P(x1,y1) another end point is unknown, intersect with a circle that located at origin with radius R at only one point(tangent) T(x2,y2). An

9条回答
  •  孤城傲影
    2020-12-09 05:13

    Take R as the radius of the circle and D the distance from the external point to the center of the circle such that D > R.

    The tanget line makes and angle of \alpha with the line connecting the external point and the center, where

    \alpha = arcsin(R/D)
    

    The line connecting the external point (P) and the center (C) makes an angle with the horizontal of

    \beta = arctan((C_y - P_y)/(C_x - P_x))
    

    That gives you the angle of the tangent line with the horizontal as

    \theta = \beta +/- \alpha
    

    Note the ambiguity.

    The length of the tangent segment is

    L = sqrt(D^2 - R^2)
    

    which is all you need.

提交回复
热议问题