📌  相关文章
📜  圆的弦长,其半径和弦对中心的角度为给定

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

给定一个圆,它的半径和它的弦在中心处所对的角度是给定的。任务是找到和弦的长度。
例子:

Input: r = 4, x = 63 
Output: 4.17809

Input:: r = 9, x = 71
Output:: 10.448

方法

  1. 让圆以O 为中心,半径为r ,它的弦为AB
  2. 弦的长度为2d ,它在中心所对的角度为2x度。
  3. 由于在弦上垂下的垂线将弦平分,因此垂线也以x度数等分对角2x
  4. 所以,从图中,
    d/r = sin(x*π/180) (这里 x deg 以弧度换算)
  5. 所以, d = rsin(x*π/180)
    因此, 2d = 2rsin(x*π/180)
  6. 所以, length of the chord = 2 * radius * sin(angle/2)

下面是上述方法的实现:

C++
// C++ program to find the length chord
// of the circle whose radius
// and the angle subtended at the centre
// is also given
 
#include 
using namespace std;
 
// Function to find the length of the chord
void length_of_chord(double r, double x)
{
    cout << "The length of the chord"
         << " of the circle is "
         << 2 * r * sin(x * (3.14 / 180))
         << endl;
}
 
// Driver code
int main()
{
    double r = 4, x = 63;
    length_of_chord(r, x);
    return 0;
}


Java
// Java program to find the length chord
// of the circle whose radius
// and the angle subtended at the centre
// is also given
 
class GFG
{
 
// Function to find the length of the chord
static void length_of_chord(double r, double x)
{
    System.out.println("The length of the chord"
        + " of the circle is "
        + 2 * r * Math.sin(x * (3.14 / 180)));
}
 
// Driver code
public static void main(String[] args)
{
    double r = 4, x = 63;
    length_of_chord(r, x);
}
}
 
// This code contributed by Rajput-Ji


Python3
# Python3 program to find the length chord
# of the circle whose radius
# and the angle subtended at the centre
# is also given
 
import math as mt
 
# Function to find the length of the chord
def length_of_chord(r, x):
 
    print("The length of the chord"
        ," of the circle is "
        ,2 * r * mt.sin(x * (3.14 / 180)))
 
 
# Driver code
r = 4
x = 63;
length_of_chord(r, x)
 
# This code is contributed by mohit kumar


C#
// C# program to find the length chord
// of the circle whose radius
// and the angle subtended at the centre
// is also given
using System;
 
class GFG
{
     
    // Function to find the length of the chord
    static void length_of_chord(double r, double x)
    {
        Console.WriteLine("The length of the chord" +
                        " of the circle is " +
                        2 * r * Math.Sin(x * (3.14 / 180)));
                         
    }
 
    // Driver code
    public static void Main(String[] args)
    {
        double r = 4, x = 63;
        length_of_chord(r, x);
    }
}
 
// This code is Contributed by Naman_Garg


PHP


Javascript


输出:
The length of the chord of the circle is 7.12603

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