Skip to content

rutvi1998/physics-simulation

 
 

Repository files navigation

forthebadge made-with-python

KWoC 2018

  This is a simple physics engine module made using pygame in python.

It is based on some physics phenomenon and mathematical expressions which defines movement after the collision between particles, the gravitational force on particles and spring function to make a chain of particles to work them as spring. for example three particles together will act as a triangle.

Pygame requires Python; if you don't already have it, you can download it from python.org. Use python 3.6.1 or greater, because it is much friendlier to newbies, and additionally runs faster.

The best way to install pygame is with the pip tool (which is what python uses to install packages). Note, this comes with python in recent versions. We use the --user flag to tell it to install into the home directory, rather than globally.

  • python3 -m pip install -U pygame --user

To see if it works, run one of the included examples:

  • python3 -m pygame.examples.aliens
  • python3 -m pygame.examples.universe

If it works, you are ready to go!

To use this module in your file download it in the folder where you are working and import PyParticle.py in your file.

other files are examples of using PyParticle, one just needs to place pyparticle.py in current folder/directory. No need to download other files

Below all examples are created using PyParticle module which enables to write less number of lines code.

Some of the main features of this it defines the movement of particles in space and provides the ability to zoom-in and zoom-out

space particle

This programme shows the effect on the speed of particles after collision depending on their mass

space particle

Below image shows the spring function in action

space particle

To use this module in your file download it in the folder where you are working and import PyParticle in your file** You can call its function by passing arguments using the name of the function

         **Referred to example programs to see how to call the function in PyParticle module**

Licensed under MIT License.

About

No description, website, or topics provided.

Resources

License

Code of conduct

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Python 100.0%