[5] Draw a 500×500 window with black background. Set the title of the window to "grade_id / name". (See Fig.1)
[10] Place six control points P0, P1, P2, P3, P4, P5 in the window as follows: control points P0, P1, P2, P3, P4, P5 equally distributed on the unit circle
|
Draw the control points Pi with the size of 5×5 pixels in green and connect them with white lines to form the control polygon.
Plot the spline curves defined by the control polygon above. We will have 5 curve types:
[10] When the key '1' is pressed,
for each i = 0, ..., 5, (suppose i = i mod 6)
Draw the points cij in cyan with the size of 3×3 pixels.
Use the function glMap1() to draw the
quadratic curves with their control points of ci0, ci1, ci2. (See
Fig.1)
When the "C" key is pressed draw a
circle of appropriate size to show that the piecewise
polynomial curve is not a circle.
[5] When the key '2' is pressed,
for each i = 0, ..., 5, (suppose i = i mod 6)
Determine ci0 and ci3 so that the polynomial pieces join C2.
Draw those points in red color with the size of 3×3 then connect them to form the piecewise linear curves.
Use the function glMap1()
to draw the cubic curves with their control points of ci0,
ci1, ci2, ci3.(See
Fig.2)
[15] Determine rational
weights for quadratic and cubic so that the resulting
curve, when rendering using glMap1(),
is a circle. When key 'q' is pressed,
show the circle for quadratic and when key 'c' is pressed, show the
circle for cubic. (See Fig.q
for quadratic and Fig.c for cubic)
[10] When the key '3' is pressed,
use a single glNurbsCurve() function call to plot the
cubic curve and the quadratic curve (See Fig.3).
Rotate and superimpose the rotated curves to see they
are not circular.
Each time when 's' key is pressed, get a better approximation by performing one step of de Boor's subdivision (see note2 and 6.14 in papers2).
Redraw the new subdivided control polygon and print out the new length (in the command window, not the OpenGL window).
Note:
|
![]() |
![]() |
![]() |
| Fig.1 | Fig.2 | Fig.3 |
![]() |
![]() |
|
| Fig.q | Fig.c |
[15] Allow the position of control points to be interactively modified: when the left mouse button is clicked sufficiently near to a control point, that point will be picked and follow the motion of mouse cursor. Refresh the control polygon and the curve while the mouse is moving. Releasing the left button stops the motion.
[15] Allow the resizing of the window. Adjust the control points and the curve according to the size of the window. The picking and dragging of the control points should work as above regardless of the size of the window.
Program exits when ESC key is pressed.
Here are the executables for each platform you can try yourselves. In the demo you can hide the curves by pressing space bar, but this is not required in your program.