You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

33 lines
670 B
Go

package main
import (
"fmt"
"math"
)
func main() {
const n = 12
a := 1400.0
b := 4200.0
theta0 := 0.38
dtheta := 0.52
pts := make([]struct{ x, y, r float64 }, n)
for i := 0; i < n; i++ {
th := theta0 + float64(i)*dtheta
r := a + b*th
pts[i].x = r * math.Cos(th)
pts[i].y = r * math.Sin(th)
pts[i].r = r
fmt.Printf("%d: %d, %d (r=%.0f)\n", i, int(math.Round(pts[i].x)), int(math.Round(pts[i].y)), r)
}
fmt.Println("--- distances ---")
var sum float64
for i := 0; i < n; i++ {
j := (i + 1) % n
d := math.Hypot(pts[j].x-pts[i].x, pts[j].y-pts[i].y)
sum += d
fmt.Printf("%d->%d: %.0f\n", i, j, d)
}
fmt.Println("avg:", sum/float64(n))
}