角度是当两条射线在平面上的公共点相遇时的几何图形。这些射线形成角的边,交汇点称为角的顶点。有一点我们需要记住,形成角度的平面不一定是欧几里得平面。现在,在一个圆中,弧的长度是圆周的一部分。该图解释了我们讨论过的各个部分:
给定一个角度和一个圆的直径,我们可以使用以下公式计算圆弧的长度:
ArcLength = ( 2 * pi * radius ) * ( angle / 360 )
Where pi = 22/7,
diameter = 2 * radius,
angle is in degree.
例子 :
Input :
Diameter = 25
Angle = 45
Explanation : ((22/7) * 25) * (45/360)
Output : 9.821 (rounded)
Input :
Diameter = 80
Angle = 60
Explanation : ((22/7) * 80) * (60/360)
Output : 41.905 (rounded)
注意:如果角度大于或等于 360 度,则无法计算弧长,因为不可能有角度。
C++
// C++ program to calculate
// length of an arc
#include
using namespace std;
// function to calculate
// arc length
double arcLength(double diameter,
double angle)
{
double pi = 22.0 / 7.0;
double arc;
if (angle >= 360)
{
cout<< "Angle cannot",
" be formed";
return 0;
}
else
{
arc = (pi * diameter) *
(angle / 360.0);
return arc;
}
}
// Driver Code
int main()
{
double diameter = 25.0;
double angle = 45.0;
double arc_len = arcLength(diameter,
angle);
cout << (arc_len);
return 0;
}
Java
// Java program to calculate
// length of an arc
public class Arc {
// function to calculate arc length
static double arcLength(double diameter,
double angle)
{
double pi = 22.0 / 7.0;
double arc;
if (angle >= 360) {
System.out.println("Angle cannot"
+ " be formed");
return 0;
}
else {
arc = (pi * diameter) * (angle / 360.0);
return arc;
}
}
// Driver Code
public static void main(String args[])
{
double diameter = 25.0;
double angle = 45.0;
double arc_len = arcLength(diameter, angle);
System.out.println(arc_len);
}
}
Python3
# Python3 code to calculate
# length of an arc
import math
# function to calculate arc length
def arcLength(diameter, angle ):
if angle >= 360:
print("Angle cannot be formed")
return 0
else:
arc = (3.142857142857143 * diameter) * (angle / 360.0)
return arc
# Driver Code
diameter = 25.0
angle = 45.0
arc_len = arcLength(diameter, angle)
print(arc_len)
# This code is contributed by "Sharad_Bhardwaj".
C#
// C# program to calculate length of an arc
using System;
public class GFG {
// function to calculate arc length
static double arcLength(double diameter,
double angle)
{
double pi = 22.0 / 7.0;
double arc;
if (angle >= 360) {
Console.WriteLine("Angle cannot"
+ " be formed");
return 0;
}
else {
arc = (pi * diameter) * (angle / 360.0);
return arc;
}
}
// Driver Code
public static void Main()
{
double diameter = 25.0;
double angle = 45.0;
double arc_len = arcLength(diameter, angle);
Console.WriteLine(arc_len);
}
}
// This code is contributed by Anant Agarwal.
PHP
= 360)
{
echo "Angle cannot",
" be formed";
return 0;
}
else
{
$arc = ($pi * $diameter) *
($angle / 360.0);
return $arc;
}
}
// Driver Code
$diameter = 25.0;
$angle = 45.0;
$arc_len = arcLength($diameter, $angle);
echo ($arc_len);
// This code is contributed by ajit
?>
Javascript
输出:
9.821428571428571