Skip to content

Jan-Malinowski/collision-simulator

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

5 Commits
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

โš™๏ธ 1D & 2D Collision Simulation

Language: Python
Library: Pygame


๐Ÿ“– Overview

This project simulates elastic collisions between two objects of different masses.

  • Current version: 1D collisions between two squares moving along a single axis.
  • In progress: 2D collisions between circles with velocity components in both X and Y directions.

๐Ÿง  Physics Principles

  • Conservation of Momentum
    The total momentum before and after the collision remains constant.

  • Conservation of Kinetic Energy (elastic collisions)
    The total kinetic energy is preserved during the collision.

  • Collision Detection

    • 1D: Triggered when the edges of the squares meet.
    • 2D (planned): Triggered when the distance between two circle centers is less than or equal to the sum of their radii.
  • Velocity Update Formulas

    • 1D: Uses standard elastic collision equations for two masses along a line.
    • 2D (planned): Uses vector-based formulas to separate velocity into normal and tangent components, updating only the normal component after collision.

โœจ Features

  • Real-time simulation with Pygameโ€™s rendering loop.
  • Adjustable masses and initial velocities.
  • Smooth, visually clear animation of motion and collisions.

๐Ÿš€ Planned Improvements

  • Implementation of 2D elastic collisions for circles.
  • Optional inelastic collision mode with adjustable restitution coefficient.
  • Additional visual effects and statistics display.

๐Ÿ“บ Previev

prev

prev

About

A Python program built with Pygame that simulates 1D elastic collisions between two squares of different masses. It calculates updated velocities after each collision using physics equations, and visually displays the motion along a single axis in real time.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages