# Finding the interior tangent circles of a given radius of a concave polygon

I am trying to write an algorithm for calculating toolpath's for CNC machines and in doing so I need to find a way of determining all the circles of a given radius whose centers lie on the bisector of each internal angle and be also tangent to both sides that form the angle.

We have: -a polygon of n sides which is not self-intersecting and whose internal angles may or may not be greater than pi radians. -n vertices which are given in a clockwise direction and n internal angles -the radius of the circle

What I did is - calculate the n clockwise vectors ( from V1 to V2...... Vn-1 to Vn) and the n anticlockwise vectors ( from V2 to V1......Vn to Vn-1) - calculate the n angles by taking the arccosine of the scalar product of the clockwise vector with it's previous anticlockwise vector all divided by the product of the length of the adjacent sides

Now since the circle is tangent to both sides the distance from the center of the circle to each side is equal to the radius. So this means that the distance from the vertex to the center of the circle is equal to the sine of half the internal angle divided by the radius.

To calculate the direction, I have calculated the clockwise and anticlockwise vectors of magnitude 1. By adding the adjacent vectors of magnitude 1 I have obtained the bisector direction and I have divided the resulting vector by twice the cosine of half the internal angle to ensure that it always has a magnitude of one. By multiplying this vector with the distance from the the vector, we get the change in x and change in y and so can we find the center of the circle.

The issue is that this way of finding the internal angle doesn't works when the angle is greater than pi radians, and so it places the circle outside our given polygon. What I am trying to find is a modification of this formula so that when the angle is greater than pi radians, the circle is placed tangent to the internal corner, on the bisector of the angle. Thanks!

• Your question is not clear, here's a couple of issues. 1) A generic polygon doesn't have, in general, an incircle; are you dealing with particular polygons? 2) A polygon with an internal angle greater than 180° is concave, and concave polygons don't have an incircle. You should make clear what exactly you are trying to do. – Aretino Dec 31 '18 at 10:56