Arc length from given Angle (original ) (raw )Last Updated : 17 Feb, 2023
An angle is a geometrical figure when two rays meet at a common point on a plane. These rays form the sides of the angle and the meeting point is referred as the vertex of the angle. There is something that we need to keep in mind that the plane that forms an angle doesn't need to be a Euclidean plane. Now, in a circle, the length of an arc is a portion of the circumference. The figure explains the various parts we have discussed:
Given an angle and the diameter of a circle, we can calculate the length of the arc using the formula:
ArcLength = ( 2 * pi * radius ) * ( angle / 360 )
Where pi = 22/7,
diameter = 2 * radius,
angle is in degree.
Examples :
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)
Note: If angle is greater than or equal to 360 degree, then the arc length cannot be calculated, since no angle is possible.
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 arcimport math
function to calculate arc lengthdef arcLength(diameter, angle ):
if angle >= 360:
print("Angle cannot be formed")
return 0
else:
arc = (3.142857142857143 * diameter) * (angle / 360.0)
return arc
Driver Codediameter = 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=(arc = ( a rc = ( pi * $diameter) *
($angle / 360.0);
return $arc;
}
}
// Driver Code
$diameter = 25.0; angle=45.0;<spanclass="katex"><spanclass="katex−mathml"><mathxmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>a</mi><mi>r</mi><msub><mi>c</mi><mi>l</mi></msub><mi>e</mi><mi>n</mi><mo>=</mo><mi>a</mi><mi>r</mi><mi>c</mi><mi>L</mi><mi>e</mi><mi>n</mi><mi>g</mi><mi>t</mi><mi>h</mi><mostretchy="false">(</mo></mrow><annotationencoding="application/x−tex">arclen=arcLength(</annotation></semantics></math></span><spanclass="katex−html"aria−hidden="true"><spanclass="base"><spanclass="strut"style="height:0.5806em;vertical−align:−0.15em;"></span><spanclass="mordmathnormal">a</span><spanclass="mordmathnormal"style="margin−right:0.02778em;">r</span><spanclass="mord"><spanclass="mordmathnormal">c</span><spanclass="msupsub"><spanclass="vlist−tvlist−t2"><spanclass="vlist−r"><spanclass="vlist"style="height:0.3361em;"><spanstyle="top:−2.55em;margin−left:0em;margin−right:0.05em;"><spanclass="pstrut"style="height:2.7em;"></span><spanclass="sizingreset−size6size3mtight"><spanclass="mordmathnormalmtight"style="margin−right:0.01968em;">l</span></span></span></span><spanclass="vlist−s"></span></span><spanclass="vlist−r"><spanclass="vlist"style="height:0.15em;"><span></span></span></span></span></span></span><spanclass="mordmathnormal">e</span><spanclass="mordmathnormal">n</span><spanclass="mspace"style="margin−right:0.2778em;"></span><spanclass="mrel">=</span><spanclass="mspace"style="margin−right:0.2778em;"></span></span><spanclass="base"><spanclass="strut"style="height:1em;vertical−align:−0.25em;"></span><spanclass="mordmathnormal">a</span><spanclass="mordmathnormal">rc</span><spanclass="mordmathnormal">L</span><spanclass="mordmathnormal">e</span><spanclass="mordmathnormal">n</span><spanclass="mordmathnormal"style="margin−right:0.03588em;">g</span><spanclass="mordmathnormal">t</span><spanclass="mordmathnormal">h</span><spanclass="mopen">(</span></span></span></span>diameter,angle = 45.0; <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>a</mi><mi>r</mi><msub><mi>c</mi><mi>l</mi></msub><mi>e</mi><mi>n</mi><mo>=</mo><mi>a</mi><mi>r</mi><mi>c</mi><mi>L</mi><mi>e</mi><mi>n</mi><mi>g</mi><mi>t</mi><mi>h</mi><mo stretchy="false">(</mo></mrow><annotation encoding="application/x-tex">arc_len = arcLength(</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.5806em;vertical-align:-0.15em;"></span><span class="mord mathnormal">a</span><span class="mord mathnormal" style="margin-right:0.02778em;">r</span><span class="mord"><span class="mord mathnormal">c</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3361em;"><span style="top:-2.55em;margin-left:0em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mathnormal mtight" style="margin-right:0.01968em;">l</span></span></span></span><span class="vlist-s"></span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mord mathnormal">e</span><span class="mord mathnormal">n</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mord mathnormal">a</span><span class="mord mathnormal">rc</span><span class="mord mathnormal">L</span><span class="mord mathnormal">e</span><span class="mord mathnormal">n</span><span class="mord mathnormal" style="margin-right:0.03588em;">g</span><span class="mord mathnormal">t</span><span class="mord mathnormal">h</span><span class="mopen">(</span></span></span></span>diameter, an g l e = 45.0 ; < s p an c l a ss = " ka t e x " >< s p an c l a ss = " ka t e x − ma t hm l " >< ma t h x m l n s = " h ttp : // www . w 3. or g /1998/ M a t h / M a t h M L " >< se man t i cs >< m ro w >< mi > a < / mi >< mi > r < / mi >< m s u b >< mi > c < / mi >< mi > l < / mi >< / m s u b >< mi > e < / mi >< mi > n < / mi >< m o >=< / m o >< mi > a < / mi >< mi > r < / mi >< mi > c < / mi >< mi > L < / mi >< mi > e < / mi >< mi > n < / mi >< mi > g < / mi >< mi > t < / mi >< mi > h < / mi >< m os t re t c h y = " f a l se " > ( < / m o >< / m ro w >< ann o t a t i o n e n co d in g = " a ppl i c a t i o n / x − t e x " > a r c l e n = a rc L e n g t h ( < / ann o t a t i o n >< / se man t i cs >< / ma t h >< / s p an >< s p an c l a ss = " ka t e x − h t m l " a r ia − hi dd e n = " t r u e " >< s p an c l a ss = " ba se " >< s p an c l a ss = " s t r u t " s t y l e = " h e i g h t : 0.5806 e m ; v er t i c a l − a l i g n : − 0.15 e m ; " >< / s p an >< s p an c l a ss = " m or d ma t hn or ma l " > a < / s p an >< s p an c l a ss = " m or d ma t hn or ma l " s t y l e = " ma r g in − r i g h t : 0.02778 e m ; " > r < / s p an >< s p an c l a ss = " m or d " >< s p an c l a ss = " m or d ma t hn or ma l " > c < / s p an >< s p an c l a ss = " m s u p s u b " >< s p an c l a ss = " v l i s t − t v l i s t − t 2" >< s p an c l a ss = " v l i s t − r " >< s p an c l a ss = " v l i s t " s t y l e = " h e i g h t : 0.3361 e m ; " >< s p an s t y l e = " t o p : − 2.55 e m ; ma r g in − l e f t : 0 e m ; ma r g in − r i g h t : 0.05 e m ; " >< s p an c l a ss = " p s t r u t " s t y l e = " h e i g h t : 2.7 e m ; " >< / s p an >< s p an c l a ss = " s i z in g rese t − s i ze 6 s i ze 3 m t i g h t " >< s p an c l a ss = " m or d ma t hn or ma l m t i g h t " s t y l e = " ma r g in − r i g h t : 0.01968 e m ; " > l < / s p an >< / s p an >< / s p an >< / s p an >< s p an c l a ss = " v l i s t − s " > < / s p an >< / s p an >< s p an c l a ss = " v l i s t − r " >< s p an c l a ss = " v l i s t " s t y l e = " h e i g h t : 0.15 e m ; " >< s p an >< / s p an >< / s p an >< / s p an >< / s p an >< / s p an >< / s p an >< s p an c l a ss = " m or d ma t hn or ma l " > e < / s p an >< s p an c l a ss = " m or d ma t hn or ma l " > n < / s p an >< s p an c l a ss = " m s p a ce " s t y l e = " ma r g in − r i g h t : 0.2778 e m ; " >< / s p an >< s p an c l a ss = " m re l " >=< / s p an >< s p an c l a ss = " m s p a ce " s t y l e = " ma r g in − r i g h t : 0.2778 e m ; " >< / s p an >< / s p an >< s p an c l a ss = " ba se " >< s p an c l a ss = " s t r u t " s t y l e = " h e i g h t : 1 e m ; v er t i c a l − a l i g n : − 0.25 e m ; " >< / s p an >< s p an c l a ss = " m or d ma t hn or ma l " > a < / s p an >< s p an c l a ss = " m or d ma t hn or ma l " > rc < / s p an >< s p an c l a ss = " m or d ma t hn or ma l " > L < / s p an >< s p an c l a ss = " m or d ma t hn or ma l " > e < / s p an >< s p an c l a ss = " m or d ma t hn or ma l " > n < / s p an >< s p an c l a ss = " m or d ma t hn or ma l " s t y l e = " ma r g in − r i g h t : 0.03588 e m ; " > g < / s p an >< s p an c l a ss = " m or d ma t hn or ma l " > t < / s p an >< s p an c l a ss = " m or d ma t hn or ma l " > h < / s p an >< s p an c l a ss = " m o p e n " > ( < / s p an >< / s p an >< / s p an >< / s p an > d iam e t er , angle);
echo ($arc_len);
// This code is contributed by ajit
?>
JavaScript
`
Output:
9.821428571428571
Time Complexity: O(1)Auxiliary Space: O(1)