Bouncing Balls II
An update to a previous block, but with collision detection and Canvas. This block uses Geometric.js for geometric calculations.
- When circles collide, they simply swap angles and speeds. This gets the job done, but it does not let circles glance off of each other. I need a more realistic method of transferring energy when they collide.
- The algorithm runs in quadratic time — on each tick, the position of every circle is compared with the position of every other circle. By using a more efficient data structure, such as a quadtree, I believe you could get this humming in logarithmic time.
- Canvas is fast, but WebGL is faster.