EXERCISES FOR WEEK 4
week4-1

Write a function which accomplishes the task you just completed in the last exercise of week 3 (week3-10). That is, write a function

Point2D Tween(Point2D A, Point2D B, double t)

which takes two points as input, A and B, a real value for t, and then returns the point on the line through A and B for that particular value of t. Check your function by passing in points A and B as defined in exercise week3-10 and the values for t.

week4-2

In exercise 3-10, we end up plotting 6 points (including the two endpoints) on the line and increment between successive values for t is 0.2. In general, if you want to plot numframes points on the line segment from point A to point B, including the two endpoints, what is the value for increment that you would use?

 

week4-3

Suppose you have an array of points, S, which contains all the vertices of the figure your animation should start with, and a second array of points, D, which contains all the vertices of the figure which is the destination of your animation. Assume there are numpoints points in each array. Write a function, FillTween, which takes as input:

  • the two arrays of points
  • the value for numpoints (the number of points in each array)
  • the value for t

and returns an array of points with numpoints points in it; each point calculated using corresponding points of S and D and calling the function Tween.

week4-4

Now write a function, DrawSequence, which takes as input:

  • the array of points to start with
  • the array of points for the destination
  • the number of frames you want from start to destination, inclusive (numframes)

and does the following:

for every frame to be drawn:

clears the screen;
calculates the value for t;
uses FillTween to fill a new array of points;
draws the figure, using the array of points and whatever instructions you have for how to connect the points;
swaps the buffers;

 

week4-5

Do practice exercise 4.2.1 (a,b,c) on page 140 of the Hill book.

 

week4-6

Do practice exercise 4.3.1 on page 144 of the Hill book.

 

week4-7

Multiply the following matrices (if possible):

  • [A] * [B] where [A] = [2 1 4
                                        3 7 -2
                                        1 0 5]

and [B] = [2
                 4
                 6]

  • [B] * [A], where A and B are as given abovem,
week4-8

What is the homogeneous scaling matrix MS if you wish to make the object twice as wide as it is now?

 

week4-9

What is the homogeneous scaling matrix MS if you wish to make the object one-third as tall as it now is?