Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
22
Task/Averages-Mean-angle/XPL0/averages-mean-angle.xpl0
Normal file
22
Task/Averages-Mean-angle/XPL0/averages-mean-angle.xpl0
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
include c:\cxpl\codes;
|
||||
|
||||
def Pi = 3.14159265358979323846;
|
||||
def D2R = Pi/180.0; \coefficient to convert degrees to radians
|
||||
|
||||
func real MeanAng(A); \Return the mean of the given list of angles
|
||||
int A;
|
||||
real X, Y;
|
||||
int I;
|
||||
[X:= 0.0; Y:= 0.0;
|
||||
for I:= 1 to A(0) do
|
||||
[X:= X + Cos(D2R*float(A(I)));
|
||||
Y:= Y + Sin(D2R*float(A(I)));
|
||||
];
|
||||
return ATan2(Y,X)/D2R;
|
||||
];
|
||||
|
||||
[Format(5, 15);
|
||||
RlOut(0, MeanAng([2, 350, 10])); CrLf(0);
|
||||
RlOut(0, MeanAng([4, 90, 180, 270, 360])); CrLf(0);
|
||||
RlOut(0, MeanAng([3, 10, 20, 30])); CrLf(0);
|
||||
]
|
||||
Loading…
Add table
Add a link
Reference in a new issue