📜  给定圆弧的宽度和高度时的圆半径

📅  最后修改于: 2021-04-23 21:45:01             🧑  作者: Mango

给定一个圆,其中给出了弧的宽度和高度。任务是借助圆弧的宽度和高度找到圆的半径。
例子:

Input: d = 4, h = 1 
Output: The radius of the circle is 2.5

Input: d = 14, h = 8
Output: The radius of the circle is 7.0625

方法

  • 令圆的半径为r
  • 令弧的高度和宽度为hd
  • 现在,直径DC将和弦AB分为两半,每半的长度为d / 2
  • 直径也被弦线分为两部分,弧内的部分h和其余的2r-h
  • 现在从相交和弦定理,
    h *(2r-h)=(d / 2)^ 2
    或2rh – h ^ 2 = d ^ 2/4
    因此,r = d ^ 2 / 8h + h / 2
  • 所以,圆的半径
    r = d^2/8h + h/2
C++
// C++ program to find
// radius of the circle
// when the width and height
// of an arc is given
 
#include 
using namespace std;
 
// Function to find the radius
void rad(double d, double h)
{
    cout << "The radius of the circle is "
        << ((d * d) / (8 * h) + h / 2)
        << endl;
}
 
// Driver code
int main()
{
    double d = 4, h = 1;
    rad(d, h);
    return 0;
}


Java
// Java program to find
// radius of the circle
// when the width and height
// of an arc is given
class GFG
{
 
// Function to find the radius
static void rad(double d, double h)
{
    System.out.println( "The radius of the circle is "
        + ((d * d) / (8 * h) + h / 2));
}
 
// Driver code
public static void main(String[] args)
{
    double d = 4, h = 1;
    rad(d, h);
}
}
 
/* This code contributed by PrinciRaj1992 */


Python3
# Python3 program to find
# radius of the circle
# when the width and height
# of an arc is given
 
# Function to find the radius
def rad(d, h):
    print("The radius of the circle is",
        ((d * d) / (8 * h) + h / 2))
 
# Driver code
d = 4; h = 1;
rad(d, h);
 
# This code is contributed by 29AjayKumar


C#
// C# program to find
// radius of the circle
// when the width and height
// of an arc is given
using System;
 
class GFG
{
 
// Function to find the radius
static void rad(double d, double h)
{
    Console.WriteLine( "The radius of the circle is "
        + ((d * d) / (8 * h) + h / 2));
}
 
// Driver code
public static void Main()
{
    double d = 4, h = 1;
    rad(d, h);
}
}
 
// This code is contributed by AnkitRai01


PHP


Javascript


输出:

The radius of the circle is 2.5