Interact with smooth curves. Choose one of : OpenGL or webGL.
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
Connect adjacent control points \(P_i\) with white line segments for example as follows.
ip = i+1; if i==N, ip = 0;
or
modulo
or
repeat the end point when seting up the VAO, VBO
for the polygon.)
glDrawArrays
with
GL_LINE_STRIP
or
GL_LINE_LOOP
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
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.
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:
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
Let \(n\) be the tessellation number (= number of evaluations-1 = number of segments) per BB-piece.
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)
Make sure picking still works on the original \(N\) vertices, and your curves adapt when moved.