Homework 8, due Monday, Nov 24.

Splines:

In class I talked about parametric cubic splines, and briefly mentioned parametric bicubic surface patches. What I would like you to do for this assignment is to implement an interactive Java applet that allows the user to drag around control points to modify a picture that's been created out of Bezier splines. Your program should behave as follows:

Helpful notes:

As we covered in class, the way you define a Bezier curve from four control points A,B,C,D is to treat the set of x coordinates {Ax, Bx, Cx, Dx} and the set of y coordinates {Ay, By, Cy, Dy} independently.

As I said in class, for every type of spline there is a unique matrix that transforms the control point values to the (a,b,c,d) values of the cubic polynomial at3+bt2+ct+d.

For Bezier curves, the particular matrix to use is:

-1 3-31
3-6 30
-3 3 00
1 0 00

To get the cubic polynomial equation for the x coordinates and y coordinates, respectively, you need to use this matrix to transform the two geometry column vectors:

Ax
Bx
Cx
Dx
Ay
By
Cy
Dy
into the two column vectors of cubic coefficients:
ax
bx
cx
dx
ay
by
cy
dy

which will let you evaluate the cubic polynomials:

X(t) = axt3 + bxt2 + cxt + dx
Y(t) = ayt3 + byt2 + cyt + dy

Once you know the cubic polynomials that define X(t) and Y(t) for any individual Bezier curve, the simplest way to draw the curve is to loop through values of t, stepping from 0.0 to 1.0, and draw short lines between successive values. For example, if you have already defined methods double X(double t) and double Y(double t), then you can use code structured something like:

   for (double t = 0 ; t <= 1 ; t += ε)
      g.drawLine((int)X(t), (int)Y(t), (int)X(t+ε), (int)Y(t+ε));