Project 1: Particle system

 

Due: Sep 11, 2014, 12PM


You will implement a particle simulator to simulate two physical phenomena: (1) Galileo’s experiment, (2) a tinkertoy.


Requirements

You will generate two applications in C++ to demonstrate the following two physical phenomena. Your particle system must contain 3D particles and forces required in each task.

  1. 1.Galileo’s experiment: Involving three particles, gravitational force, and two integration methods.

  2. 2.Tinkerkoy: Involving one particle, constraint force, gravitational force, and one integration method.


Galileo’s experiment

You are standing at the top of the Leaning Toward of Pisa. Just like Galileo, you are trying to convince people that your numerical integrator is accurate, by dropping two balls from the tower. One ball follows the analytical equation of free-fall motion while the other one is simulated by your particle system. Your goal is to show that they reach the ground at the same time.


You will implement two numerical integration methods and show that one of them yields the same motion as the analytical solution, while the other one does not.


In your executable, show three particles side-by-side falling from 20 meters to the ground. Drop the particles at the same time with zero initial velocity. Render the particle that follows the analytical solution red and the other two blue.




Tinkertoy

Simulate a bead on a circular wire under gravitational force. You will implement a constraint of the form C(px, py) = 0 that keeps the bead on the circle. Your program should draw the particle as it moves, as well as drawing the circle the particle is supposed to stay on. The motion of the particle should be affected by gravity.


The constraint you need to implement can be represented as: C(px, py) = px2 + py2 - d2, where d is the radius of the circle C. The constraint becomes singular at the origin (the derivatives go away). You should initialize the particle at a position that satisfies constraint C.

If you are interested in building a tinkertoy with multiple constraints and particles, you should implement the constraint in the general form. Rather than hard-coding the whole system, you will build the constraint matrix on the fly by allowing each constraint to make its own contribution to the global Jacobian matrix and its time derivative matrix. If you just want to simulate one particle on the circle, you only need to implement a single implicit constraint.


In order to build the global matrices and vectors, the constraints need to know where to put their derivatives. This can be done by pointers, or a simple matter of indexing by number all your constraints and the particles. The index of the i-th constraint is just i (assuming all the constraints are scalar functions), and the indices of j-th particle are 3j through 3j+2, for the x, y, and z components respectively. The derivative of constraint Ci with respect to the y component of particle pj goes into element (i, 3j+1) of the Jacobian matrix.


Skeleton code

The skeleton code is built using DART libraries. DART is a powerful toolkit which provides physics simulation and many other capabilities. For this project, however, you will only need to use a small set of functionalities of DART, namely, basic UI and vector computation. You will implement your own integrators and differential equations for the particle system, instead of using those provided by DART. 


Step 1: Install and build DART: CS7496 branch.

  1. Go to https://github.com and sign up for an account (it’s free!).

  2. Go to https://github.com/dartsim/dart and

  3. Click on “Wiki” in the right column.

  4. Click on “Git Setup” and follow the instructions to install git.

  5. Continue to follow the instructions to download DART, but modify the clone command line     with the CS7496 branch:

  6. git clone -b CS7496 git@github.com:dartsim/dart.git

  7. or

  8. git clone -b CS7496 https://<username>@github.com/dartsim/dart.git

  9. Go back to the Wiki page and click on “Window Installation”, “Linux Installation”, or “Mac Installation”. Follow the instructions to install DART. Note that you do not need to install GRIP for this project.


Step 2: Run the skeleton code.

Once you install and build DART, run the following apps under bin/

bin/Galileo

bin/tinkertoy

As you can see, the skeleton code currently is only moving particles linearly instead of simulating them based on physics.


Step 3: Understand the skeleton code.

The source code of these apps are under apps/

apps/Galileo/

apps/tinkertoy/

That’s where you will develop your code to complete this project. The skeleton code provides a viewing window and some incomplete UI functionality, but they are a good starting point. Before you start coding, you need to understand the organization of these two apps. They all share the same classes: MyWorld, MyWindow, and Particle, but the implementation of these classes is slightly different due to different tasks. Start out with apps/Galileo. Once you fully understand the code, the other app is pretty similar.


Step 4: Extend skeleton code to complete the tasks.

You need to implement a complete particle system and required integrators. Your simulation should replace the dummy code in MyWorld::simulate(). You can also add more functions and data members to the existing classes or create new classes. Although the requirements of each task are different, many of the components you implement can probably be reused.


Extra points

  1. 1.Implement additional types of constraints for the tinkertoy. If the constraint outputs more than a single scalar, you need to modify the indexing scheme for the global matrices and vectors so that the constraint evaluations and derivatives are stored in the correct places. Each extra constraint is worth one present.

  2. 2.To make your tinkertoy simulation interactive, implement a mouse-spring as follows: each time the mouse button and the shift key are pressed at the same time, find the particle closest to the mouse at that moment. Apply an attractive spring force (damped, with zero rest-length) between that particle and the mouse until the button is released. Let the “mouse force” Fm be computed by Fm = km (Mx - px, My - py) with km > 0. In order for your simulation not to get out of control, you will want to add a damping force Fd of the form Fd = -kd v where kd > 0, so that the total force F is F = Fm + Fd. You should also be able to turn gravity forces on/off in your system.


Demo

Download demo for “Tinkertoy”