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 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.

hints.

Computer graphics window showing ten intended control points arranged to form a figure-eight shape on a dark blue background. Several points overlap at the center, so only nine distinct points are visible.
Figure 1. Reference configuration for the N = 10 control points forming a figure 8.

Task 1: B-spline Subdivision

Points: 15

Initialize P0i = Pi (white points).

Use these formulas to create a refined set of control points (cyan):

Pk2i := (4Pk−1i−1 + 4Pk−1i) / 8 Pk2i+1 := (Pk−1i−1 + 6Pk−1i + Pk−1i+1) / 8

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).

Computer graphics window illustrating B-spline subdivision. The original control points are white and the refined control points are cyan on a dark blue background.
Figure 2. Reference result for one step of B-spline subdivision.

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:

ci,1 := (2Pi + Pi+1) / 3 ci,2 := (Pi + 2Pi+1) / 3

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.

Computer graphics window showing the control-point configuration and intermediate points for cubic Bézier curves. Small yellow and white points are arranged in a figure-eight pattern on a dark blue background.
Figure 3. Reference configuration for the C2 Bézier-curve task.

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.

Computer graphics window showing smooth green curves and red control polygons for a figure-eight-shaped configuration. White points mark selected or original points.
Figure 4. Reference result for the Catmull–Rom curve task.

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.

Computer graphics window showing a figure-eight arrangement of small white control points on a dark blue background, illustrating the picking interface.
Figure 5. Reference image for picking and interaction with the original vertices.

What to Submit