Simulating Rigid Body Dynamics Using Mass-Spring Systems.

[download the project executable]

Project Description:

Simulating rigid body dynamics traditionally requires knowledge of many different facets of physics and mathematics. In such a simulation we must define the state of the body at any given instance of the simulation. In order to accomplish this we must calculate the following data:

Flexible body dynamics calculate position, velocity, acceleration, and force using particles, mass-springs, and a numerical integrator (this project uses 4th order Runge-Kutta), to run the simulation. This requires much less background of physics and mathematics. This is the idea of Dr. John McDonald's paper “On Flexible Body Approximations of Rigid Body Dynamics.” This project attempts to construct the ideas proposed in this paper. Specifically, this project simulates the dynamics of a toy top rotating, slowly loosing momentum, interacting with boundaries in space, and eventually toppling over on its side.

The motion of the top that we are trying to simulate is described by www.wikipeida.com as: “Typically the top will at first wobble until the shape of the tip and its interaction with the surface force it upright. After spinning upright for an extended period, the angular momentum, and therefore the gyroscopic effect, will gradually lessen, leading to ever increasing precession, finally causing the top to topple in a frequently violent last thrash.”


The top is constructed using only particles and mass-springs in the following manner:

Let T = a conical top
Let Mt = the mass of T = 100.0
Let p[14] = an array of particles
Let s[37] = an array of springs

Position the particles as follows: Mass of the particles: Position the springs: Set the spring stiffness: Setup initial conditions:












Now that the top is set in motion we add collision detection to the simulation. Collision detection adds friction on the floor’s surface and contains the top within defined boundaries. Collision detection is integrated to the project via the collision class which inherits from force. In the Collision::CalculateForce function we calculate the repulsion force of the floor and wall surfaces, and then calculate the friction force of the floor.

The formula to calculate the repulsion force is Fs = k(H-z). Where k is the strenth of the repulsion, H is the height of the spring that is pushing the force away from the surface (H is also the equilibrium length of the spring), and z is the length of the compressed spring due to collision.

The formula used to calculate the friction force is Ff = -(v-dot(v,n)*n)*sigma. Where n is the surface normal, v is the velocity, and sigma is the friction constant.

The data needed for the collision class included: particle p0 and p1, spring spr, vector normal, double sigma, LinkedList *particles. Through experimentation of tweaking the numerical values of this data and witnessing the effects on motion, I’ve determined to following to hold true in this simulation.

A higher friction constant (sigma), resulted in less sliding and bouncing motion on the surfaces. In the repulsion spring, a higher friction coefficient (fricCoef), resulted in the object gripping the surface more tightly, and higher spring stiffness value (k), resulted in less bounce in the collision.

Overall, constructing the basic simulation was easier than originally anticipated. The physical movement of the top appears very realistic, especially the rotational movement. The only portion of the simulation where movement needs some additional adjustment is the last thrash when the top topples over. However, this can probably be tweaked a little more in the numerical setup of the simulation.

Future enhancements would include tweaking the numerical setup a bit. Adding the simulation the renderGL where we can incorporate the physical movement into additional scenes with more advanced texturing and lighting. I especially want to take time and add soft-edged shadows to the scene (my project from GPH595). Once in renderGL, constructing a scene with multiple top’s and several additional objects to collide with would be a very interesting exercise.


The following is a list of code modifications and respective locations in the application. This project was created in the particles system framework provided in class for homework three.
  1. Application.cpp
    • Modified the SetupControls function to create the interface for the top application.
    • Added event handler function ApplyParametersButtonPressed.
    • Modified SetupSimulation function to setup all initial values for the particles and springs.
    • Added ResetSimulation function to reset simulation parameter to default state.
  2. Collision.cpp and Collision.h
    • This class inherits from Force.
    • Implementation of CalculateForce functions for friction and repulsion.
    • Data members for this class include: two particles, spring, a normal vector, friction constant sigma, and a linked list of particles.
  3. Matrix.cpp and Matrix.h
    • For matrix operations.
  4. Simulation.cpp
    • Added my implementation of 4th order Runge-Kutta.

[top of page]