Averages/Mean angle: Difference between revisions
m
→{{header|Phix}}: minor tidy, use builtin atan2, round to 10dp.
MaiconSoft (talk | contribs) No edit summary |
m (→{{header|Phix}}: minor tidy, use builtin atan2, round to 10dp.) |
||
Line 1,483:
=={{header|Phix}}==
Copied from [[Averages/Mean_angle#Euphoria|Euphoria]], and slightly improved
<lang Phix>function
atom ai_rad = angles[i]*PI/180▼
▲atom x=0, y=0, ai_rad
▲ for i=1 to l do
▲ ai_rad = angles[i]*PI/180
x += cos(ai_rad)
y += sin(ai_rad)
end for
if abs(x)<1e-16 then return "not meaningful" end if
return sprintf("%
end function
constant AngleLists = {{350,10},{90,180,270,360},{10,20,30},{180},{0,180}}
for i=1 to length(AngleLists) do
sequence ai = AngleLists[i]
printf(1,"%
end for</lang>
{{out}}
<pre>
{350,10}: Mean Angle is
{90,180,270,360}: Mean Angle is not meaningful
{10,20,30}: Mean Angle is
{180}: Mean Angle is 180
{0,180}: Mean Angle is not meaningful
</pre>
|