📌  相关文章
📜  圆心与两个直接公切线的交点之间的距离比

📅  最后修改于: 2021-05-04 16:50:41             🧑  作者: Mango

给定两个给定半径的圆,以使圆彼此不接触,任务是找到圆心与两个直接公切线与圆的相交点之间的距离之比。
例子:

Input: r1 = 4, r2 = 6 
Output: 2:3

Input: r1 = 22, r2 = 43
Output: 22:43

方法

  • 令圆的半径分别为r 1r 2 ,中心分别为C 1C 2
  • P为两个直接公切线与圆的交点,而A 1A 2为切线与圆的接触点。
  • 在三角形PC 1 A 1和三角形PC 2 A 2中
    C 1 A 1 P =角C 2 A 2 P = 90度{将圆心与接触点连接的线与切线成90度角},
    同样,角度A 1 PC 1 =角度A 2 PC 2
    因此,角度A 1 C 1 P =角度A 2 C 2 P
    由于角度相同,三角形PC 1 A 1PC 2 A 2相似
  • 因此,由于三角形的相似性,
    C 1 P / C 2 P = C 1 A 1 / C 2 A 2 = r 1 / r 2

下面是上述方法的实现:

C++
// C++ program to find the ratio of the distance
// between the centers of the circles
// and the point of intersection of
// two direct common tangents to the circles
// which do not touch each other
 
#include 
using namespace std;
 
// Function to find the GCD
int GCD(int a, int b)
{
    return (b != 0 ? GCD(b, a % b) : a);
}
 
// Function to find the ratio
void ratiotang(int r1, int r2)
{
    cout << "The ratio is "
         << r1 / GCD(r1, r2)
         << " : "
         << r2 / GCD(r1, r2)
         << endl;
}
 
// Driver code
int main()
{
    int r1 = 4, r2 = 6;
    ratiotang(r1, r2);
    return 0;
}


Java
// Java program to find the ratio of the distance
// between the centers of the circles
// and the point of intersection of
// two direct common tangents to the circles
// which do not touch each other
class GFG {
 
    // Function to find the GCD
    static int GCD(int a, int b)
    {
        return (b != 0 ? GCD(b, a % b) : a);
    }
 
    // Function to find the ratio
    static void ratiotang(int r1, int r2)
    {
        System.out.println("The ratio is "
                           + r1 / GCD(r1, r2)
                           + " : "
                           + r2 / GCD(r1, r2));
    }
 
    // Driver code
    public static void main(String args[])
    {
        int r1 = 4, r2 = 6;
        ratiotang(r1, r2);
    }
}
 
// This code has been contributed by 29AjayKumar


Python3
# Python 3 program to find the ratio
# of the distance between the centers
# of the circles and the point of intersection
# of two direct common tangents to the circles
# which do not touch each other
 
# Function to find the GCD
from math import gcd
 
# Function to find the ratio
def ratiotang(r1, r2):
    print("The ratio is", int(r1 / gcd(r1, r2)), ":",
                          int(r2 / gcd(r1, r2)))
 
# Driver code
if __name__ == '__main__':
    r1 = 4
    r2 = 6
    ratiotang(r1, r2)
 
# This code is contributed by
# Surendra_Gangwar


C#
// C# program to find the ratio of the distance
// between the centers of the circles
// and the point of intersection of
// two direct common tangents to the circles
// which do not touch each other
using System;
     
class GFG
{
 
    // Function to find the GCD
    static int GCD(int a, int b)
    {
        return (b != 0 ? GCD(b, a % b) : a);
    }
 
    // Function to find the ratio
    static void ratiotang(int r1, int r2)
    {
        Console.WriteLine("The ratio is "
                        + r1 / GCD(r1, r2)
                        + " : "
                        + r2 / GCD(r1, r2));
    }
 
    // Driver code
    public static void Main(String[] args)
    {
        int r1 = 4, r2 = 6;
        ratiotang(r1, r2);
    }
}
 
// This code contributed by Rajput-Ji


PHP


Javascript


输出:
The ratio is 2 : 3