26 lines
869 B
Plaintext
26 lines
869 B
Plaintext
' FB 1.05.0 Win64
|
|
|
|
Const PI As Double = 3.1415926535897932
|
|
|
|
Function MeanAngle(angles() As Double) As Double
|
|
Dim As Integer length = Ubound(angles) - Lbound(angles) + 1
|
|
Dim As Double sinSum = 0.0
|
|
Dim As Double cosSum = 0.0
|
|
For i As Integer = LBound(angles) To UBound(angles)
|
|
sinSum += Sin(angles(i) * PI / 180.0)
|
|
cosSum += Cos(angles(i) * PI / 180.0)
|
|
Next
|
|
Return Atan2(sinSum / length, cosSum / length) * 180.0 / PI
|
|
End Function
|
|
|
|
Dim As Double angles1(1 To 2) = {350, 10}
|
|
Dim As Double angles2(1 To 4) = {90, 180, 270, 360}
|
|
Dim As Double angles3(1 To 3) = {10, 20, 30}
|
|
|
|
Print Using "Mean for angles 1 is : ####.## degrees"; MeanAngle(angles1())
|
|
Print Using "Mean for angles 2 is : ####.## degrees"; MeanAngle(angles2())
|
|
Print Using "Mean for angles 3 is : ####.## degrees"; MeanAngle(angles3())
|
|
Print
|
|
Print "Press any key to quit the program"
|
|
Sleep
|