least angle required to avoid intersection

Viewed 36

I am trying to create an avoidance system where circle A has to avoid circle B with as minimum angle as possible. My approach is to create an imaginary circle C of radius Ra + Rb from the center of circle B and the draw a tangent from center of circle A to circle C. With those 2 tangents, I can get the minimum angle required to avoid the circle. I will add the minimum angle to current angle if circle A to avoid the Circle B. Is it the right approach or I am missing something here?Image describing my idea

1 Answers

Yes this is the right approach.

You'll notice that the centers of the two circles and the tangent point make a right triangle. The sine of the angle you need is Ra+Rb divided by the distance between the circle centers. You can compute the angle with the std::asin function.

double angleInRadians = std::asin((Ra+Rb)/(Cb-Ca))
Related