CG Class 25, Mon 20181126
Table of contents
2 Chapter 13 slides ctd

We've seen some of this.
3 Chapter 14

Curves are the next chapter of Angel. WebGL does this worse than full OpenGL. Here is a summary. Big questions:
 What math to use?
 How should the designer design a curve?
 My notes on Bezier curves.

Partial summary:

To represent curves, use parametric (not explicit or implicit) equations.

Use connected strings or segments of lowdegree curves, not one hidegree curve.

If the adjacent segments match tangents and curvatures at their common joint, then the joint is invisible.

That requires at least cubic equations.

Higher degree equations are rarely used because they have bad properties such as:
 less local control. Changing one control point of a hidegree curve changes the whole curve. Parts of the curve distant from that point may move a lot. This makes designing a desired curve impossible.
 numerical instability. Small changes in coefficients cause large changes in the curve, even if computations are exact.
 roundoff error. Computations are not exact.

See my note on Hi Degree Polynomials.

One 2D cartesian parametric cubic curve segment has 8 d.f. in 2D (12 in 3D).
\(x(t) = \sum_{i=0}^3 a_i t^i\),
\(y(t) = \sum_{i=0}^3 b_i t^i\), for \(0\le t\le1\).

Requiring the graphic designer to enter those coefficients would be unpopular, so other APIs are common.

Most common is the Bezier formulation, where the segment is specified by 4 control points, which also total 8 d.f.: P0, P1, P2, and P3.

The generated curve starts at P0, goes near P1 and P2, and ends at P3.

The curve stays inside the control polygon, the convex hull of the control points. A flatter control polygon means a flatter curve. Designers like this.

A choice not taken would be to have the generated curve also go thru P2 and P3. That's called a CatmullRomOberhauser curve. However that would force the curve to go outside the control polygon by a nonintuitive amount. That is considered undesirable.

Instead of 4 control points, a parametric cubic curve can also be specified by a starting point and tangent, and an ending point and tangent. That also has 8 d.f. It's called a Hermite curve.

The three methods (polynomial, Bezier, Hermite) are easily interconvertible.

Remember that we're using connected strings or segments of cubic curves, and if the adjacent segments match tangents and curvatures at their common joint, then the joint is invisible.

Matching tangents (called \(G^1\) or geometric continuity) is sufficient, and is weaker than matching the 1st derivative (\(C^1\) or parametric continuity), since the 1st derivative has a direction (tangent) and a length. Most people do \(C^1\) because it's easier and good enough. However \(G^1\) gives you another degree of freedom to use in your design.

Similarly, matching the radius of curvature (\(G^2\) or geometric continuity) is weaker than matching the 2nd derivative (\(C^2\) or parametric continuity), but most people do parametric continuity.

Parametric continuity reduces each successive segment from 8 d.f. down to 2 d.f.

This is called a Bspline.

From a sequence of control points we generate a Bspline curve that is piecewise cubic and goes near, but probably not thru, any control point (except perhaps the ends).

Moving one control point moves the adjacent few spline pieces. That is called local control. Designers like it.

One spline segment can be replaced by two spline segments that, together, exactly draw the same curve. However they, together, have more control points for the graphic designer to move individually. So now the designer can edit smaller pieces of the total spline.

Extending this from 2D to 3D curves is obvious.

Extending to homogeneous coordinates is obvious. Increasing a control point's weight attracts the nearby part of the spline. This is called a rational spline.

Making two control points coincide means that the curvature will not be continuous at the adjacent joint.
Making three control points coincide means that the tangent will not be continuous at the adjacent joint.
Making four control points coincide means that the curve will not be continuous at the adjacent joint.
Doing this is called making the curve (actually the knot sequence) Nonuniform. (The knots are the values of the parameter for the joints.)

Putting all this together gives a nonuniform rational Bspline, or a NURBS.

A Bspline surface is a grid of patches, each a bicubic parametric polynomial.

Each patch is controlled by a 4x4 grid of control points.

When adjacent patches match tangents and curvatures, the joint edge is invisible.

The surface math is an obvious extension of the curve math.
 \(x(u,v) = \sum_{i=0}^3\sum_{j=0}^3 a_{ij} u^i v^j\)
 \(y, z\) are similar.
 One patch has 48 d.f. for Cartesian points, or 64 d.f. for homogeneous points, although most of those are used to establish continuity with adjacent patches.


My extra enrichment info on Splines.

The program I showed earlier is robotArm is Chapter 9.

To run program figure there, you may first need to fix an error in figure.html. Change InitShaders to initShaders.
Many of the textbook programs have errors that prevent them from running. You can see them in the console log.
4 Chapter 14 slides
 14_1 Curves and surfaces.
 Programs drawing the Utah teapot.