← Back to Portfolio

Physics Simulation – Lagrangian Impacts (Jack-in-Box)

Skills: Python, Lagrangian Mechanics, SymPy, Mechanical Simulation, Numerical Integration, Impacts, Coordinate Transformations, Physics Animation

GitHub Repo

Project Overview

For this MECH_ENG 314 capstone, I modeled the dynamics of a jack-in-a-box in 2D, applying advanced Lagrangian mechanics and computational methods to capture both free motion and impacts. This project combines analytical physics, rigorous coding, and visualization—a full pipeline from equations to simulation.

System Modeling and Setup

Euler-Lagrange Equations & Solution

External Forces

Heavyside visualization
Visualization of the Heaviside function which shakes the box

Impact Events & Update Laws

Impact Update Laws
Configuraiton right before impact, where reference frames will cross one another and trigger a response

Simulation & Results

Reflections

This project challenged me to combine symbolic math, mechanical insight, and robust numerical methods. Coding these mechanics from the ground up, I deepened my understanding of Lagrangian analysis and impact mechanics, and demonstrated a full workflow from equations to animation.