This is a course project to simulate in 2D, a box in a box and collision with each others.
-
Dynamic simulation
- Object have weight and inertia
- Additional external force applied to one of the object
- Have gravity
-
Collision updates with 20 collision pairs
- All corners and edges between boxes are considered (16 collision pairs)
- outer box has collision with ground as well
-
Visualization and animation with plotly
Video showing everything working:
clame-rainbow.mp4
Due to the large amount of computation from symbolic math, jupyter notebook is used to allow rework and debug with sections of codes.
The generate steps are:
- Define the dynamic system in symbolic math (Euler lagrange)
- Create the symbolic impact equations (but not solving it) systematically for each pair.
- Create impact update lambda and impact checking lambda
- Combined dynamic equations and impact update into the same simulation function, and conditionally call impact update during the simulation.
- Use the simulated output to generate plots and animations.
The impact systems only handle 1-to-1 impact pairs between edge and vertex, simulations impacts are not handled (multiple vertex hitting edges at the same time-step).
Here is another video showing it failed to handle simultaneous impact
Working-but-hit.into.ground.mp4
The system is only in 2d. But there should be very little work to expand it into 3d.
All code in the repo are jupyter notebooks.
The project code is in Project/Project.ipynb
There are also lots of homework files in other folder.