How To Get the Arc Length from Given Angle in Java?



An arc of a circle is a segment or portion of the circumference of a circle. In other words, a curve between a pair of distinct points.

The length of the arc refers to the length between two points along the arc (two points along a section of a circle or curve). It is a percentage of the circumference of the circle.

When two lines intersect each other, the common meeting point is called a vertex and the geometrical figure between the two arms/lines is called an angle.

Following diagram will help you to understand the arc and its length:

arc

Length of the Arc

To calculate the length of the arc, we have a formula in mathematics that requires either the radius and central angle or the diameter and central angle (in degrees) of the circle. 

Formula to find the arc length by using the radius:

Arc Length = (theta / 360) x (2 x pi x r )

Where, r refers to the radius of the circle and theta refers to the central angle in degree measure of the arc.

Formula to find the arc length by using diameter:

Arc Length = (theta / 360) x (d x pi)

Where, 'd' refers to the diameter (d = 2r) of the circle and theta refers to the central angle in degree measure of arc.

Input & Output Scenarios

The following input and output scenarios help you to calculate the arc length based on the radius, diameter, and angle:

Scenario 1

Suppose the radius (r) of the circle is 8 and the angle (radian) is 60 degrees:

Input: radius = 8, angle = 60
Output: 8.37758

Calculation: Arc Length = (60 / 360) x (2 x 3.14 * 8) = 8.37758

Scenario 2

Suppose the diameter (d) of the circle is 7 and the angle (radian) is 50 degrees:

Input: diameter = 7, angle = 50
Output: 3.05432

Calculation: Arc Length = (50 / 360) * (7 * 3.14); = 3.05432

Here are the different approaches to calculate the length of the arc:

Calculating arc Length using Radius and Angle

To calculate the arc length, we can use the circle radius and angle in the upper radius formula.b. The radius of a circle is any line from the center to its perimeter. The angle is a radian between two points on the circle.

Example

The following example calculates the length of the arc with a given circle radius 4 and an angle 40 by using the above formula:

public class calculateLength {
   public static void main(String args[]) {
      double radius = 4;
      double angle = 40;
      System.out.println("The given radius of circle: " + radius);
      System.out.println("The given angle of circle: " + angle);
      
      double arcLength;
      
      //if angle is more than 360 then it is Invalid
      if (angle > 360) {
         System.out.println("Invalid angle");
      }
      arcLength = (angle / 360) * (2 * Math.PI * radius);
      System.out.println("The arc length is: " + arcLength);
   }
}

The above program produces the following output:

The given radius of circle: 4.0
The given angle of circle: 40.0
The arc length is: 2.792526803190927

Using Diameter and Angle

We can also calculate the length of the arc by using the diameter and angle of the circle.

The diameter of a circle is any straight line segment that passes through the center of the circle and whose endpoints lie on the circle. The angle is the radian between the two points on the circle.

Example

This is another example of calculating the length of the arc with a circle diameter 6 and an angle 40 by using the above formula:

public class calculateLength {
   public static void main(String args[]) {
      double diameter = 6;
      double angle = 40;
      System.out.println("The given diameter of circle: " + diameter);
      System.out.println("The given angle is: " + angle);
      
      double arcLength;
      
      //if angle is more than 360 then it is Invalid
      if (angle > 360) {
         System.out.println("Invalid angle");
      }
      //calculating arc length
      arcLength = (angle / 360) * (diameter * Math.PI);
      System.out.println("Arc length : " + arcLength);
   }
}

Following is the output of the above program:

The given diameter of circle: 6.0
The given angle is: 40.0
Arc length : 2.0943951023931953

When Angle is Invalid

If the given angle exceeds 360 degrees (i.e., invalid angle), the length of the arc can not be calculated because the arc extends beyond a full circle:

public class calculateLength {
   public static void main(String args[]) {
      double diameter = 6;
      double angle = 420;
      System.out.println("The given diameter of circle: " + diameter);
      System.out.println("The given angle is: " + angle);

      double arcLength;

      //if angle is more than 360 then it is Invalid
      if (angle > 360) {
         System.out.println("Invalid angle");
         return;
      }
      //calculating arc length
      arcLength = (angle / 360) * (diameter * Math.PI);
      System.out.println("Arc length : " + arcLength);
   }
}

Below is the output of the above program:

The given diameter of circle: 6.0
The given angle is: 420.0
Invalid angle
Updated on: 2025-06-10T18:22:52+05:30

509 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements