func makeFragments(radius int, self bool) (frags []fragment) { r := float32(radius) for y := -r; y <= r; y++ { for x := -r; x <= r; x++ { d := math32.Hypot(x, y) var includePoint bool if self { // Self is hollow ring includePoint = r*0.9 <= d && d <= r*1.1 } else { // Aliens are solid circles includePoint = d <= r } if includePoint { // Impart radial velocity to fragment var vx, vy, extra float32 if d > 0 { vx, vy = x/d, y/d extra = 0.4 } else { vx, vy = 0, 0 extra = 1.4 } // Random non-radial component uy, ux := math32.Sincos(rand.Float32() * (2 * math32.Pi)) frags = append(frags, fragment{ x, y, vx + ux*extra, vy + uy*extra, }) } } } return frags }
// euler returns e raised to the power iθ. func euler(θ float32) complex64 { y, x := math32.Sincos(θ) return complex(x, y) }