Length of an arc between two angles: Difference between revisions

Added Easylang
(add RPL)
(Added Easylang)
 
(6 intermediate revisions by 3 users not shown)
Line 141:
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}}==
Line 304 ⟶ 326:
<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>
 
Line 716 ⟶ 751:
=={{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
Line 753 ⟶ 788:
=={{header|Wren}}==
{{trans|Julia}}
<syntaxhighlight lang="ecmascriptwren">var arcLength = Fn.new { |r, angle1, angle2| (360 - (angle2 - angle1).abs) * Num.pi / 180 * r }
 
System.print(arcLength.call(10, 10, 120))</syntaxhighlight>
1,981

edits