# Arc length between two angles

As I calculate the length of the arc (green) between two angles;

I need a method like:

arc_lenght (xpos, ypos, radius, ang1, ang2) { return arc_lenght }

• I'm not quite sure what you mean by 'arc length between two angles'. Generally, you can easily find the arc length from the radius and some central angle. Also what does xpos and ypos represent? Are they the center of the circle? Cause that doesn't seem relevant to the problem. – prithul Mar 15 '20 at 6:26
• If you have two angles, there should be two arcs on the circle that join them. Which one do you want? My guess is clockwise from the first angle to the second, is that correct? Well, they should sum up to the circumference, so if you can get one, you can get the other. – Theraot Mar 15 '20 at 11:29

The arc-length, l, of a circle is equal to the angle of the arc, θ, in radians times the radius.

If we assume that ang1 is in the range [0 - ang2] and ang2 is in the range [ang1 - 360] (so ang1 is always the smaller of the two and neither is bigger than 360) then:

float angle = ang1 - ang2;
float rad = angle * PI / 180.0;

I am not sure what xpos and ypos represents, but I don't think they're relevant for getting the arc length.