Project 1b ©Jorg Peters

Points: 45

Purpose

Interact with smooth curves. Choose one of : OpenGL or webGL.

Set Up

Proj 1A (hint: replace any explicit enumerations by loops)
(note ATTN: in the code! Examples of "Object": all Vertices, or all line segments, or all BB-polygons, or... )

For each Task below show the points and the curve (= sequence of short line segments).
The B-spline control points \(P_i\) are the same for all three Tasks.
The \(c_{i,j}\) in Task 3,4 are called BB-coefficients

Task 1: Connect the points

Points: 5

Connect adjacent control points \(P_i\) with white line segments for example as follows.

Task 2: Subdivision

Points: 10

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

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

\[P^k_{2i} := \frac{3P^{k-1}_{i}+P^{k-1}_{i+1}}{4}\] \[P^k_{2i+1} := \frac{P^{k-1}_{i}+3P^{k-1}_{i+1}}{4}\]

where \(k\) is the level of subdivison and
\(i\) is in \(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^1\) Bézier (BB-form)

Points: 10

Another way to generate a curve is to construct several smoothly connected pieces in Bernstein-Bézier (BB) form.

We construct N BB-pieces of degree 2. The \(i\)th piece has BB-coefficients \(\mathbf{c}_i=\{c_{i,0},c_{i,1},c_{i,2}\}\).
The interior BB-coefficient is:

\[c_{i,1} := P_{i}\]

Determine \(c_{i,0}\) and \(c_{i,2} = c_{i+1,0}\) so that the polynomial pieces join \(C^1\).
Write down the formulas for the BB-coefficients in terms of the B-spline control points in readme.txt

Task 4: Draw the Bezier curve

Points: 15

Let \(n\) be the tessellation number (= number of evaluations-1 = number of segments) per BB-piece.

Task 5: Similarity between the curves

Points: 5

BONUS

Points: 10

Implement Task 4 using the OpenGL 4.x's tessellation engine. (You will have to use the web for details -- or sign up for Advanced Graphics)

PENALTY

Points: -10

Make sure picking still works on the original \(N\) vertices, and your curves adapt when moved.

WHAT TO SUBMIT