Project 4: NURBS Curve Evaluator (The Smooth Math)
Build a NURBS curve evaluator that generates points and tangents from control points.
Project Overview
| Attribute | Value |
|---|---|
| Difficulty | Level 2: Intermediate |
| Time Estimate | 1-2 weeks |
| Main Language | C++ |
| Alternative Languages | C, Rust, Python |
| Knowledge Area | Parametric curve evaluation |
| Tools | Plotting tool, CAD viewer |
| Main Book | “The NURBS Book” by Piegl & Tiller |
What you’ll build: A curve evaluator that outputs sampled points and tangents for NURBS curves.
Why it teaches computational geometry: NURBS are the native language of CAD. Understanding them is essential.
Core challenges you’ll face:
- Implementing the Cox-de Boor recursion
- Handling weights and rational coordinates
- Managing knot vectors and parameter ranges
Real World Outcome
You will generate curve points that can be plotted and verified. The curve will interpolate or approximate control points based on weights and knots.
Example Output:
$ ./nurbs_curve --control control.json --samples 200 --output curve.csv
Degree: 3
Control points: 7
Wrote curve samples to curve.csv
Verification steps:
- Plot the curve with control points
- Confirm endpoint and continuity behavior
The Core Question You’re Answering
“How does a CAD system turn a handful of control points into a smooth, precise curve?”
NURBS curves are the backbone of every smooth CAD shape.
Concepts You Must Understand First
Stop and research these before coding:
- B-spline basis functions
- How do basis functions blend control points?
- Book Reference: “The NURBS Book” by Piegl & Tiller, Ch. 2
- Knot vectors
- How do knots control parameterization and continuity?
- Book Reference: “Curves and Surfaces for Computer-Aided Geometric Design” by Gerald Farin, Ch. 5
- Rational weights
- Why do weights allow exact circles?
- Book Reference: “The NURBS Book” by Piegl & Tiller, Ch. 4
Questions to Guide Your Design
- Evaluation strategy
- Will you use recursive or iterative basis evaluation?
- How will you handle clamped vs unclamped knots?
- Sampling density
- How will you choose the number of sample points?
- How do you detect areas needing more detail?
Thinking Exercise
Knot Intuition
Given a cubic B-spline with clamped knots, sketch how the curve behaves near the endpoints.
Questions while working:
- Why does clamping force interpolation at endpoints?
- How does knot multiplicity affect continuity?
The Interview Questions They’ll Ask
Prepare to answer these:
- “What are NURBS and why are they used in CAD?”
- “How do basis functions work?”
- “What is the role of a knot vector?”
- “Why do rational weights enable circles?”
- “How do you compute curve tangents?”
Hints in Layers
Hint 1: Starting Point Start with B-spline basis functions before adding weights.
Hint 2: Next Level Implement Cox-de Boor recursion for basis evaluation.
Hint 3: Technical Details Compute rational coordinates by dividing weighted sums by total weight.
Hint 4: Tools/Debugging Plot basis functions to verify they sum to one across the parameter range.
Books That Will Help
| Topic | Book | Chapter |
|---|---|---|
| B-splines | “The NURBS Book” by Piegl & Tiller | Ch. 2 |
| Knot vectors | “Curves and Surfaces for CAGD” by Gerald Farin | Ch. 5 |
| Rational curves | “The NURBS Book” by Piegl & Tiller | Ch. 4 |
Implementation Hints
- Validate basis functions independently before curve evaluation.
- Keep knot vector checks strict to avoid undefined behavior.
- Provide a simple CSV output for plotting.
Learning Milestones
- First milestone: You can evaluate a simple B-spline curve.
- Second milestone: You can add weights and produce NURBS curves.
- Final milestone: You can explain continuity and knot effects.