22 lines
543 B
Text
22 lines
543 B
Text
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);
|
|
]
|