X Tutup
Skip to content

Seismic-wave-Han/physics_engine

Repository files navigation

Newton Physics Engine 🍎

Fall 2019 Computational Science Project (Undergraduate) @ Seoul National University A 2D rigid body physics engine developed from scratch using Python and the Qt framework (GUI).

📝 Introduction

This project was developed as a term project for the Computational Science major at SNU (Fall 2019). The primary goal was to implement a physics simulation engine without relying on external physics libraries (like Box2D), solely based on mathematical models of Newtonian mechanics.

The entire user interface was built with Python and Qt, allowing users to interactively visualize and manipulate physical properties in real-time.

  • Development Period: Sep 2019 - Dec 2019
  • Tech Stack: Python, Qt (PyQt/PySide)
  • Key Concepts: Rigid Body Dynamics, Impulse-based Collision Resolution, Numerical Integration

📺 1. Core Engine Demo

This demonstration showcases the fundamental capabilities of the engine, including gravity, restitution control, and shape interactions.

v2.mov

🎮 2. Applications & Scenarios

Below are various application scenarios built on top of the core Newton Physics Engine.

🔹 Application A: [Basketball]

default.mov

🔹 Application B: [Pocketball]

default.mov

✨ Key Features

1. Python & Qt Based Interactive UI

  • Real-time Control: Leveraging the Qt framework, the UI allows users to adjust simulation parameters (Gravity, Friction) on the fly.
  • Property Inspection: Select objects to view and modify their properties (Mass, Velocity, Size) instantly via the side panel.

2. Rigid Body Simulation

  • Collision Detection: Implements algorithms to detect overlaps between Circles and Rectangles (AABB).
  • Elasticity Control: Supports Coefficient of Restitution ($e$).
    • Demo Highlight: Adjusting $e$ from 1.0 to 0.3 (as seen in the Core Demo) simulates energy loss during inelastic collisions.

📐 Mathematical Implementation

The engine simulates physics by numerically integrating the equations of motion:

  • Integration Method: (Explicit Euler / Velocity Verlet) $$p_{t+1} = p_t + v_t \Delta t$$ $$v_{t+1} = v_t + \frac{F}{m} \Delta t$$

  • Collision Response: Uses impulse-based resolution to handle collisions. $$J = \frac{-(1+e)((v_A - v_B) \cdot n)}{n \cdot n (1/m_A + 1/m_B)}$$

About

Final project for computational science2

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

X Tutup