Data update
This commit is contained in:
parent
35bcdeebf8
commit
74c69a0df6
2427 changed files with 31826 additions and 3468 deletions
22
Task/Averages-Mean-angle/MiniScript/averages-mean-angle.mini
Normal file
22
Task/Averages-Mean-angle/MiniScript/averages-mean-angle.mini
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
atan2 = function(y, x)
|
||||
return 2 * atan((sqrt(x^2 + y^2) - x) / y)
|
||||
end function
|
||||
|
||||
deg2rad = function(x); return x * pi / 180; end function
|
||||
rad2deg = function(x); return x * 180 / pi; end function
|
||||
|
||||
meanAngle = function(angles)
|
||||
xsum = 0; ysum = 0
|
||||
for angle in angles
|
||||
xsum += cos(deg2rad(angle))
|
||||
ysum += sin(deg2rad(angle))
|
||||
end for
|
||||
return rad2deg(atan2(ysum / angles.len, xsum / angles.len))
|
||||
end function
|
||||
|
||||
manyAngledOnes = [[350, 10], [90, 180, 270, 360], [10, 20, 30]]
|
||||
|
||||
for angles in manyAngledOnes
|
||||
mean = meanAngle(angles)
|
||||
print ["Mean of", angles, "is", mean].join(" ")
|
||||
end for
|
||||
Loading…
Add table
Add a link
Reference in a new issue