Skip to content

Vasundhara-331/Deterministic-Physics-Simulation

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 

Repository files navigation

Deterministic Physics Simulation - Image Reveal

This project implements a deterministic 2D physics simulation where multiple balls move, collide, and bounce off boundaries, eventually revealing an uploaded image as their colors map to the pixels of the image.


Features

  • Deterministic Physics Engine: Uses Verlet integration for accurate motion simulation.
  • Gravity & Collisions: Balls are affected by gravity, bounce off walls, and collide with each other.
  • Image Reveal: Balls take colors from an uploaded image, forming a near pixel-perfect representation over time.
  • Optimized Collision Handling: Uses spatial hashing to reduce computational overhead for collisions.
  • CSV-based Ball Tracking: Ball positions and states are recorded in ball_spawns.csv for deterministic replay.
  • Customizable Parameters: Easily adjust gravity, ball radius, spawn rate, number of objects, and simulation steps.
  • Fast Calculation Phase: Precomputes ball positions for smooth real-time display.

Requirements

  • Python 3.10+
  • Pygame
  • Pillow (PIL)
  • Tkinter (for image file selection, usually included with Python)

Install required packages: pip install pygame pillow

How to run? Open Command Prompt or Windows Powershell and install the required dependencies. Then run python bouncing_balls.py to see the magic in action.

Note: View the created final image from afar for best results

About

Deterministic Physics Simulation - Image Reveal

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages