Windmill Impact Simulation

This is the final project of ME314 (Machine Dynamics). The goal is to simulate a dynamic system including one windmill and one triangle block (both with inertia) in Mathematica. The Lagrangian, Euler-Lagrangian and Hamiltonian equations are applied to derive the trajectory of the objects. To judge if an impact is going to happen, I set multiple impact conditions. When an impact happens, the Impact-Update Law is applied to update the velocity of each object and then Lagrangian and EL-Lagrangian are used again to generate the new trajectory of all the objects.