Initial data commit

This commit is contained in:
Ingy döt Net 2023-07-01 11:58:00 -04:00
parent 72d218235f
commit f23f22d71c
199087 changed files with 3378941 additions and 0 deletions

View file

@ -0,0 +1,28 @@
package main
import (
"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))
}
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))
}
}

View file

@ -0,0 +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
}