# Introduction to Splines and Parametric Curve Representations

Even 200 years ago engineers used smooth shapes:
-- in ship building for fast, smooth hulls,
-- in watch making for the spiral spring that powers the watch ...

Motivational task:  How to construct a "smooth" spiral ?
-- piecewise  linear - yields connectivity;
-- composed of circular arcs - yields G1 (tangent-) continuity;
-- composed of elliptical arcs - yield G2 (curvature-) continuity.

How do you represent straight lines, planes ?
How do you generalize that to curves, curved surfaces ?
-- parametric representations of a spiral.
-- other examples of parametric curves.

What are "splines" ? -- Wood strips used in ship building that yield nice smooth curves,
because nature is trying to minimize overall bending energy (= arc-length integral of curvature squared).
Depending on what fixtures are being used one can apply different constraints to those strips
-- Position Constraints are implemented with pegs, and
-- Tangent Constriants can be realized with clamps.
Mathematical "splines" are linearized approximations to the above difficult optimization problem.

When making smooth shapes by piecing together smooth curves, consider the
degrees of smoothness at the joints:
-- Parametric Continuity: differentiability of the parametric representation (C0, C1, C2, ...)
-- Geometric Continuity: smoothness of the resulting displayed shape (G0=C0, G1=tangent-cont., G2=curvature-cont. )

Distinguish between:
-- Interpolating splines (pass through all the data points; example Hermite splines), and
-- Approximating splines (only come close to data points; example B-Splines).

## Cubic Bezier Curves

These very handy curves are a mixture of the above two "pure" schemes.
Cubic Bezier Curve is defined by:
-- 2 interpolated endpoints, and
-- 2 approximated intermediary control points that define the tangent directions at the endpoints.
Cubic polynomials: ==> allow to make inflection points and true space curves in 3D.

Basic underlying math;
(Cubic) Polynomial: infinitely differentiable --> Continuity = C-infinity
Cubic Hermite Spline: 2 endpoints, 2 tangent directions.
Cubic Bezier Curve: 2 endpoints, 2 approximated intermediary control points.
-- (P1,P2) = 1/3 of starting velocity vector
-- (P3,P4) = 1/3 of ending velocity vector
Influence of parameters (qualitative view).
DOF's (Degrees of Freedom).

### Properties of Bezier Curves

• Cubic polynomial, ==> true space curves;
• Interpolates endpoints;
• Approximation of other two control points;
• End tangents defined by pairs of control points;
• Convex hull property;
• Invariant under affine transformations;
• Start-to-end symmetry;
• Infinitely differentiable;
• May have loops, cusps.
• ### Construction of Bezier Curves

DeCasteljau construction algorithm: (Construction by three iterations of linear interpolation)
How to draw a Bezier curve from its control points:
-- the geometrical construction.
-- the polynomial resulting from the repeated interpolations.
Subdivision of a Bezier curve into two pieces that together are identical to the original one.

### Higher-order Bezier Curves and Patches

It is hard to make "interesting" curves with high-order Bezier curves.
-- points in the middle of the curve get influenced by every control point!
But 5th degree (quintic) Bezier curves are very useful if you also want to get control over curvature at the ends.

There are better ways to make complicated curves with many undulations ...

### Stitching Bezier Curves Together

• Aiming for more control over complicated curves.
• Making Interpolating Curves from several Bezier segments.
• Tangent Continuity Conditions at the joints.
• Curvature Continuity Conditions at the joints.
• Counting Degrees of Freedom (DoF)
•      -- Each control point in 2D has 2 DoF.
-- Each constraint imposed removes one DoF.
-- How many DoF are remaining ?
• How to use these DoF's ?
•      ---> Optimize the curve !
• Global Optimization (approximation)
•      -- Define a cost function:
-- E.g., Strain Energy = arc-length integral of square of curvature. How to approximate a given smooth curve with Bezier segments.

A better way to make extensive smooth curves:

## B-Splines (an approximating spline)

An easy way to make a smooth C2-continuous space curve, e.g.,  for a path of an airplane or for a camera path,
is to sprinkle a few control points through space that define the coarse topology and geometry of the curve
and then let them be approximated by a cubic B-spline.

Assuming for the moment a closed curve with N=6 control points, such a curve would be described as
a sequence of N=6 cubic curve segments, each one of which is controlled by four consecutive control points,
but producing a curve segment that is only about as long as the distance between the two middle control points.
Because a subsequent curve segment reuses three of the control points of the previous segment,
they blend together in a very smooth (C2-continuous) way.

The interpolation function is given in all relevant text books:
One segment depending on the 4 control points A,B,C,D, is given by the polynomial:

Q = A(1 -3t +3t2 -t3)/6 + B(4 -6t2 +3t3)/6 + C(1 +3t +3t2 -3t3)/6 + D(t3)/6

thus the point at t=0 is given by  A/6 + 4B/6 + C/6,
and the point at t=1 is given by  B/6 + 4C/6 + D/6.

### Properties of Cubic B-Splines

• Piecewise cubic polynomial;
• Does NOT interpolate control points;
• Convex hull property;
• Construction by 3-fold linear interpolation
• Invariant under affine transformations;
• Start-to-end symmetry;
• Twice differentiable (C2) at joints;
• Infinitely differentiable everywhere else;
• May have cusps, thus may not be G2 everywhere;
• Good to make smooth closed loops.

## Use of Splines in your Final Projects

• Smooth camera paths.
• Rollercoaster tracks.
• Snake bodies (sweep along a spline curve).
• Curved smooth bodies and shells.