Calculate intersect point between arc and line

后端 未结 2 506
清酒与你
清酒与你 2021-01-12 15:28

I want to calculate the intersect point between arc and line. I have all the data for line and arc.

For line : start and and end point.
For arc : start/end poin

2条回答
  •  暖寄归人
    2021-01-12 15:41

    A point on the arc has coordinates

    R.cos(t) + Xc
    R.sin(t) + Yc
    

    Using the implicit form of the line equation (either given or obtained from two given points),

    A.X + B.Y + C = 0
    

    then

    A.R.cos(t) + B.R.sin(t) + A.Xc + B.Yc + C = 0
    

    To solve this trigonometric equation, first divide both members by R.√A²+B², giving

    c.cos(t) + s.sin(t) = d
    

    which can be rewritten, with tan(p) = s/c and d = cos(q):

    cos(t-p) = cos(q)
    

    then

    t = p +/- q = arctan(B/A) +/- arccos(-(A.Xc + B.Yc + C)/R.√A²+B²)
    

    Eventually, you will need to check if these values of t fall in the range (start, end), modulo 2π.

提交回复
热议问题