 (def particle-diameter (* 2 particle-radius))
 (def particle-count 10)
 (def gravitational-constant 200)
-(def speed-limit 5)
 (def initial-speed 0)
+(def bounciness 0.4)
 
 (def scene-width window/innerWidth)
 (def scene-height window/innerHeight)
 
 (def particles (atom []))
 (def particle-meshes (atom []))
-(def collided-particles (atom {}))
 
 (def nullv [0 0 0])
 

  [p v all]
  (let [a (calc-accel p all)
        v (map + v a)

        ;; added a speed limit here because gavitational sigularities were
        ;; causing particles to become superaccelerated, which is kind of cool
        ;; but generally doesn't make for a good simulation. This is needed only
        ;; when there's no collision detection.
        speed (magnitude v)
        v (if (> speed speed-limit)
            (direction v speed-limit)
            v)

        p (map + p v)]
    [p v a]))


  [v]
  (Math/sqrt (apply + (map #(* % %) v))))

(defn scale
  [v s]
  (map #(* % s) v))

(defn direction
  "Given a vector, returns a unit vector in the same direction, optionally
scaled."
