Just another update
This commit is contained in:
parent
a25938f123
commit
00a190b0a6
6591 changed files with 94363 additions and 23227 deletions
|
|
@ -1,22 +1,28 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"math"
|
||||
"math/cmplx"
|
||||
"fmt"
|
||||
"math"
|
||||
"math/cmplx"
|
||||
)
|
||||
|
||||
func deg2rad(d float64) float64 { return d * math.Pi / 180 }
|
||||
func rad2deg(r float64) float64 { return r * 180 / math.Pi }
|
||||
|
||||
func mean_angle(deg []float64) float64 {
|
||||
sum := 0i
|
||||
for _, x := range deg { sum += cmplx.Rect(1, deg2rad(x)) }
|
||||
return rad2deg(cmplx.Phase(sum))
|
||||
sum := 0i
|
||||
for _, x := range deg {
|
||||
sum += cmplx.Rect(1, deg2rad(x))
|
||||
}
|
||||
return rad2deg(cmplx.Phase(sum))
|
||||
}
|
||||
|
||||
func main() {
|
||||
for _, angles := range [][]float64 {{350, 10}, {90, 180, 270, 360}, {10, 20, 30}} {
|
||||
fmt.Printf("The mean angle of %v is: %f degrees\n", angles, mean_angle(angles))
|
||||
}
|
||||
for _, angles := range [][]float64{
|
||||
{350, 10},
|
||||
{90, 180, 270, 360},
|
||||
{10, 20, 30},
|
||||
} {
|
||||
fmt.Printf("The mean angle of %v is: %f degrees\n", angles, mean_angle(angles))
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,9 +1,9 @@
|
|||
func mean_angle(deg []float64) float64 {
|
||||
var ss, sc float64
|
||||
for _, x := range deg {
|
||||
s, c := math.Sincos(x * math.Pi / 180)
|
||||
ss += s
|
||||
sc += c
|
||||
}
|
||||
return math.Atan2(ss, sc) * 180 / math.Pi
|
||||
var ss, sc float64
|
||||
for _, x := range deg {
|
||||
s, c := math.Sincos(x * math.Pi / 180)
|
||||
ss += s
|
||||
sc += c
|
||||
}
|
||||
return math.Atan2(ss, sc) * 180 / math.Pi
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue