/** * \author Andrew Mustun, CVH © 2024 * \return Solutions for circles (<=4) that are tangential to the two given circles * and the given point. */ Apollonius.getSolutionsPCC = function(point, circle1, circle2) { if (!isPointShape(point) || !isCircleShape(circle1) || !isCircleShape(circle2)) { return []; // Empty, no solutions } // Relative sized inversion circle (FS#2590): var rInv = circle1.getRadius(); if (circle2.radius > circle1.radius) { rInv = circle2.getRadius(); } var inversionCircle = new RCircle(point.getPosition(), rInv); // Construct inversion shapes: var c1Inverse = Apollonius.getInverseShape(circle1, inversionCircle); var c2Inverse = Apollonius.getInverseShape(circle2, inversionCircle); // Get all tangent shapes for given inversion shapes: // Exploits an enhanced algorithm by CVH var tangents = Apollonius.getAllTangents(c1Inverse, c2Inverse); // Return the re-inversion of all tangents (0-4 solutions): return Apollonius.getInverseShapes(tangents, inversionCircle); };