Skip to content

A simulator that can simulate a set of particles moving in a square units and the collision between them following the law of physics about elastic collision.

License

Notifications You must be signed in to change notification settings

KhoaNam225/Collision_Simulator

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Particles Collision Simulator

MIT license

A system that can simulate the collision between many small particles following the law of physics about elastic collision.

logo

Motivation

This project was created in order to help me learn more about the use of PriorityQueue data structure as well as Java Swing library to build GUI application.

Using event-driven programming, the system was constructed base on the events that can happen during the simulation. The order of the event will base on the time that the event occur.

In order to get the earliest (smallest) event that will happen next, we use the PriorityQueue to achieve O(logN) performance.

Framework used

This project was built with:

  • Java Swing: used to build a class dedicated to draw different shapes as well as handle animation on the canvas.

Installation

Everything you need is to install Java 11 (or above) to run the system.

How to use (on Linux)

1. Compile the source code

To compile the code, make sure you are in the directory that contains all the source code and then simply type the following command to the terminal:

~$ javac *.java

2. Run the class file

After compiling the code, all you need to do is to run the generated Simulator class file. This can be done by using the following command:

~$ java Simulator  <number_of_particles>  <simulation_time_limit>

You will need to give the program 2 arguments. The first argument will be the number of particles involving in the simulation, depends on your hardward resource this could vary from 10 to 50 (or above). The second argument will be the time limit for the simulation, after this period of time is exceeded, the simulation will stop.

3. Screenshot

This is how the simulation will look like:

logo

License

MIT © KhoaNam225

About

A simulator that can simulate a set of particles moving in a square units and the collision between them following the law of physics about elastic collision.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages