2D Impact Dynamics
Project
The aim of this exercise was to simulate dynamic impacts in a 2D environment using only calculus. This interactive simulation involves two objects, a box and a toy jack bouncing around inside. There are external forces acting on the cup to represent shaking while nothing affects the jack except for its own motion and the impacts with the walls. To play the simulation at normal speed, Pause it and then click Play.
Method
The simulation begins by computing the Euler-Lagrange equation for two objects falling in gravity to represent the system. One object, the cup, has an external force applied to shake it as well as to keep it from falling. From here the conditions for which an impact can occur are calculated and stored for later (when any corner of the jack collides with any side of the box). These, along with the hamiltonian of the system is what is required for computing the new trajectory after impacts during simulation.
Once all the data is assembled, the simulation begins to step forward through time using a 4th order Runge-Kutta integration method. At every point in time, the impact conditions are evaluated to determine if an impact has occurred. If it has, the post-impact trajectories for both items are calculated using the appropriate impact equations from before as well as the hamiltonian. With the trajectories updated, the simulation continues.