Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
33
Task/Averages-Mean-angle/NetRexx/averages-mean-angle.netrexx
Normal file
33
Task/Averages-Mean-angle/NetRexx/averages-mean-angle.netrexx
Normal file
|
|
@ -0,0 +1,33 @@
|
|||
/* 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
|
||||
Loading…
Add table
Add a link
Reference in a new issue