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.
34 lines
670 B
Go
34 lines
670 B
Go
//go:build ignore
|
|
|
|
package main
|
|
|
|
import (
|
|
"fmt"
|
|
"math"
|
|
)
|
|
|
|
func main() {
|
|
const n = 12
|
|
a := 900.0
|
|
b := 2600.0
|
|
theta0 := 0.42
|
|
dtheta := 0.58
|
|
pts := make([]struct{ x, y 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)
|
|
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))
|
|
}
|