# Lecture_010_Digital_Geometry_Processing

## Problems in Geometry Processing

Reconstruction:

• samples from

• point clouds, normals
• image pairs (stereo)
• line density integral (MRI/CT)
• techniques

• silhouette-based (visual hull)
• Voronoi-based (power crust)
• PDE-based (Poisson Reconstruction)
• Radon Transform / Isosurfacing (Marching cubes)

Upsampling: increase resolution via interpolation

• subdivision

• bilateral upsampling

Downsampling: decrease resolution

• iterative decimation

• variational shape approximation

Resampling: modify sample distribution to improve quality (visualization vs solving equation)

Filter: remove noise or emphasize features

• curvature flow

• bilateral filter

• spectral filter (augment low frequency signal result in exaggerated shape)

Compression: reduce storage size by remove redundant data or approximating unimportant data

• compress geometry and connectivity

Shape Analysis:

• computer vision

• segmentation

• symmetry detection

• correspondence

## Re-meshing and Sampling

Metrics: how should we judge that our re-meshed result is good

• vertex position is close

• vertex normal is close

• triangles are close to 60 degrees

• Delaunay: when there are no other triangle's vertex inside the circle of a triangle

• helps with numerical accuracy and stability
• maximizes minimum angles
• provide smoothest interpolation
• guarantee maximum principle in Laplace PDE
• vertex degree: closer to degree 6

In general, you can't have regular vertex degree everywhere.

## Subdivision and Upsampling

Metrics:

• interpolation vs approximation: do we constraint by the overall looking or the geometric property

• limit surface continuity

• behavior at irregular vertices

Algorithms:

• Triangle: Loop, Butterfly, Sqrt(3)

The equation, especially the weighting for the new vertex coordinate, here is quiet arbitrary.

1. split every polygon into quadrilaterals
2. compute the coordinates of face center (by arithmetic mean)
3. compute edge center positions by arithmetic mean
4. calculate vertex coordinates

For edge case: we want the subdivision to behave the same if the tube gets cut in half

• Edge Midpoint: $e = (a + b) / 2$

• Vertex Positions: $v = 1/8a + 1/8c + 3/4b$

Catmull-Clark keeps original irregular vertices but does not introduce new vertices for quads. When applied to triangles, it generates irregular mesh everywhere.

Loop Subdivision: Triangle subdivision with $C^2$ continuity

1. split each triangle into four
2. assign new vertex position according to weights

Loop Subdivision can be implemented by split and flip.

## Simplification and Downsampling

Greedy Algorithm: iteratively collapse edges

1. assign edge with a cost function (quadratic error metric, Garland & Heckbert 1997 CMU)
2. collapse edge with least cost using gradient descent
3. repeat until target number is reached

Quadratic Error Metric: the distance between a vertex to its adjacent faces

To calculate the error in 3D coordinates, we need:

• query point $\vec{x} = (x, y, z)$ where $x, y, z$ are coordinates

• plane normal $\vec{n} = (a, b, c)$ where $\vec{n}$ is a unit vector

• distance from plane to origin $d = \vec{n} \cdot \vec{p}$ where $\vec{p}$ is the point where the normal vector $\vec{n}$ points from.

Note that we only need $d$ and $\vec{n}$ to describe a plane. To draw a plane in 3D, first find all the points in a surface of a ball of radius $d$ from the origin. Then, notice every point of the surface have a different normal. Then we can pin point the plane using the normal we stored.

To calculate the error in homogeneous coordinates, we need:

• query point $\vec{u} = (x, y, z, 1)$ where $x, y, z$ are coordinates

• plane $\vec{v} = (a, b, c, d)$ where $(a, b, c)$ is a unit vector and $d$ is the distance from plane to origin.

Notice that we can represent a 3D plane in homogeneous coordinates as a point in 4D.

Signed distance to a plane is:

\vec{u} \cdot \vec{v} = ax + by + cz + d

Squared distance is

(\vec{u} \cdot \vec{v})^2 = \vec{u}^T(\vec{v}\vec{v}^T)\vec{u} = \vec{u}^TK\vec{u}\\ K = \vec{v}\vec{v}^T = \begin{bmatrix} a^2 & ab & ac & ad\\ ab & b^2 & bc & bd\\ ac & bc & c^2 & cd\\ ad & bd & cd & d^2\\ \end{bmatrix}

Notice matrix K encodes squared distance to plane $\vec{v}$. To find the squared distance for any point $\vec{u}$, you just do $\vec{u}^TK\vec{u}$.

Furthermore, if you want to find the distance to union of planes $P_1, P_2, ...$, you can just some multiple matrix $K_1, K_2, ...$. Therefore you only need to do one matrix computation. Which means you can use all planes in your geometry. However, this might not be useful as every point will then be set to the center of the geometry.

Since gradient descent is costly, it might be possible to find a analytical solution to quadratic equations in 2D.

We can write the following 2D quadratic equation in matrix form:

f(x, y) = ax^2 + bxy + cy^2 + dx + ey + g
X = \begin{bmatrix} x\\ y\\ \end{bmatrix}, A = \begin{bmatrix} a & b/2\\ b/2 & c\\ \end{bmatrix} u = \begin{bmatrix} d\\ e\\ \end{bmatrix}\\ f(x, y) = x^T A x + u^T x + g

Now we can observe a critical point (when derivative is zero, there can be minimum, maximum, or saddle point) can be described by:

\begin{align*} 2Ax + u =& 0\\ x =& - \frac{1}{2}A^{-1}u\\ \end{align*}

The critical point is a minimum as long as it satisfy: (quadratic term greater than zero)

(\forall x) (x^T A x > 0)

So we want to minimize the following formula:

\min_{\vec{u} \in \mathbb{R}^4} \vec{u}^T K \vec{u}

Firstly we break up quadratic function into:

\begin{align*} &\begin{bmatrix} \vec{x}^T & 1 \end{bmatrix} \cdot\begin{bmatrix} B & \vec{w}\\ \vec{w}^T & d^2\\ \end{bmatrix} \cdot\begin{bmatrix} \vec{x}\\ 1\\ \end{bmatrix}\\ =& \vec{x}^T B \vec{x} + 2\vec{w}^T \vec{x} + d^2\\ \to& \vec{x} = -B^{-1}\vec{w}\\ \end{align*}

We can guarantee B is a positive definite matrix because there exists one point that minimizes this error to zero.

Summary:

• compute $K_f$ for each triangle face

• set $K_i$ for each vertex $i$ to be $\sum K_f$ from incident triangles

• set $K_e$ for each edge $e$ to be $K_{ij} = K_i + K_j$ from incident vertex

• find point $x$ that minimize the error, assign the cost to the point to $K_{ij}(x)$.

• find the smallest cost $K_{ij}(x)$ and collapse to point $x$

• update costs near the new vertex

The information of the original geometry is never lost in the process of repeating collapse because they are tacked by $K_{ij}$.

In practice the algorithm might generate flipped triangles. In this case, don't do the operation.

## Re-mesh

### Delaunay Mesh

To obtain delaunay mesh, we can flip the edge if

\alpha + \beta > \pi

For planer triangulation (2D case), we can guarantee with $O(n^2)$ (where $n$ is the number of triangles) steps, we will eventually get a Delaunay mesh. However, it does not always work in 3D because there might be livelock (loop forever where one edge keeps flipping). But there are ways to detect such livelock and you don't need $O(n^2)$ to get "ok" looking mesh.

### Vertex Degree

Since the average degree of a geometry approaches to 6 as number of triangles increases, you might hope to get a mesh that is very close to degree 6.

There is no guarantee edge flip works. But it works in practice.

### 60 Degree

We can repeatably center vertices to make triangle more "round".

We can move vertices only in the direction that is tangent to the surface (by removing normal component of the moving direction. The normal direction is calculated using vertex's own neighbores)

### Isotropic Re-meshing

Repeat Four Steps:

1. split any edge over $\frac{4}{3}$ mean edge length
2. collapse edge less than $\frac{4}{5}$ mean edge length
3. Flip edges to improve vertex degree
4. Center vertices tangentially

// QUESTION: how is the numbers here chosen?

Table of Content