Shape Analysis #2: Curve Representation

7 months ago
geometrylearningcomputer-graphics

What is a curve?

  • A parameterized curve is a map btw each point tt an interval of the real line to some point x(t)x(t) in the plane
  • Note that: the same geometrical curve admit many parameterizations...
    • basically corresponds to a change of "velocity" along the curve
    • canonical: unit-speed curve ∥x′(t)∥=1\|x'(t)\|=1
    • we can get this unit-speed curve by choosing the right parameterization:
  • A measure of the curve is called geometric if it is invariant to the choice of parameterization:
    • e.g: length, tangent direction, normal direction, curvature
    • some are not intuitive from the formula. E.g: curvature

Given a curve x(t)=(x(t)y(t))x(t)=\begin{pmatrix}x(t)\\ y(t)\end{pmatrix}

The length of this curve between t0t_0 and tt is:

l(t)=∫t0tx′(s)2+y′(s)2ds=∫t0t∥x′(u)∥dul(t) = \int_{t_0}^t \sqrt{x'(s)^2+y'(s)^2} ds = \int_{t_0}^t\|x'(u)\|du
  • note that l(t)l(t) is strictly increasing
  • thus, it has an inverse l−1(t)l^-1(t)
  • x(l−t(t))x(l^-t(t)) is exactly the unit-speed curve we are looking for

Local Frames of Curves (Frenet–Serret basis (or TNB basis))

Given an unit-speed curve.

The tangent, normal, and binormal unit vectors, often called T, N, and B make up the Frenet–Serret basis (or TNB basis), together form an orthonormal basis that spans R3\mathbb{R}^3 are defined as follows:

  • T is the unit vector tangent to the curve, pointing in the direction of motion.
  • N is the normal unit vector, the derivative of T with respect to the arclength parameter of the curve, divided by its length.
  • B is the binormal unit vector, the cross product of T and N.

In math word:

  • T=x′(s)T = x'(s)
  • N=x′′(s)N = x''(s)
  • B=T×NB = T\times N

Because we have <x′(s),x′(s)>=1<x'(s),x'(s)>=1, one has <x′(s),x′′(s)>=0<x'(s), x''(s)>=0, so x′′(s)isnormalofthecurvex''(s) is normal of the curve

  • The maginitude of x′′(s)x''(s) is the absolute value of the curvature κ\kappa
    • x′′(s)=κ(s)n(s)x''(s)=\kappa(s)n(s)
    • inverse of osculating radius
dds(t(s)n(s)b(s))=(0κ(s)0−κ(s)0τ(s)0−τ(s)0)(t(s)n(s)b(s))\frac{d}{ds}\begin{pmatrix} t(s)\\ n(s)\\ b(s) \end{pmatrix} = \begin{pmatrix} 0 & \kappa(s) & 0\\ -\kappa(s) & 0 & \tau(s)\\ 0 & -\tau(s) & 0 \end{pmatrix} \begin{pmatrix} t(s)\\ n(s)\\ b(s) \end{pmatrix}

Fundamental theorem of Curves

  • In 2D, the curvature κ(t)\kappa(t) fully determines a planar curve up to rigid motion (translation, rotation)
  • In 3D, the curvature κ(t)\kappa(t) and torsion τ(t)\tau(t) fully determine a curve up to rigid motion.

But now what, how to explain the curve to the computer?

The simplest form could be through a function: y=f(x)y=f(x)

Or through 22 functions we saw earlier.

Or ... through interpolation between ordered points:

  • linear interpolation: easy, but look boring, and not smooth
  • linear combination of smooth functions

Winding number

Winding number (winding index) of a closed curve in the plane around a given point is an integer representing the total number of times that the curve travels counterclockwise around the point, i.e., the curve's number of turns. For certain open plane curves, the number of turns may be a non-integer. The winding number depends on the orientation of the curve, and it is negative if the curve travels around the point clockwise.

-2-10
123

Turning number theorem:

∮Cκds=k2π with k being turning number.\oint_C \kappa ds = k2\pi \text{ with }k\text{ being turning number.}

Generic Interpolation

Given points (xi,yi)(x_i,y_i) and basis functions {ϕi(x)}\{\phi_i(x)\}, find a function:

f(x)=∑i=1Naiϕi(x) s.t. f(xi)=yif(x) = \sum_{i=1}^N a_i\phi_i(x) \text{ s.t. }f(x_i)=y_i

Solution step-by-step:

  • Construct the Vandermonde-like matrix:
W=(ϕ1(x1)ϕ2(x1)…ϕN(x1)ϕ1(x2)ϕ2(x2)…ϕN(x2)⋮⋮⋱⋮ϕ1(xN)ϕ2(xN)…ϕN(xN))W = \begin{pmatrix} \phi_1(x_1) & \phi_2(x_1) & \ldots & \phi_N(x_1)\\ \phi_1(x_2) & \phi_2(x_2) & \ldots & \phi_N(x_2)\\ \vdots & \vdots & \ddots & \vdots \\ \phi_1(x_N) & \phi_2(x_N) & \ldots & \phi_N(x_N) \end{pmatrix}
  • Solve for the vector a=W−1ya = W^{-1}y
  • Done

So the problem come back to the choice of the basis function ϕi\phi_i.

Polynomial Interpolation

simple, but can easily go bad:

  • Runge phenomenon
  • local changes affect global shape
  • may not converge
  • terrible condition number for W.

Spline Interpolation

Idea: although globally, there is no interpolating low-degree polynomial, locally, we may find a good one.

Goal: construct a set of local, piecewise expressions that result in a smooth, global curve:

  • simpler is better, so let's keep it of low-order
  • but too simple is bad: linear should be avoided for example

cubic polynomial is the first order having inflections (change of curvature)

To formularize the problem again:

Given pairs of coordinates {xi,yi}\{x_i,y_i\}, construct a function ff s.t. f(xi)=yi∀if(x_i)=y_i \forall i that is cubic in each interval [xi,xi+1][x_i,x_{i+1}].

We have:

fi(xi)=yi  ⟺  ai+bixi+cixi2+dixi3=yifi(xi+1)=yi+1  ⟺  ai+bixi+1+cixi+12+dixi+13=yi+1\begin{alignat*}{7} &f_i(x_i) &&= y_i &&\iff a_i &&+ b_ix_i &&+ c_ix_i^2 &&+ d_ix_i^3 &&= y_i\\ &f_i(x_{i+1}) &&= y_{i+1} &&\iff a_i &&+ b_ix_{i+1} &&+ c_ix_{i+1}^2 &&+ d_ix_{i+1}^3 &&= y_{i+1}\\ \end{alignat*}

This ensures that ff interpolates the points and is continuous.

But we also need smoothness:

fi′(xi)=fi−1′(xi)  ⟺  bi+2cixi+3dixi2=bi−1+2ci−1xi+3di−1xi2\begin{alignat*}{4} f_i'(x_i) = f_{i-1}'(x_i) &\iff &&b_i &&+ 2c_ix_i &&+ 3d_ix_i^2\\ & = &&b_{i-1} &&+ 2c_{i-1}x_i &&+ 3d_{i-1}x_i^2 \end{alignat*}

I am not so sure why, but my lecture also requires second derivative at the end of each interval to be equalized.

And finally, we need to ensure f′(x1)=s1f'(x_1)=s_1 and f′(xN)=sNf'(x_N)=s_N with s1,sNs_1, s_N being the direction of the curve at the very last points.

Thus we have a 4(n−1)4(n-1) linear equation with 4(n−1)4(n-1) variables. And this approach has some particular benefits:

  • easier to solve numerically (sparse solvers)
  • more stable solutions (lower condition number)
  • is guaranteed to converge as sampling density increases.

Note: This is so much better compare to Lagrange interpolation (polynomial version) because among all C2C^2 functions that interpolate a given set of points, spline interpolate minimizes:

∫x1xNf′′(x)2dx\int_{x_1}^{x_N}f''(x)^2 dx

which is closely related to curvature minimization!

Variant of Cubic Splines

  • Hermite splines: The tangent at each endpoints is provided by users.
  • Catmull-Rom splines: tangent based on previous/next points

Other Ways to Design Splines

Find a more expressive basis:

Q(u)=a0+a1u+a2u2+a3u3=p0b0(u)+p1b1(u)+p2b2(u)+p3b3(u)\begin{align*} Q(u) &= a_0 + a_1u + a_2u^2 + a_3u^3\\ &= p_0b_0(u) + p_1b_1(u) + p_2b_2(u) + p_3b_3(u) \end{align*}
  • This works for arbitrary order k=2,3,…k=2,3,\dots
  • (pi)i≤n(p_i)_{i\le n} are the control points
  • u∈[0,1]u\in[0,1] is the parameterization variable.
{bi(u)≥0∑i=1kbi(u)=1\begin{cases} b_i(u) \ge 0\\ \sum_{i=1}^k b_i(u) = 1 \end{cases}

A few more key-word to look at:

  • de Casteljau Algorithm: Repeated subdivision converges to curve
  • B Splines
  • Chaiken’s Algorithm: This idea is the basis of subdivision surfaces

Comments (0)

No comments yet. Be the first to share your thoughts!