Class CollisionSystem

  • public class CollisionSystem
    extends Object
    The CollisionSystem class represents a collection of particles moving in the unit box, according to the laws of elastic collision. This event-based simulation relies on a priority queue.

    For additional documentation, see Section 6.1 of Algorithms, 4th Edition by Robert Sedgewick and Kevin Wayne.

    Robert Sedgewick, Kevin Wayne
    • Constructor Detail

      • CollisionSystem

        public CollisionSystem​(Particle[] particles)
        Initializes a system with the specified collection of particles. The individual particles will be mutated during the simulation.
        particles - the array of particles
    • Method Detail

      • simulate

        public void simulate​(double limit)
        Simulates the system of particles for the specified amount of time.
        limit - the amount of time
      • main

        public static void main​(String[] args)
        Unit tests the CollisionSystem data type. Reads in the particle collision system from a standard input (or generates N random particles if a command-line integer is specified); simulates the system.
        args - the command-line arguments