Dadas dos circunferencias de radios dados, teniendo sus centros separados por una distancia dada, tal que las circunferencias no se tocan. La tarea es encontrar la longitud de la tangente transversal común entre los círculos.
Ejemplos:
Input: r1 = 4, r2 = 6, d = 12 Output: 6.63325 Input: r1 = 7, r2 = 9, d = 21 Output: 13.6015
Enfoque :
- Sean los radios de los círculos r1 y r2 respectivamente.
- Sea la distancia entre los centros d unidades.
- Dibujar una línea O’R paralela a PQ,
- ángulo OPQ = ángulo RPQ = 90 grados
ángulo O’QP = 90 grados
{ la línea que une el centro del círculo con el punto de contacto forma un ángulo de 90 grados con la tangente }
- ángulo RPQ + ángulo O’QP = 180 grados
PR || O’Q - Dado que los lados opuestos son paralelos y los ángulos interiores son 90, O’PQR es un rectángulo.
- O’Q = RP = r2 y PQ = O’R
- En el triángulo OO’R
ángulo ORO’ = 90 grados
Por el teorema de Pitágoras ,
OR^2 + O’R^2 = OO’^2
O’R^2 = OO’^2 – OR^2
O’R^2 = d ^2 – (r1+r2)^2
O’R^2 = √(d^2 – (r1+r2)^2)
C++
// C++ program to find the length // of the transverse common tangent // between two circles which // do not touch each other #include <bits/stdc++.h> using namespace std; // Function to find the length // of the transverse common tangent void lengthOfTangent(double r1, double r2, double d) { cout << "The length of the transverse" << " common tangent is " << sqrt(pow(d, 2) - pow((r1 + r2), 2)) << endl; } // Driver code int main() { double r1 = 4, r2 = 6, d = 12; lengthOfTangent(r1, r2, d); return 0; }
Java
// Java program to find the length // of the transverse common tangent // between two circles which // do not touch each other class GFG { // Function to find the length // of the transverse common tangent static void lengthOfTangent(double r1, double r2, double d) { System.out.println("The length of the transverse" + " common tangent is " + Math.sqrt(Math.pow(d, 2) - Math.pow((r1 + r2), 2))); } // Driver code public static void main(String args[]) { double r1 = 4, r2 = 6, d = 12; lengthOfTangent(r1, r2, d); } } // This code has been contributed by 29AjayKumar
Python3
# python 3 program to find the length # of the transverse common tangent # between two circles which # do not touch each other from math import sqrt, pow # Function to find the length # of the transverse common tangent def lengthOfTangent(r1, r2, d): print("The length of the transverse", "common tangent is", '{0:.6g}'.format(sqrt(pow(d, 2) - pow((r1 + r2), 2)))) # Driver code if __name__ == '__main__': r1 = 4 r2 = 6 d = 12 lengthOfTangent(r1, r2, d) # This code is contributed by # Surendra_Gangwar
C#
// C# program to find the length // of the transverse common tangent // between two circles which // do not touch each other using System; class GFG { // Function to find the length // of the transverse common tangent static void lengthOfTangent(double r1, double r2, double d) { Console.WriteLine("The length of the transverse" + " common tangent is " + Math.Sqrt(Math.Pow(d, 2) - Math.Pow((r1 + r2), 2))); } // Driver code static public void Main() { double r1 = 4, r2 = 6, d = 12; lengthOfTangent(r1, r2, d); } } // This code has been contributed by ajit.
PHP
<?php // PHP program to find the length // of the transverse common tangent // between two circles which // do not touch each other // Function to find the length // of the transverse common tangent function lengthOfTangent($r1, $r2, $d) { echo "The length of the transverse common tangent is ", sqrt(pow($d, 2) - pow(($r1 + $r2), 2)) ; } // Driver code $r1 = 4; $r2 = 6; $d = 12; lengthOfTangent($r1, $r2, $d); // This code is contributed by AnkitRai01 ?>
Javascript
<script> // javascript program to find the length // of the transverse common tangent // between two circles which // do not touch each other // Function to find the length // of the transverse common tangent function lengthOfTangent(r1,r2 , d) { document.write("The length of the transverse" + " common tangent is " + Math.sqrt(Math.pow(d, 2) - Math.pow((r1 + r2), 2))); } // Driver code var r1 = 4, r2 = 6, d = 12; lengthOfTangent(r1, r2, d); // This code contributed by Princi Singh </script>
Producción:
The length of the transverse common tangent is 6.63325
Complejidad de tiempo: O(1)
Espacio Auxiliar: O(1)
Publicación traducida automáticamente
Artículo escrito por IshwarGupta y traducido por Barcelona Geeks. The original can be accessed here. Licence: CCBY-SA