Quiz: polynomial wiggles, piecewise cubics and Bézier curves
Before this unit: Day 1: Images, filters and frequencies.
See also: Day 5: Deconvolution; Day 14: Labelling.
Short questions to test your understanding. Try each on paper first, then open the answer.
Q1. You have 15 equally spaced samples of a smooth intensity profile and fit one polynomial of degree 14 through them. Where do you expect trouble, and does taking 30 samples help?
Runge’s phenomenon.
Near the two ends: the polynomial passes through every sample but swings wildly between the outer samples. More equally spaced samples make it worse, not better (for the bump 1/(1 + 25x^2) the largest error grows from 1.9 at 11 samples to 60 at 21). Use piecewise low-degree pieces (a spline) instead.
Q2. Piecewise linear interpolation is local and never overshoots. What is wrong with it for measuring curvature or velocity?
What happens to the slope at a sample?
The slope jumps at every sample (a kink), so the first derivative is a staircase and the second derivative is zero between samples and infinite at them. Curvature and acceleration computed from it are meaningless. Piecewise cubics that agree in slope (and curvature) at the joins fix this.
Q3. Two curve pieces meet with the same tangent direction but different speeds. Which continuity is this: C⁰, G¹, C¹ or C²? Would you see it in the curve? In the curvature comb?
G stands for geometric: only the direction counts.
G¹ (and C⁰), but not C¹. The curve itself looks smooth (no kink), but the curvature generally jumps at the join; the comb shows a step there, which the eye sees as a subtle “bump” in a highlight or reflection.
Q4. A cubic Bézier curve has control points (0, 0), (2, 4), (4, 4), (6, 0). Without computing anything: where does it start and end, in which directions, and can it go above y = 4?
End points, end legs, convex hull.
It starts at (0, 0) heading towards (2, 4) and ends at (6, 0) arriving from the direction of (4, 4). It stays inside the convex hull of the four points, so it never goes above y = 4 (in fact its highest point is y = 3 at t = \tfrac12).
Q5. Evaluate the quadratic Bézier curve with control points (0, 0), (2, 2), (4, 0) at t = \tfrac12 by de Casteljau.
Halfway along each leg, then halfway between the two new points.
Legs: (1, 1) and (3, 1). Then halfway between them: (2, 1). (Bernstein weights \tfrac14, \tfrac12, \tfrac14 give the same point.)
Q6. You want to rotate a curve made of 50 cubic Bézier pieces by 30°. What is the cheapest exact way?
Affine invariance.
Rotate the control points (at most 151 points for a connected chain) and draw the curve from them. Because every curve point is a weighted average of the control points with weights that sum to 1, rotating the control points rotates every curve point exactly.
Q7. A Bézier piece ends with \mathbf{P}_2 = (5, 1), \mathbf{P}_3 = (6, 3). Where must \mathbf{Q}_1 of the next cubic piece go for a C¹ join? Give one position that is G¹ but not C¹.
Mirror \mathbf{P}_2 in \mathbf{P}_3.
C¹: \mathbf{Q}_1 = 2\mathbf{P}_3 - \mathbf{P}_2 = (7, 5). G¹ only: any other point on the ray (6, 3) + s(1, 2) with s > 0, e.g. (8, 7) (s = 2).
Q8. Why is a single Bézier curve of degree 20, controlled by 21 points, a bad way to draw a long outline?
Which Bernstein weights are non-zero at a given t?
Every Bernstein weight is positive for 0 < t < 1, so every control point moves the whole curve (global control); the influence of a single point is also weak and spread out, so the curve hugs the middle of the polygon and local detail is hard to draw. Chains of low-degree pieces (and next unit, B-splines) give local control.
Q9. (math) Show that the derivative of a cubic Bézier curve at t = 0 is 3(\mathbf{P}_1 - \mathbf{P}_0).
Differentiate the Bernstein form and set t = 0.
\mathbf{B}(t) = (1-t)^3\mathbf{P}_0 + 3t(1-t)^2\mathbf{P}_1 + 3t^2(1-t)\mathbf{P}_2 + t^3\mathbf{P}_3. Differentiating: -3(1-t)^2\mathbf{P}_0 + 3\big[(1-t)^2 - 2t(1-t)\big]\mathbf{P}_1 + 3\big[2t(1-t) - t^2\big]\mathbf{P}_2 + 3t^2\mathbf{P}_3. At t = 0: -3\mathbf{P}_0 + 3\mathbf{P}_1.