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

📅  最后修改于: 2021-10-23 08:43:45             🧑  作者: Mango

给定两个具有给定半径的圆,使得这些圆不会相互接触。任务是找到圆心之间的距离与圆的两个横向公切线的交点的比值。
例子:

Input :r1 = 4, r2 = 8 
Output :1:2

Input :r1 = 5, r2 = 13
Output :5:13

方法

  • 设圆的半径分别为r1 & r2C1 & C2
  • P为圆的两条横向公切线的交点, A1A2为切线与圆的接触点。
  • 在三角形PC1A1和三角形PC2A2 中
    C1A1P = 角C2A2P = 90 度 { 连接圆心和接触点的线与切线成 90 度角 },
    此外,角度A1PC1 = 角度A2PC2 {垂直对角总是相等}
    所以,角A1C1P = 角A2C2P
    由于角度相同,三角形PC1A1PC2A2相似。
  • 所以,由于三角形的相似性,
    C1P/C2P = C1A1/C2A2 = r1/r2

The ratio of the distance between the centres of the circles and the point of intersection of two transverse common tangents to the circles = radius of the first circle/radius of the second circle

C++
// C++ program to find the ratio
// of the distance between the centres of the circles
// and the point of intersection
// of two transverse common tangents
// to the circles which do not touch each other
 
#include 
using namespace std;
 
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 = 8;
    ratiotang(r1, r2);
    return 0;
}


Java
// Java program to find the ratio
// of the distance between the centres of the circles
// and the point of intersection
// of two transverse common tangents
// to the circles which do not touch each other
 
import java.io.*;
 
class GFG{
 
    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 = 8;
        ratiotang(r1, r2);
    }
}
 
// This code is contributed by NamrataSrivastava1


Python
# Python3 program to find the ratio
# of the distance between the centres of the circles
# and the point of intersection
# of two transverse common tangents
# to the circles which do not touch each other
 
def GCD(a, b):
    if(b!=0):
        return GCD(b, a%b);
    else:
        return a;
 
# Function to find the ratio
def ratiotang(r1, r2):
 
    print("The ratio is", r1 // GCD(r1, r2),
                     ":", r2 // GCD(r1, r2));
 
# Driver code
r1 = 4; r2 = 8;
ratiotang(r1, r2);
 
# This code is contributed by Code_Mech


C#
// C# program to find the ratio
// of the distance between the centres of the circles
// and the point of intersection
// of two transverse common tangents
// to the circles which do not touch each other
using System;
 
class GFG
{
 
    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
    static public void Main ()
    {
         
        int r1 = 4, r2 = 8;
        ratiotang(r1, r2);
    }
}
 
// This code is contributed by Tushil.


PHP


Javascript


输出:
The ratio is 1:2

如果您希望与专家一起参加现场课程,请参阅DSA 现场工作专业课程学生竞争性编程现场课程