Length of an arc between two angles: Difference between revisions
Content added Content deleted
No edit summary |
(Added Algol W) |
||
Line 9: | Line 9: | ||
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. |
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|ALGOL W}}== |
|||
Follows the Fortran interpretation of the task and finds the length of the major arc. |
|||
<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.</lang> |
|||
{{out}} |
|||
<pre> |
|||
43.6332 |
|||
</pre> |
|||
=={{header|AWK}}== |
=={{header|AWK}}== |