Introduction to Computer Graphics
1999 Autumn Quarter


Animator - Help Session Notes


Getting familiar

The animator project is basically an extended version of the modeler project you worked on for project 2. There are a few new extensions that are worth paying attention to:


Monotonic Curves

The handout specifies that time needs to be monotonically increasing, therefore your curves should never move in the negative x-direction. After you get them working, you will notice that some of the curves will actually create loops or move backwards for a short period of time when points are placed too close together. You will need to find a way to ensure that this never happens.

STL Tips
Most of the code that you will be dealing with uses vector template. The easiest thing to think about this vector is that it is like an array without limited size and with special methods to make your life easier.

The following methods are the most common methods that you will use to implement each curve type:

clear -- is used to clear all the content of the vector. This function does not take any input parameter.
resize -- is used to resize the vector into a certain size. It take one parameter with type integer.
push_back -- is used to insert an object (in this project, this will be a Point object) into the vector. This method only take one parameter.
size -- to get the current size of the vector. This method does not have any parameter.

How To... in STL

How to loop through the vector
There are a couple of ways to make a loop using STl. The first one is to take the current size of the curve and then use it to index the vector. The second one is to use STL's iter.

Example
Suppose that I have a vector of Point named foo.

int size = foo.size();
for (int i = 0; i < size; i++)
{ cout << foo[i].x << " " << foo[i].y << endl; }

OR...

for (vector<Point>::iter i = foo.begin(); i < foo.end(); i++)
{ cout << i->x << " " << i->y << endl; }
Note: there is only a single less than and greater than signs needed right and after Point. I don't know how to display them correctly in HTML.

How to clear a vector
Just call clear method to erase all the content, i.e, foo.clear();

How to access a vector
Acessing a vector is the same as accessing the array. You should put the squared brackets. For exmple, you should have the similar code as following: foo[2]; to access the third element of the vector. Remember that the vector is zero-based.

How to insert a new object into a vector
You should call push_back function to insert an object into a vector.
Suppose that you want to inser a point (3, 5) into a vector foo.
Your code will be like the following:
foo.pus_back(Point(3, 4));