# Advanced Computer Graphics (Fall 2010) CS 283, Lecture 7: Quadric Error Metrics Ravi Ramamoorthi

## Presentation on theme: "Advanced Computer Graphics (Fall 2010) CS 283, Lecture 7: Quadric Error Metrics Ravi Ramamoorthi"— Presentation transcript:

Advanced Computer Graphics (Fall 2010) CS 283, Lecture 7: Quadric Error Metrics Ravi Ramamoorthi http://inst.eecs.berkeley.edu/~cs283/fa10

To Do Assignment 1, Due Oct 7.  Should have made some serious progress by end of week This lecture reviews quadric error metrics and some points regarding implementation

Resources  Garland and Heckbert SIGGRAPH 97 paper  Garland website, implementation notes (in thesis)  Notes in this and previous lectures

Surface Simplification: Goals (Garland)  Efficiency (70000 to 100 faces in 15s in 1997)  High quality, feature preserving (primary appearance emphasized rather than topology)  Generality, non-manifold models, collapse disjoint regions

Simplifications  Pair contractions in addition to edge collapses  Previously connected regions may come together

Algorithm Outline

Background: Computing Planes  Each triangle in mesh has associated plane  For a triangle, find its (normalized) normal using cross products  Plane equation?

Quadric Error Metrics  Sum of squared distances from vertex to planes:

Quadric Error Metrics  Common mathematical trick: quadratic form = symmetric matrix Q multiplied twice by a vector

Quadric Error Metrics  Simply a 4x4 symmetric matrix  Storage efficient: 10 floating point numbers per vertex  Initially, error is 0 for all vertices

Quadric Error Metrics  2 nd degree polynomial in x, y and z  Level surface (v T Qv = k) is a quadric surface  Ellipsoid, paraboloid, hyperboloid, plane etc.

Quadric Visualization  Ellipsoids: iso-error surfaces  Smaller ellipsoid = greater error for a given motion  Lower error for motion parallel to surface  Lower error in flat regions than at corners  Elongated in “cylindrical” regions

Using Quadrics Approximate error of edge collapses  Each vertex v has associated quadric Q  Error of collapsing v 1 and v 2 to v’ is v’ T Q 1 v’+v’ T Q 2 v’  Quadric for new vertex v’ is Q’=Q 1 +Q 2

Using Quadrics  Find optimal location v’ after collapse:

Using Quadrics  Find optimal location v’ after collapse:

Algorithm Outline

Algorithm Summary  Compute the Q matrices for all the initial vertices  Select all valid pairs  Compute the optimal contraction target v vor each valid pair. The error v T (Q 1 +Q 2 )v of this target vertex becomes the cost of contracting that pair  Place all pairs in a heap keyed on cost with minimum cost pair on the top  Iteratively remove the least cost pair, contract this pair, and update the costs of all valid pairs of interest

Final Algorithm

Results Original 1k tris 100 tris Quadrics

Results Original 250 tris, edge collapses only 250 tris Quadrics

Additional Details  Preserving boundaries/discontinuities (weight quadrics by appropriate penalty factors)  Preventing mesh inversion (flipping of orientation): compare normal of neighboring faces, before after  Has been modified for many other applications  E.g. in silhouettes, want to make sure volume always increases, never decreases  Take color and texture into account (followup paper)  See paper, other more recent works for details

Implementation Tips  Incremental, test, debug, simple cases  Find good data structure for heap etc.  May help to visualize error quadrics if possible  Challenging, but hopefully rewarding assignment

Questions?  Issues or questions?  All the material for assignment covered  Start early, work hard  Rest of unit  NURBs (today if time permits)  Subdivision (next lecture)

Outline  Rational Splines  Quadratic rational splines  NURBs (briefly)  Parametric patches (briefly)

Parametric Polynomial Curves  A parametric polynomial curve of order n:  Advantages of polynomial curves  Easy to compute  Infinitely differentiable everywhere

Rational Splines  Can’t represent certain shapes (e.g. circles) with piecewise polynomials  Wider class of functions: rational functions  Ratio of polynomials  Can represent any quadric (e.g. circles) exactly  Mathematical trick: homogeneous coordinates  Ratio of 2 polynomials in 3D equivalent to single polynomial in 4D

Rational Splines  Example: creating a circular arc with 3 control points (0,0) (0,1)(1,1) Polynomial spline: parabolic arc (0,0;1) (1,1;1) Rational spline: circular arc (???)

Standard deCasteljau Standard deCasteljau A B

Rational deCasteljau A B

Homogeneous deCasteljau Non-rational splines simply have all weights set to 1 instead

Outline  Rational Splines  Quadratic rational splines  NURBs (briefly)  Parametric patches (briefly)

Evaluation: Rational Splines  Add an extra weight coordinate Multiply standard coords of control point by weight (essentially the same as the use of homogeneous coords)  Apply standard deCasteljau or other evaluation alg.  Divide by final value of weight coordinate Essentially the same as perspective division/dehomogenize  Rational because of final division: Rational polynomial at the end (ratio of two polynomials)

Quadratic Bezier Curve  Example: quarter-circle arc, weight midpoint  Smaller w: pulled away from middle control point  Larger w: pulled towards middle control point (0,0;1) (0,1;1)(1,1;1) Polynomial spline: parabolic arc (0,0;1) (1,1;1) Rational spline: result depends on w (0,1;w)

Quadratic Bezier Curve General Bezier Formula for quadratic? (0,0;1) (0,1;1)(1,1;1) Polynomial spline: parabolic arc (0,0;1) (1,1;1) Rational spline: result depends on w (0,1;w)

Dependence of curve on w  For w very large, curve pulled toward middle control point, get a section of a hyperbola  For w = 1 (standard spline), standard parabola  For w < 1, positive, curve moves away from middle control point  For w = 0, curve becomes a straight line  When is curve part of a circle? (homework)

Mid-Point (t = ½ ?)

W very large (0,0;1) (0,1;>>1)(1,1;1)

W = 1 (non-rational spline) (0,0;1) (0,1;1)(1,1;1) Polynomial spline: parabolic arc

W < 1 (0,0;1) (1,1;1) Rational spline: result depends on w (0,1;w)

W = 0 (0,0;1) (1,1;1) Straight Line (0,1;w)

Outline  Rational Splines  Quadratic rational splines  NURBs (briefly)  Parametric patches (briefly)

NURBS  Non-uniform (vary time interval per segment)  Rational  B-Splines  Can model a wide class of curves and surfaces  Same convenient properties of B-Splines  Still widely used in CAD systems

Polar Forms: Cubic Bspline Curve -2 –1 0 –1 0 1 0 1 2 1 2 3  For Uniform B-splines, uniform knot vector (below)  For non-uniform, only require non-decreasing, not necessarily uniform (can be arbitrary) Uniform knot vector: -2, -1, 0, 1, 2,3 Labels correspond to this

NURBS

Outline  Rational Splines  Quadratic rational splines  NURBs (briefly)  Parametric patches (briefly)

Parametric Patches  Each patch is defined by blending control points FvDFH Figure 11.44

Parametric Patches  Point Q(u,v) on the patch is the tensor product of curves defined by the control points Watt Figure 6.21 Q(u,v) Q(0,0) Q(1,0) Q(0,1) Q(1,1)

Parametric Bicubic Patches  Point Q(u,v) defined by combining control points with polynomial blending functions: Where M is a matrix describing the blending functions for a parametric cubic curve (e.g., Bezier, B-spline, etc.)

Summary  Splines still used commonly for modeling  Start with simple spline curves (Bezier, uniform non-rational B-splines)  Discussed extension to rational curves (add homogeneous coordinate for rational polynomial)  Brief discussion of NURBs: widely used  Brief discussion of Parametric patches for modeling surfaces (rather than curves)