Project 1b

Points: 45 (+10 BONUS)

Purpose

Interact with smooth curves in OpenGL.

Set Up


Place \(N=8\) control points equally distributed to form a circle.
Title the window "yourFirstname yourLastname (ufid)"

For each Task below show the control points and the curve (sequence of line segments).
The points \(P_i\) are the same for all Tasks.

Task 1: Connect the points

Points: 5

Connect all the control points with white lines

Task 2: (B-spline) Subdivision

Points: 10

From the polygon in Task 1, generate a smoother curve by subdivision.

Initialize \(P_i^0 = P_i\) (green).
Double the number of control points by setting

\[P^k_{2i} := \frac{P^{k-1}_{i-2} + 10P^{k-1}_{i-1} + 5P^{k-1}_{i}}{16}\] \[P^k_{2i+1} := \frac{5P^{k-1}_{i-1} + 10P^{k-1}_{i} +P^{k-1}_{i+1}}{16}\]

where \(k\) is the level of subdivison and
\(i\) is the index of points is in range \(0 \dots (N\times 2^k-1)\) .

Cycle through a maximal level of subdivisions: when \(k=0\) show the original control polygon. When key 1 is pressed and \(k=m\) then compute and draw the control polygon at level \(k=m+1\). However, when \(m=5\), \(m\) is set to 0 and the original control polygon is drawn.

Task 3: \(C^3\) Bezier

Points: 10

Another way to generate a curve is to construct several smoothly connected Bezier pieces.

We are going to construct 8 pieces of degree 4. The \(i\)th piece has control points \(\mathbf{c}_i=\{c_{i,0},c_{i,1},c_{i,2},c_{i,3},c_{i,4}\}\). One of the 5 control points is given as: \[c_{i,2} = \frac{4P_{i-1}+16P_i+4P_{i+1}}{24}\] and the points \(c_{i,1}\) and \(c_{i_3}\) have the following form: \[c_{i,1} = a P_{i-1} + b P_i + c P_{i+1}\] \[c_{i,3} = c P_{i-1} + b P_i + a P_{i+1}\] for constants \(a,b,c\).

Task 4: Draw the Bezier curve

Points: 15

For each Bezier curve piece:

Draw the 5 BB-coefficients in red

Choose \(n\) the number of pieces to discretize each Bezier piece into (tessellation number) sufficiently high so the discretized curve looks smooth.

Task 5: Similarity between the curves

Points: 5

BONUS

Points: 10

Implement Task 4 using the OpenGL 4.x tessellation engine.

REMARK

Point penalty: 10

Make sure picking still works on the original \(N\) vertices, and your curves adapt to their movement.

WHAT TO SUBMIT