15 lines
483 B
Text
15 lines
483 B
Text
with javascript_semantics
|
|
function MeanAngle(sequence angles)
|
|
atom x = 0, y = 0
|
|
for a in sq_mul(angles,PI/180) do
|
|
x += cos(a)
|
|
y += sin(a)
|
|
end for
|
|
if abs(x)<1e-15 then return "not meaningful" end if
|
|
return sprintf("%g",round(atan2(y,x)*180/PI,1e10))
|
|
end function
|
|
|
|
for a in {{350,10},{90,180,270,360},{10,20,30},{180},{0,180},
|
|
{90,270},{45,225},{10,190},{1,91,181,271}} do
|
|
printf(1,"%16V: Mean Angle is %s\n",{a,MeanAngle(a)})
|
|
end for
|