find te condition for the line xcos(alpha) + ysin(alpha) = p to be a tangent to the ellipse x2/a2 + y2/b2 = 1.
Kindly refer the link for answer similar to your query:
https://www.meritnation.com/ask-answer/question/if-straight-line-x-cos-alpha-y-sin-alpha-p-touches-the/math/6338138
https://www.meritnation.com/ask-answer/question/if-straight-line-x-cos-alpha-y-sin-alpha-p-touches-the/math/6338138