Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
25
Task/Averages-Mean-angle/FreeBASIC/averages-mean-angle.basic
Normal file
25
Task/Averages-Mean-angle/FreeBASIC/averages-mean-angle.basic
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
' 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
|
||||
Loading…
Add table
Add a link
Reference in a new issue