Length of an arc between two angles: Difference between revisions

Added Easylang
(Added Easylang)
 
(43 intermediate revisions by 26 users not shown)
Line 5:
Write a method (function, procedure etc.) in your language which calculates the length of the major arc of a circle of given radius between two angles.
 
In [https://imgur.com/a/aYgDLxr this diagram] the major arc is colored green   (note: this website leaves cookies).
 
Illustrate the use of your method by calculating the length of the major arc of a circle of radius 10 units, between angles of 10 and 120 degrees.
 
=={{header|11l}}==
{{trans|Python}}
 
<syntaxhighlight lang="11l">F arc_length(r, angleA, angleB)
R (360.0 - abs(angleB - angleA)) * math:pi * r / 180.0
 
print(arc_length(10, 10, 120))</syntaxhighlight>
 
{{out}}
<pre>
43.6332
</pre>
 
=={{header|Action!}}==
{{libheader|Action! Tool Kit}}
{{libheader|Action! Real Math}}
<syntaxhighlight lang="action!">INCLUDE "H6:REALMATH.ACT"
 
PROC ArcLength(REAL POINTER r,a1,a2,len)
REAL tmp1,tmp2,r180,r360,pi
 
IntToReal(360,r360)
IntToReal(180,r180)
ValR("3.14159265",pi)
RealAbsDiff(a1,a2,tmp1) ;tmp1=abs(a1-a2)
RealSub(r360,tmp1,tmp2) ;tmp2=360-abs(a1-a2)
RealMult(tmp2,pi,tmp1) ;tmp1=(360-abs(a1-a2))*pi
RealMult(tmp1,r,tmp2) ;tmp2=(360-abs(a1-a2))*pi*r
RealDiv(tmp2,r180,len) ;len=(360-abs(a1-a2))*pi*r/180
RETURN
 
PROC Main()
REAL r,a1,a2,len
 
Put(125) PutE() ;clear screen
Print("Length of arc: ")
IntToReal(10,r)
IntToReal(10,a1)
IntToReal(120,a2)
ArcLength(r,a1,a2,len)
PrintR(len)
RETURN</syntaxhighlight>
{{out}}
[https://gitlab.com/amarok8bit/action-rosetta-code/-/raw/master/images/Length_of_an_arc_between_two_angles.png Screenshot from Atari 8-bit computer]
<pre>
Length of arc: 43.63323122
</pre>
 
=={{header|Ada}}==
<syntaxhighlight lang="ada">with Ada.Text_Io;
with Ada.Numerics;
 
procedure Calculate_Arc_Length is
use Ada.Text_Io;
 
type Angle_Type is new Float range 0.0 .. 360.0; -- In degrees
type Distance is new Float range 0.0 .. Float'Last; -- In units
 
function Major_Arc_Length (Angle_1, Angle_2 : Angle_Type;
Radius : Distance)
return Distance
is
Pi : constant := Ada.Numerics.Pi;
Circumference : constant Distance := 2.0 * Pi * Radius;
Major_Angle : constant Angle_Type := 360.0 - abs (Angle_2 - Angle_1);
Arc_Length : constant Distance :=
Distance (Major_Angle) / 360.0 * Circumference;
begin
return Arc_Length;
end Major_Arc_Length;
 
package Distance_Io is new Ada.Text_Io.Float_Io (Distance);
 
Arc_Length : constant Distance := Major_Arc_Length (Angle_1 => 10.0,
Angle_2 => 120.0,
Radius => 10.0);
begin
Put ("Arc length : ");
Distance_Io.Put (Arc_Length, Exp => 0, Aft => 4);
New_Line;
end Calculate_Arc_Length;</syntaxhighlight>
{{out}}
<pre>
Arc length : 43.6332
</pre>
 
Ada can be simple and concise:
<syntaxhighlight lang="ada">
with ada.float_text_io; use ada.float_text_io; -- for put()
with ada.numerics; use ada.numerics; -- for pi
with ada.text_io; use ada.text_io; -- for new_line
 
procedure arc_length_simple is
 
function arc_length(radius, deg1, deg2: Float) return Float is
((360.0 - abs(deg1 - deg2)) * pi * radius / 180.0);
 
begin
put(arc_length(10.0, 120.0, 10.0), fore=>0, aft=>15, exp=>0);
new_line;
end arc_length_simple;
</syntaxhighlight>
 
Ada can do automatic compile-time checking of types. In this example, degrees and radians cannot be accidentally mixed:
<syntaxhighlight lang="ada">
with ada.float_text_io; use ada.float_text_io; -- for put()
with ada.numerics; use ada.numerics; -- for pi
with ada.text_io; use ada.text_io; -- for new_line
 
procedure arc_length_both is
type Degree is new Float;
type Radian is new Float;
 
function arc_length(radius: Float; deg1, deg2: Degree) return Float is
((360.0 - abs(Float(deg1) - Float(deg2))) * radius * pi / 180.0);
 
function arc_length(radius: Float; rad1, rad2: Radian) return Float is
((2.0 * pi - abs(Float(rad1) - Float(rad2))) * radius);
 
d1 : Degree := 120.0;
d2 : Degree := 10.0;
r1 : Radian := Radian(d1) * pi / 180.0;
r2 : Radian := Radian(d2) * pi / 180.0;
begin
put(arc_length(10.0, d1, d2), fore=>0, aft=>15, exp=>0);
new_line;
put(arc_length(10.0, r1, r2), fore=>0, aft=>15, exp=>0);
new_line;
-- Next line will not compile as you cannot mix Degree and Radian
-- put(arc_length(10.0, d1, r2), fore=>0, aft=>15, exp=>0);
end arc_length_both;
</syntaxhighlight>
 
=={{header|ALGOL 68}}==
{{Trans|ALGOL W}}
<syntaxhighlight lang="algol68">
BEGIN
# returns the length of the arc between the angles a and b on a circle of radius r #
# the angles should be specified in degrees #
PROC major arc length = ( REAL a, b, r )REAL:
BEGIN
REAL angle := ABS ( a - b );
WHILE angle > 360 DO angle -:= 360 OD;
IF angle < 180 THEN angle := 360 - angle FI;
( r * angle * pi ) / 180
END # majorArcLength # ;
# task test case #
print( ( fixed( major arc length( 10, 120, 10 ), -10, 4 ), newline ) )
END
</syntaxhighlight>
{{out}}
<pre>
43.6332
</pre>
 
=={{header|ALGOL W}}==
Follows the Fortran interpretation of the task and finds the length of the major arc.
<syntaxhighlight lang="algolw">begin
% returns the length of the arc between the angles a and b on a circle of radius r %
% the angles should be specified in degrees %
real procedure majorArcLength( real value a, b, r ) ;
begin
real angle;
angle := abs( a - b );
while angle > 360 do angle := angle - 360;
if angle < 180 then angle := 360 - angle;
( r * angle * PI ) / 180
end majorArcLength ;
% task test case %
write( r_w := 10, r_d := 4, r_format := "A", majorArcLength( 10, 120, 10 ) )
end.</syntaxhighlight>
{{out}}
<pre>
43.6332
</pre>
 
=={{header|APL}}==
{{works with|Dyalog APL}}
<syntaxhighlight lang="apl">arc ← (○÷180)×⊣×360-(|(-/⊢))</syntaxhighlight>
{{out}}
<pre> 10 arc 10 120
43.6332313</pre>
 
=={{header|Arturo}}==
 
<syntaxhighlight lang="arturo">degToRad: function [deg]-> deg * pi // 180
doublePi: 2 * pi
 
arcLength: function [r, a, b][
d: (abs a-b) % doublePi
return r * (d >= pi)? -> d -> doublePi - d
]
 
print ["Arc length:" to :string .format:".5f" arcLength 10 degToRad 10.0 degToRad 120.0]</syntaxhighlight>
 
{{out}}
 
<pre>Arc length: 43.63323</pre>
 
=={{header|AutoHotkey}}==
<syntaxhighlight lang="autohotkey">MsgBox % result := arcLength(10, 10, 120)
return
 
arcLength(radius, angle1, angle2){
return (360 - Abs(angle2-angle1)) * (π := 3.141592653589793) * radius / 180
}</syntaxhighlight>
{{out}}
<pre>43.633231</pre>
 
=={{header|AWK}}==
<syntaxhighlight lang="awk">
<lang AWK>
# syntax: GAWK -f LENGTH_OF_AN_ARC_BETWEEN_TWO_ANGLES.AWK
# converted from PHIX
Line 22 ⟶ 230:
}
function abs(x) { if (x >= 0) { return x } else { return -x } }
</syntaxhighlight>
</lang>
{{out}}
<pre>
43.6332313
</pre>
 
=={{header|BASIC}}==
<syntaxhighlight lang="basic">10 DATA 10, 10, 120
20 READ R, A1, A2
30 GOSUB 100
40 PRINT A
50 END
100 REM Calculate length of arc of radius R, angles A1 and A2
110 A = ATN(1)*R*(360-ABS(A1-A2))/45
120 RETURN</syntaxhighlight>
{{out}}
<pre> 43.6332</pre>
 
=={{header|C}}==
{{Trans|AWK}}
<syntaxhighlight lang="c">
<lang c>
#define PI 3.14159265358979323846
#define ABS(x) (x<0?-x:x)
Line 42 ⟶ 262:
printf("%.7f\n",arc_length(10, 10, 120));
}
</syntaxhighlight>
</lang>
{{out}}
<pre>
Line 50 ⟶ 270:
=={{header|C++}}==
{{trans|Kotlin}}
<langsyntaxhighlight lang="cpp">#include <iostream>
 
#define _USE_MATH_DEFINES
Line 63 ⟶ 283:
std::cout << "arc length: " << al << '\n';
return 0;
}</langsyntaxhighlight>
{{out}}
<pre>arc length: 43.6332</pre>
 
=={{header|D}}==
{{trans|C++}}
<syntaxhighlight lang="d">import std.math;
import std.stdio;
 
double arcLength(double radius, double angle1, double angle2) {
return (360.0 - abs(angle2 - angle1)) * PI * radius / 180.0;
}
 
void main() {
writeln("arc length: ", arcLength(10.0, 10.0, 120.0));
}</syntaxhighlight>
{{out}}
<pre>arc length: 43.6332</pre>
Line 69 ⟶ 304:
=={{header|Delphi}}==
{{Trans|AWK}}
<syntaxhighlight lang="delphi">
<lang Delphi>
program Length_of_an_arc;
 
Line 87 ⟶ 322:
Readln;
end.
</syntaxhighlight>
</lang>
{{out}}
<pre>
43.6332313
</pre>
 
=={{header|EasyLang}}==
{{trans|Python}}
<syntaxhighlight>
func arc_length r angleA angleB .
return (360 - abs (angleB - angleA)) * pi * r / 180
.
print arc_length 10 10 120
</syntaxhighlight>
{{out}}
<pre>
43.63
</pre>
 
=={{header|Factor}}==
<langsyntaxhighlight lang="factor">USING: kernel math math.constants math.trig prettyprint ;
 
: arc-length ( radius angle angle -- x )
- abs deg>rad 2pi swap - * ;
 
10 10 120 arc-length .</langsyntaxhighlight>
{{out}}
<pre>
43.63323129985824
</pre>
 
=={{header|FOCAL}}==
<syntaxhighlight lang="focal">01.10 S A1=10 ;C SET PARAMETERS
01.20 S A2=120
01.30 S R=10
01.40 D 2 ;C CALL SUBROUTINE 2
01.50 T %6.4,A,! ;C DISPLAY RESULT
01.60 Q
 
02.01 C CALCULATE LENGTH OF ARC OF RADIUS R, ANGLES A1 AND A2
02.10 S A=(360 - FABS(A2-A1)) * (3.14159 / 180) * R</syntaxhighlight>
{{out}}
<pre>= 43.6332</pre>
 
=={{header|Fortran}}==
The Fortran subroutine contains the MAX(DIF, 360. - DIF) operation. Other solutions presented here correspond to different interpretations of the problem. This subroutine computes the length of the major arc, which is not necessarily equal to distance traveling counter-clockwise.
<langsyntaxhighlight lang="fortran">*-----------------------------------------------------------------------
* given: polar coordinates of two points on a circle of known radius
* find: length of the major arc between these points
Line 154 ⟶ 415:
END
 
</syntaxhighlight>
</lang>
{{out}}
<pre> first angle: 120.000000 second angle: 10.0000000 radius: 10.0000000 Length of major arc: 43.6332321
first angle: 10.0000000 second angle: 120.000000 radius: 10.0000000 Length of major arc: 43.6332321
first angle: 180.000000 second angle: 270.000000 radius: 10.0000000 Length of major arc: 47.1238899
</pre>
 
=={{Header|FreeBASIC}}==
 
<syntaxhighlight lang="freebasic">
#define DEG 0.017453292519943295769236907684886127134
 
function arclength( r as double, a1 as double, a2 as double ) as double
return (360 - abs(a2 - a1)) * DEG * r
end function
print arclength(10, 10, 120)
</syntaxhighlight>
{{out}}
<pre>
43.63323129985824
</pre>
 
=={{header|Go}}==
{{trans|Julia}}
<langsyntaxhighlight lang="go">package main
 
import (
Line 176 ⟶ 453:
func main() {
fmt.Println(arcLength(10, 10, 120))
}</langsyntaxhighlight>
 
{{out}}
Line 182 ⟶ 459:
43.63323129985823
</pre>
 
=={{header|Haskell}}==
{{Trans|Julia}}
<syntaxhighlight lang="haskell">arcLength radius angle1 angle2 = (360.0 - (abs $ angle1 - angle2)) * pi * radius / 180.0
 
main = putStrLn $ "arcLength 10.0 10.0 120.0 = " ++ show (arcLength 10.0 10.0 120.0)</syntaxhighlight>
{{out}}
<pre>arcLength 10.0 10.0 120.0 = 43.63323129985823</pre>
 
=={{header|J}}==
 
Interpreting the task requirements as asking for the length of a clockwise arc between two angles whose values are provided in degrees.
 
<syntaxhighlight lang=J>clockwise=: - + 360 * < NB. clockwise effective angle between two provided angles
length=: * 2r360p1 * ]</syntaxhighlight> NB. use radius to find length of angle
 
Example use:
<syntaxhighlight lang=J> 10 length 10 clockwise 120
43.6332
5 length 10 clockwise 120
21.8166
10 length 120 clockwise 90
5.23599</syntaxhighlight>
 
=={{header|Java}}==
<syntaxhighlight lang="java">public static double arcLength(double r, double a1, double a2){
return (360.0 - Math.abs(a2-a1))*Math.PI/180.0 * r;
}</syntaxhighlight>
 
=={{header|JavaScript}}==
{{Trans|AWK}}
<syntaxhighlight lang="javascript">
<lang JavaScript>
function arc_length(radius, angle1, angle2) {
return (360 - Math.abs(angle2 - angle1)) * Math.PI / 180 * radius;
Line 191 ⟶ 496:
 
console.log(arc_length(10, 10, 120).toFixed(7));
</syntaxhighlight>
</lang>
 
{{out}}
<pre>
43.6332313
</pre>
 
=={{header|jq}}==
{{trans|Julia}}
{{works with|jq}}
'''Works with gojq, the Go implementation of jq'''
 
As noted in the entry for [[#Julia|Julia]], the function defined here does not correspond to the arc subtended by an angle.
 
In case you're wondering why `length` appears below where you might expect `abs`, rest assured that jq's `length` applied to a number yields its absolute value.
<syntaxhighlight lang="jq"># Output is in the same units as radius; angles are in degrees.
def arclength(radius; angle1; angle2):
def pi: 1 | atan * 4;
(360 - ((angle2 - angle1)|length)) * (pi/180) * radius;
 
# The task:
arclength(10; 10; 120)</syntaxhighlight>
# {{out}}
<pre>
43.63323129985824
</pre>
 
=={{header|Julia}}==
The task seems to be to find the distance along the circumference of the circle which is NOT swept out between the two angles.
<langsyntaxhighlight lang="julia">
arclength(r, angle1, angle2) = (360 - abs(angle2 - angle1)) * π/180 * r
@show arclength(10, 10, 120) # --> arclength(10, 10, 120) = 43.63323129985823
</syntaxhighlight>
</lang>
 
=={{header|Kotlin}}==
{{trans|Go}}
<langsyntaxhighlight lang="scala">import kotlin.math.PI
import kotlin.math.abs
 
Line 217 ⟶ 542:
val al = arcLength(10.0, 10.0, 120.0)
println("arc length: $al")
}</langsyntaxhighlight>
{{out}}
<pre>arc length: 43.63323129985823</pre>
 
=={{header|Lua}}==
{{trans|D}}
<syntaxhighlight lang="lua">function arcLength(radius, angle1, angle2)
return (360.0 - math.abs(angle2 - angle1)) * math.pi * radius / 180.0
end
 
function main()
print("arc length: " .. arcLength(10.0, 10.0, 120.0))
end
 
main()</syntaxhighlight>
{{out}}
<pre>arc length: 43.633231299858</pre>
 
=={{header|Mathematica}}/{{header|Wolfram Language}}==
<syntaxhighlight lang="mathematica">ClearAll[MajorArcLength]
MajorArcLength[r_, {a1_, a2_}] := Module[{d},
d = Mod[Abs[a1 - a2], 360];
d = Max[d, 360 - d]; (* this will select the major arc *)
d Degree r
]
MajorArcLength[10, {10, 120}] // N</syntaxhighlight>
{{out}}
<pre>43.6332</pre>
 
=={{header|Nim}}==
<syntaxhighlight lang="nim">import math, strformat
 
const TwoPi = 2 * Pi
 
func arcLength(r, a, b: float): float =
## Return the length of the major arc in a circle of radius "r"
## between angles "a" and "b" expressed in radians.
let d = abs(a - b) mod TwoPi
result = r * (if d >= Pi: d else: TwoPi - d)
 
echo &"Arc length: {arcLength(10, degToRad(10.0), degToRad(120.0)):.5f}"</syntaxhighlight>
 
{{out}}
<pre>Arc length: 43.63323</pre>
 
=={{header|Perl}}==
{{trans|Raku}}
<langsyntaxhighlight lang="perl">use strict;
use warnings;
use utf8;
Line 247 ⟶ 613:
[-90, 180, 10/π],
[-90, 0, 10/π],
[ 90, 0, 10/π];</langsyntaxhighlight>
{{out}}
<pre>Arc length: 43.63323 Parameters: (2.0943951, 0.1745329, 10.0000000)
Line 258 ⟶ 624:
=={{header|Phix}}==
{{trans|Julia}}
<!--<syntaxhighlight lang="phix">(phixonline)-->
<lang Phix>function arclength(atom r, angle1, angle2)
<span style="color: #008080;">with</span> <span style="color: #008080;">javascript_semantics</span>
return (360 - abs(angle2 - angle1)) * PI/180 * r
<span style="color: #008080;">function</span> <span style="color: #000000;">arclength</span><span style="color: #0000FF;">(</span><span style="color: #004080;">atom</span> <span style="color: #000000;">r</span><span style="color: #0000FF;">,</span> <span style="color: #000000;">angle1</span><span style="color: #0000FF;">,</span> <span style="color: #000000;">angle2</span><span style="color: #0000FF;">)</span>
end function
<span style="color: #008080;">return</span> <span style="color: #0000FF;">(</span><span style="color: #000000;">360</span> <span style="color: #0000FF;">-</span> <span style="color: #7060A8;">abs</span><span style="color: #0000FF;">(</span><span style="color: #000000;">angle2</span> <span style="color: #0000FF;">-</span> <span style="color: #000000;">angle1</span><span style="color: #0000FF;">))</span> <span style="color: #0000FF;">*</span> <span style="color: #004600;">PI</span><span style="color: #0000FF;">/</span><span style="color: #000000;">180</span> <span style="color: #0000FF;">*</span> <span style="color: #000000;">r</span>
?arclength(10, 10, 120) -- 43.6332313</lang>
<span style="color: #008080;">end</span> <span style="color: #008080;">function</span>
<span style="color: #0000FF;">?</span><span style="color: #000000;">arclength</span><span style="color: #0000FF;">(</span><span style="color: #000000;">10</span><span style="color: #0000FF;">,</span> <span style="color: #000000;">10</span><span style="color: #0000FF;">,</span> <span style="color: #000000;">120</span><span style="color: #0000FF;">)</span> <span style="color: #000080;font-style:italic;">-- 43.6332313</span>
<!--</syntaxhighlight>-->
 
=={{header|Python}}==
<syntaxhighlight lang="python">import math
 
def arc_length(r, angleA, angleB):
return (360.0 - abs(angleB - angleA)) * math.pi * r / 180.0
 
 
</syntaxhighlight>
<pre>
radius = 10
angleA = 10
angleB = 120
 
result = arc_length(radius, angleA, angleB)
print(result)
 
Output:
43.63323129985823
</pre>
 
=={{header|Raku}}==
Line 280 ⟶ 669:
degrees to radians and a postfix ᵍ to convert gradians to radians.
 
<syntaxhighlight lang="raku" perl6line>sub arc ( Real \a1, Real \a2, :r(:$radius) = 1 ) {
( ([-] (a2, a1).map((* + τ) % τ)) + τ ) % τ × $radius
}
Line 299 ⟶ 688:
\(175ᵍ, -45ᵍ, :r(10/π)) { # test gradian parameters
printf "Arc length: %8s Parameters: %s\n", arc(|$_).round(.000001), $_.raku
}</langsyntaxhighlight>
{{out}}
<pre>Task example: from 120° counter-clockwise to 10° with 10 unit radius
Line 317 ⟶ 706:
 
This REXX version handles angles (in degrees) that may be &nbsp; <big> &gt; </big> &nbsp; 360º.
<langsyntaxhighlight lang="rexx">/*REXX program calculates the length of an arc between two angles (stated in degrees).*/
parse arg radius angle1 angle2 . /*obtain optional arguments from the CL*/
if radius=='' | radius=="," then radius= 10 /*Not specified? Then use the default.*/
Line 332 ⟶ 721:
arcLength: procedure; parse arg r,a1,a2; #=360; return (#-abs(a1//#-a2//#)) * pi()/180 * r
/*──────────────────────────────────────────────────────────────────────────────────────*/
pi: pi= 3.1415926535897932384626433832795; return pi /*use 32 digs (overkill).*/</langsyntaxhighlight>
{{out|output|text=&nbsp; when using the default inputs:}}
<pre>
Line 341 ⟶ 730:
arc length = 43.6332313
</pre>
 
=={{header|Ring}}==
<syntaxhighlight lang="ring">
decimals(7)
pi = 3.14159265
 
see "Length of an arc between two angles:" + nl
see arcLength(10,10,120) + nl
 
func arcLength(radius,angle1,angle2)
x = (360 - fabs(angle2-angle1)) * pi / 180 * radius
return x
</syntaxhighlight>
{{out}}
<pre>
Length of an arc between two angles:
43.6332313
</pre>
 
=={{header|RPL}}==
The function also works when the difference between the two angles is greater than 180 degrees.
≪ DEG - ABS 360 OVER - MAX
* 180 / π * →NUM
≫ '<span style="color:blue">MAJARC</span>' STO
 
10 10 120 <span style="color:blue">MAJARC</span>
10 10 350 <span style="color:blue">MAJARC</span>
{{out}}
<pre>
2: 43.6332312999
1: 59.3411945678
</pre>
 
=={{header|Ruby}}==
{{trans|C}}
<syntaxhighlight lang="ruby">def arc_length(radius, angle1, angle2)
return (360.0 - (angle2 - angle1).abs) * Math::PI / 180.0 * radius
end
 
print "%.7f\n" % [arc_length(10, 10, 120)]</syntaxhighlight>
{{out}}
<pre>43.6332313</pre>
 
=={{header|V (Vlang)}}==
{{trans|go}}
<syntaxhighlight lang="v (vlang)">import math
 
fn arc_length(radius f64, angle1 f64, angle2 f64) f64 {
return (360 - math.abs(angle2-angle1)) * math.pi * radius/180
}
fn main() {
println(arc_length(10, 10, 120))
}</syntaxhighlight>
{{out}}
<pre>43.633231299858</pre>
 
=={{header|Wren}}==
{{trans|Julia}}
<langsyntaxhighlight ecmascriptlang="wren">var arcLength = Fn.new { |r, angle1, angle2| (360 - (angle2 - angle1).abs) * Num.pi / 180 * r }
 
System.print(arcLength.call(10, 10, 120))</langsyntaxhighlight>
 
{{out}}
<pre>
43.633231299858
</pre>
 
=={{header|XPL0}}==
<syntaxhighlight lang="xpl0">def Pi = 3.14159265358979323846;
 
func real ArcLen(Radius, Angle1, Angle2); \Length of major arc of circle
real Radius, Angle1, Angle2;
real Diff;
[Diff:= abs(Angle1 - Angle2);
Diff:= 360. - Diff;
return Pi * Radius / 180. * Diff;
];
 
RlOut(0, ArcLen(10., 10., 120.));
</syntaxhighlight>
 
{{out}}
<pre>
43.63323
</pre>
 
=={{header|zkl}}==
{{trans|Julia}}
<langsyntaxhighlight lang="zkl">fcn arcLength(radius, angle1, angle2){
(360.0 - (angle2 - angle1).abs()).toRad()*radius
}
println(arcLength(10,10,120));</langsyntaxhighlight>
{{out}}
<pre>
1,981

edits