Project 2b © Jorg Peters
Points: 55 (+20 BONUS)
Purpose
Interact with smooth curves in OpenGL.
Set Up
Points: 5
Place N = 10 control points to form a
figure 8
. See the reference figure. Why are there only 9 points visible?
Title the window yourFirstname yourLastname (ufid).
For each task below, show:
- the control points and the curve as a sequence of line segments;
- for Tasks 2 and 3, also show the BB-polygon of coefficients connected in red, as illustrated in the figure next to the relevant task;
- use the same points Pi for all three tasks.
The coefficients ci,j in Task 2 are in general different from those in Task 3.
In Task 2, determine ci,0 and ci,3.
In Task 3, determine ci,1 and ci,2.
Task 1: B-spline Subdivision
Points: 15
Initialize P0i = Pi (white points).
Use these formulas to create a refined set of control points (cyan):
Here k is the level of subdivision and i is the index of points in the range 0 … (N × 2k − 1).
The figure illustrates one step of subdivision. Your implementation should allow repeated refinement (at least 5 times).
- Upon pressing key 1, trigger one additional refinement.
- Initially, when k = 0, draw the control polygon without subdivision.
- Whenever key 1 is pressed, redraw the subdivided control polygon.
- Every sixth refinement resets to level k = 0.
Task 2: C2 Bézier Curves
Points: 15
Let P = {P1, …, PN} be the set of input points.
Construct N Bézier curves of degree 3: one curve segment for each input point.
The coefficients of the ith curve are ci = {ci,0, ci,1, ci,2, ci,3}.
The interior Bézier points (yellow) are:
Determine ci,0 and ci,3 = ci+1,0 so that the polynomial pieces join C1.
Write down the formulas for ci,0 and ci,3 and place them into your ReadMe.txt file.
This method should be activated when key 2 is pressed on the keyboard.
Task 3: C1 Catmull–Rom Curves
Points: 20
Let P = {P1, …, PN} be the set of input points.
Construct a Catmull–Rom curve that interpolates the N points Pi as follows.
There are N Bézier curve segments of degree 3.
The coefficients of each segment i are ci = {ci,0, ci,1, ci,2, ci,3}, where ci,0 = Pi and ci,3 = Pi+1.
The tangent at ci,0 is a multiple of Pi+1 − Pi−1.
Once all of the Bézier points (red) are determined, use de Casteljau's Algorithm to evaluate the curve at 17 points per segment.
Connecting the points yields the Catmull–Rom curve (green).
This method should be activated when key 3 is pressed on the keyboard.
Bonus
Points: 20
Implement Task 3 using the OpenGL 4.x tessellation engine.
Remark
Make sure picking still works on the original N vertices, and your curves adapt to their movement.
What to Submit
- A .zip archive containing all modified source files (.cpp files and/or .js, shaders, etc.).
- A link to a screen capture of your running program showcasing the implementation of all the tasks using Recordit (Mac, Windows) or similar software.