Part A: spline sketch
[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.
[10] When the key '1' is pressed,
for each i = 0, ..., 5, (suppose i = i mod 6)
Determine ci0 and ci3 so that the polynomial pieces join C2. Write down the formula for ci0 and ci3 and put it into your readme file.
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.1)
[10] When the key '2'
is
pressed, iterate cubic
uniform subdivision as defined in the following:
ck2i := ( ck-1i-1 +
6*ck-1i+ck-1i+1
) / 8
ck2i+1 := ( ck-1i +
ck-1i+1
) /2
[10] When the key '3' is pressed,
use a single gluNurbsCurve() function call to plot the
cubic curve (See Fig.2). What
is the number of knots, order and number of control
points? How do you make sure the curve is closed?
Put the answer in the readme file.
[10] Is the curve a circle? Can you choose the six control points so that the curve becomes a circle? What is the relationship between (a), (b) and (c)? Put the answer into readme.
Note:
|
![]() |
![]() |
![]() |
| Fig.1 | Fig.2 | Fig.3 |
Part B: spline interaction
[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. If the SHIFT key is depressed, picking and dragging moves in the z-direction; if it is not depressed, picking and dragging in the x-y plane. Refresh the control polygon and the curve while the mouse is moving. Releasing the left button stops the motion.
[20] When key '4' is pressed, create a side view of curves to see the picking and dragging in z-direction and have a box moving along the curve in both views (See Fig.3). You can use the control points from a.
[10] 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 and gets reset when 'r' is pressed.
You're supposed to submit the following files.
readme: what went right & what went wrong
& answers to theory questions.makefile: Please refer to the sample.run: Executable script which does all the batch jobs. Please refer to the sample.hw1.c)(We
require a single source code file)Preliminary version of Part A including the theory questions should be submitted on Jan 24th.
Here are executables for each platform. In the demo you can hide the curves by pressing space bar (this is not required in your implementation).
I will test your program on one of the machines of lin313-0*.cise.ufl.edu by the following steps.
readme file.run (to compile and run your program, see sample).