4 point mass system impact simulation in Python with SymPy
Vertices of the bot were represented as {A}, {B}, {C}, and {D} while its edges were denoted as {1}, {2}, {3}, and {4}. Four point masses of the jack were shown as {a}, {b}, {c}, and {d} while the World frame is shown as {W}.
Both the box and jack are free to translate and rotate in an xy-plane.
External force was applied assuming someone is shaking the box.
To ensure that the jack hit all four edges of the box, the external force was applied in the x-direction while gravity acted in the y-direction, causing the jack to contact the box boundaries.
The jack has the constraint that it has to stay within the boundaries of the box.
Phi defines when the point masses of the jack make contact with the boundaries of the box, which are {1}, {2}, {3}, and {4}. This system contains multiple constraint functions stored in phi_list, and they are called in a for-loop so that it eliminates the need to make multiple impact update functions.
Phi can be expressed with the g matrix, while g_ij [3] represents the x-component and g_ij [7] the y-component.
Function impact_condition takes phi_list and initial conditions, which include initial positions and velocities, lambdifies phi values, and tolerance to decide the impact condition.
Function impact_update takes initial conditions and impact equations to numerically update impacts.