Dana Vrajitoru
B582 Image Synthesis

B582 Lab 1

Date: September 22.

Ex. 1. In this first exercise, you will see a demo for an application that simulates a canon throwing a ball at a given angle with a given speed and a second one that simulates a gravitational pendulum where the ball moves at constant speed (unrealistic).

Download the dvlab.tar.gz. Save it in a location of your choice and decompress it. You should see a new directory named DVlab.

a. Open an terminal and set the following environment variable

setenv DV /home/danav/DataViewer 

If you use bash, use the following command instead:

DV=/home/danav/DataViewer ; export DV 

b. Compile the application with

make

c. For the canon demo, run the application with the command

runme_canon.sh 

From the File menu, choose User. In the typein dialog, you should enter first an angle in degrees as the starting angle for the canon ball (like 60), and then an initial speed in m/s (for example, 15). Click Draw.

You may want to zoom out of the scene to see the animation properly. For this, use the Ctrl-PageUp as many times as necessary. You can also use the arrow keys to rotate the scene to see the animation in perspective. Also use the right mouse button to translate the object around the scene.

To find more about the interaction with the DataViewer application, see the following documentation page:
http://lcvmwww.epfl.ch/DV/documentation/user_guide/user_guide-3.html

To see the animation for this application, from the Animate menu, select Animation Window... Click on the play button to launch the entire animation, then on the review button to go back to the begining, and the the Next button repeatedly to see what happens step by step.

Redraw the scene with different angle and speed to see the effect.

d.Run the pendulum application with the command
>

runme_pendulum.sh>

The functionality of this program is pretty much the same as the one before. In the User dialog, enter the initial angle and click Draw. You may want to zoom out and rotate the scene a little bit for an optimal view. Then from the Animation Window, play the animation just as before.

Ex. 2. Read the code for both programs (from the src folder, the files named canon.h/canon.cc and pendulum.h/pendulum.cc) and try to understand how they work from the code/comments.

a. By looking at the canon.cc file, try to figure out how to add color to an object in DataViewer, then use it to add some colors to the pendulum program (your choice of what should be colorized and how).

b. Modify the animation of the pendulum to make it more realistic. For this, compute the angle, speed (which in this case is an angular speed), and acceleration iteratively, meaning that the angle, speed, and acceleration of i+1 should be computed based on the angle, speed, and acceleration of i. The formulas to be used are

acceleration[i] = g * sin(angle[i]);
speed[i+1] = speed[i] + acceleration[i]*dt
angle[i+1] = angle[i] + speed[i] * dt + 0.5 * acceleration[i] * dt * dt

Note that the angle has to be in radians for the sine function call.

Turn in: the modified pendulum.cc file by email. If you modify the header file, send it in too.


Last updated: September 22, 2003.
danav@cs.iusb.edu.