33 lines
1 KiB
Text
33 lines
1 KiB
Text
/* NetRexx */
|
|
options replace format comments java crossref symbols nobinary
|
|
numeric digits 80
|
|
|
|
runSample(arg)
|
|
return
|
|
|
|
-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
method getMeanAngle(angles) private static binary
|
|
x_component = double 0.0
|
|
y_component = double 0.0
|
|
aK = int angles.words()
|
|
loop a_ = 1 to aK
|
|
angle_d = double angles.word(a_)
|
|
angle_r = double Math.toRadians(angle_d)
|
|
x_component = x_component + Math.cos(angle_r)
|
|
y_component = y_component + Math.sin(angle_r)
|
|
end a_
|
|
x_component = x_component / aK
|
|
y_component = y_component / aK
|
|
avg_r = Math.atan2(y_component, x_component)
|
|
avg_d = Math.toDegrees(avg_r)
|
|
return avg_d
|
|
|
|
-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
method runSample(arg) private static
|
|
angleSet = [ '350 10', '90 180 270 360', '10 20 30', '370', '180' ]
|
|
loop angles over angleSet
|
|
say 'The mean angle of' angles.space(1, ',') 'is:'
|
|
say ' 'getMeanAngle(angles).format(6, 6)
|
|
say
|
|
end angles
|
|
return
|