Search code examples
mathgeometrycollision-detection

Scale intersecting circles fixed at pivots so that they have only one point in common


Given two points, A and B; Given two circles, having 2 points in common, I1 and I2:

one circle at center C1, with radius r1, with the point A on to it and another circle at center C2, with radius r2, with the point B on it. enter image description here

Find the centers and radii of the two circles which still touch the points A and B in the same manner but only have one point in common located "mid-way" between the original circles.

Im not sure if the phrasing of the question is entirely correct, also im not sure if im missing some corner cases. Basically the question is revolving around detecting the collision of two circles "glued" to the points A and B. In the solution, center of the first circle should belong to the line (A, C1), while center of the second to (B, C2)

enter image description here

(This is a crosspost (https://math.stackexchange.com/questions/4452636/scale-intersecting-circles-fixed-at-pivots-so-that-they-have-only-one-point-in-c), since the nature of the question is mathematical)


Solution

  • Let we have points A, B, unit normal vectors to lines nA and nB, initial radii r1 and r2. Now we want to change radii to make circles to touch. As Beta noticed in comment, there is indefinite number of ways to perform this.

    For example, we can scale radii using the same coefficient t (while your picture perhaps shows different coefficients). In this case we can write the next equations:

    c1 = A + nA * r1 * t
    c2 = B + nB * r2 * t
    
    (c1.x - c2.x)^2 + (c1.y - c2.y)^2 = (r1 * t + r2 * t)^2
    (A.x + nA.x * r1 * t - B.x + nB.x * r2 * t)^2 + 
        (A.y + nA.y * r1 * t - B.y + nB.y * r2 * t)^2 = (r1 * t + r2 * t)^2
    

    open the brackets and solve quadratic equation for unknown t

    If you want another rule to change radii, put in into equations instead of r1 * t and r2 * t