In class we covered cubic parametric splines, and touched briefly on bicubic parametric surface patches. What I would like you to do for this assignment is to implement an interactive Java applet that allows the user to compose a Bezier spline curve by adding control points, and by dragging around control points. Your program should behave as follows:
g.fillOval
method
for this)
to show that those control points are the ones
which mark the beginning and end of the individual Bezier curves.
Helpful notes:
-1 | 3 | -3 | 1 |
3 | -6 | 3 | 0 |
-3 | 3 | 0 | 0 |
1 | 0 | 0 | 0 |
The resulting column vector [a b c d]^{T} then provides the coefficients for the cubic polynomial
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, 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:
double dt = .01; for (double t = 0 ; t <= 1 ; t += dt) g.drawLine((int)X(t), (int)Y(t), (int)X(t+dt), (int)Y(t+dt));
Opportunities for extra credit:
As usual, there are lots of opportunities for extra credit in this assignment. You can constrain the key points so that successive spline segments have the same slope where they join. You do this as follows:
You can do forms of spline specification other than Bezier (eg: Hermite, B-Spline, etc.) You can try to do something other than cubic splines (eg: fourth degree Bezier). You can try to make interesting content, such as specifying alphabetic letters. Over the next day or so I'm going to be posting a list of interesting opportunities for special credit, so watch this space.
Next week we are going to be focusing much more on bicubic spline surfaces.