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

Post on 15-Jan-2016

217 views 0 download

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

Advanced Computer Graphics Advanced Computer Graphics (Fall 2010) (Fall 2010)

CS 283, Lecture 7: Quadric Error Metrics

Ravi Ramamoorthi

http://inst.eecs.berkeley.edu/~cs283/fa10

To Do 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

ResourcesResources

Garland and Heckbert SIGGRAPH 97 paper

Garland website, implementation notes (in thesis)

Notes in this and previous lectures

Surface Simplification: Goals (Garland)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

SimplificationsSimplifications

Pair contractions in addition to edge collapses

Previously connected regions may come together

Algorithm OutlineAlgorithm Outline

Quadric Error MetricsQuadric Error Metrics

Based on point-to-plane distance

Better quality than point-to-point

aa bb cc

ddaa

ddbb

ddcc

Background: Computing PlanesBackground: Computing Planes

Each triangle in mesh has associated plane

For a triangle, find its (normalized) normal using cross products

Plane equation?

0ax by cz d+ + + =

0AB AC

n n v A vAB AC

´= - =

´

rr r r rg g

a

n b d A v

c

æö÷ç ÷ç ÷ç ÷= =-ç ÷ç ÷ç ÷÷çè ø

rr rg

Quadric Error MetricsQuadric Error Metrics

Sum of squared distances from vertex to planes:

2

T

( , )

,

1

( , )

Dist

x a

y b

z c

d

Dist ax by cz d

D =

æö æö÷ ÷ç ç÷ ÷ç ç÷ ÷ç ç÷ ÷ç ç÷ ÷ç ç÷ ÷= =ç ç÷ ÷ç ç÷ ÷÷ ÷ç ç÷ ÷ç ç÷ ÷ç ç÷ ÷ç çè ø è ø

= + + + =

åv

p

v p

v p

v p p v

2

T

( , )

,

1

( , )

Dist

x a

y b

z c

d

Dist ax by cz d

D =

æö æö÷ ÷ç ç÷ ÷ç ç÷ ÷ç ç÷ ÷ç ç÷ ÷ç ç÷ ÷= =ç ç÷ ÷ç ç÷ ÷÷ ÷ç ç÷ ÷ç ç÷ ÷ç ç÷ ÷ç çè ø è ø

= + + + =

åv

p

v p

v p

v p p v

Quadric Error MetricsQuadric Error Metrics

Common mathematical trick: quadratic form = symmetric matrix Q multiplied twice by a vector

T 2

T T

T T

T

( )D =

=

æ ö÷ç ÷= ç ÷ç ÷çè ø

=

å

å

å

p

p

p

p v

v pp v

v pp v

v Qv

T 2

T T

T T

T

( )D =

=

æ ö÷ç ÷= ç ÷ç ÷çè ø

=

å

å

å

p

p

p

p v

v pp v

v pp v

v Qv

Quadric Error MetricsQuadric Error Metrics

Simply a 4x4 symmetric matrix

Storage efficient: 10 floating point numbers per vertex

Initially, error is 0 for all vertices

Quadric Error MetricsQuadric Error Metrics

2nd degree polynomial in x, y and z

Level surface (vTQv = k) is a quadric surface Ellipsoid, paraboloid, hyperboloid, plane etc.

Quadric VisualizationQuadric 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 QuadricsUsing Quadrics

Approximate error of edge collapses Each vertex v has associated quadric Q Error of collapsing v1 and v2 to v’ is v’TQ1v’+v’TQ2v’ Quadric for new vertex v’ is Q’=Q1+Q2

Using QuadricsUsing Quadrics

Find optimal location v’ after collapse:

11 12 13 14

12 22 23 24

13 23 33 34

14 24 34 44

T

'

'

min ' ' ' : 0x y z

q q q q

q q q q

q q q q

q q q q

¶ ¶ ¶¶ ¶ ¶

é ùê úê úê ú= ê úê úê úê úë û

= = =v

Q

v Q v

11 12 13 14

12 22 23 24

13 23 33 34

14 24 34 44

T

'

'

min ' ' ' : 0x y z

q q q q

q q q q

q q q q

q q q q

¶ ¶ ¶¶ ¶ ¶

é ùê úê úê ú= ê úê úê úê úë û

= = =v

Q

v Q v

Using QuadricsUsing Quadrics

Find optimal location v’ after collapse:

11 12 13 14

12 22 23 24

13 23 33 34

1

11 12 13 14

12 22 23 24

13 23 33 34

0

0'

0

0 0 0 1 1

0

0'

0

0 0 0 1 1

q q q q

q q q q

q q q q

q q q q

q q q q

q q q q

-

é ù éùê ú êúê ú êúê ú êú=ê ú êúê ú êúê ú êúë û ëû

é ù éùê ú êúê ú êúê ú êú= ê ú êúê ú êúê ú êúë û ëû

v

v

11 12 13 14

12 22 23 24

13 23 33 34

1

11 12 13 14

12 22 23 24

13 23 33 34

0

0'

0

0 0 0 1 1

0

0'

0

0 0 0 1 1

q q q q

q q q q

q q q q

q q q q

q q q q

q q q q

-

é ù éùê ú êúê ú êúê ú êú=ê ú êúê ú êúê ú êúë û ëû

é ù éùê ú êúê ú êúê ú êú= ê ú êúê ú êúê ú êúë û ëû

v

v

Algorithm OutlineAlgorithm Outline

Algorithm SummaryAlgorithm 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 vT(Q1+Q2)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 AlgorithmFinal Algorithm

ResultsResults

OriginalOriginal

1k tris1k tris 100 tris100 tris

QuadricsQuadrics

ResultsResults

OriginalOriginal

250 tris, edge collapses only250 tris, edge collapses only250 tris250 tris

QuadricsQuadrics

Additional DetailsAdditional 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 TipsImplementation 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?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)

OutlineOutline

Rational Splines

Quadratic rational splines

NURBs (briefly)

Parametric patches (briefly)

Parametric Polynomial CurvesParametric Polynomial Curves

A parametric polynomial curve of order n:

Advantages of polynomial curves Easy to compute Infinitely differentiable everywhere

0

( )n

ii

i

x u a u=

=å0

( )n

ii

i

x u a u=

0

( )n

ii

i

y u b u=

=å0

( )n

ii

i

y u b u=

Rational SplinesRational 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 SplinesRational Splines

Example: creating a circular arcwith 3 control points

(0,0)(0,0)

(0,1)(0,1) (1,1)(1,1)

Polynomial spline:Polynomial spline:parabolic arcparabolic arc

(0,0;1)(0,0;1)

(1,1;1)(1,1;1)

Rational spline:Rational spline:circular arccircular arc

(???)(???)

Standard deCasteljauStandard deCasteljau

A B

(1 )t A tB

Rational deCasteljauRational deCasteljau

A B

(1 )

(1 )A B

A B

t A t Bw w

t tw w

Aw Bw

Homogeneous deCasteljauHomogeneous deCasteljau

(1 )

(1 )A B

A B

t A t Bw w

t tw w

Aw Bw

(1 )

(1 )A B

A B

t w A tw B

t w tw

A

A

w A

w

B

B

w B

w

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

OutlineOutline

Rational Splines

Quadratic rational splines

NURBs (briefly)

Parametric patches (briefly)

Evaluation: Rational SplinesEvaluation: 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 coordinateEssentially the same as perspective division/dehomogenize

Rational because of final division: Rational polynomial at the end (ratio of two polynomials)

Quadratic Bezier CurveQuadratic 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,0;1)

(0,1;1)(0,1;1) (1,1;1)(1,1;1)

Polynomial spline:Polynomial spline:parabolic arcparabolic arc

(0,0;1)(0,0;1)

(1,1;1)(1,1;1)

Rational spline:Rational spline:result depends on wresult depends on w

(0,1;w)(0,1;w)

Quadratic Bezier CurveQuadratic Bezier Curve

General Bezier Formula for quadratic?

(0,0;1)(0,0;1)

(0,1;1)(0,1;1) (1,1;1)(1,1;1)

Polynomial spline:Polynomial spline:parabolic arcparabolic arc

(0,0;1)(0,0;1)

(1,1;1)(1,1;1)

Rational spline:Rational spline:result depends on wresult depends on w

(0,1;w)(0,1;w)

2 2 2 2

2 2 2 2

(1 ) 2 (1 ) (1 ) 2 (1 )

(1 ) 2 (1 ) (1 ) 2 (1 )A B c B

A B c B

t w A t t w B t w C t A t t w B t C

t w t t w t w t t t w t

Dependence of curve on wDependence 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)

2 2 2 2

2 2 2 2

(1 ) 2 (1 ) (1 ) 2 (1 )

(1 ) 2 (1 ) (1 ) 2 (1 )A B c B

A B c B

t w A t t w B t w C t A t t w B t C

t w t t w t w t t t w t

Mid-Point (t = ½ ?)Mid-Point (t = ½ ?)2 2 2 2

2 2 2 2

(1 ) 2 (1 ) (1 ) 2 (1 )

(1 ) 2 (1 ) (1 ) 2 (1 )A B c B

A B c B

t w A t t w B t w C t A t t w B t C

t w t t w t w t t t w t

1 1 1 2

2 2(1 ) 2(1 )

wt

w w

W very largeW very large2 2 2 2

2 2 2 2

(1 ) 2 (1 ) (1 ) 2 (1 )

(1 ) 2 (1 ) (1 ) 2 (1 )A B c B

A B c B

t w A t t w B t w C t A t t w B t C

t w t t w t w t t t w t

1 1 1 2

2 2(1 ) 2(1 )

wt

w w

(0,0;1)(0,0;1)

(0,1;>>1)(0,1;>>1) (1,1;1)(1,1;1)

W = 1 (non-rational spline)W = 1 (non-rational spline)2 2 2 2

2 2 2 2

(1 ) 2 (1 ) (1 ) 2 (1 )

(1 ) 2 (1 ) (1 ) 2 (1 )A B c B

A B c B

t w A t t w B t w C t A t t w B t C

t w t t w t w t t t w t

1 1 1 2

2 2(1 ) 2(1 )

wt

w w

(0,0;1)(0,0;1)

(0,1;1)(0,1;1) (1,1;1)(1,1;1)

Polynomial spline:Polynomial spline:parabolic arcparabolic arc

W < 1W < 12 2 2 2

2 2 2 2

(1 ) 2 (1 ) (1 ) 2 (1 )

(1 ) 2 (1 ) (1 ) 2 (1 )A B c B

A B c B

t w A t t w B t w C t A t t w B t C

t w t t w t w t t t w t

1 1 1 2

2 2(1 ) 2(1 )

wt

w w

(0,0;1)(0,0;1)

(1,1;1)(1,1;1)

Rational spline:Rational spline:result depends on wresult depends on w

(0,1;w)(0,1;w)

W = 0W = 02 2 2 2

2 2 2 2

(1 ) 2 (1 ) (1 ) 2 (1 )

(1 ) 2 (1 ) (1 ) 2 (1 )A B c B

A B c B

t w A t t w B t w C t A t t w B t C

t w t t w t w t t t w t

1 1 1 2

2 2(1 ) 2(1 )

wt

w w

(0,0;1)(0,0;1)

(1,1;1)(1,1;1)

Straight LineStraight Line

(0,1;w)(0,1;w)

OutlineOutline

Rational Splines

Quadratic rational splines

NURBs (briefly)

Parametric patches (briefly)

NURBSNURBS

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 CurvePolar 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

NURBSNURBS

OutlineOutline

Rational Splines

Quadratic rational splines

NURBs (briefly)

Parametric patches (briefly)

Parametric PatchesParametric Patches

Each patch is defined by blending control points

FvDFH Figure 11.44FvDFH Figure 11.44

Parametric PatchesParametric Patches

Point Q(u,v) on the patch is the tensor product of curves defined by the control points

Watt Figure 6.21Watt Figure 6.21

Q(u,v)Q(u,v)

Q(0,0)Q(0,0)

Q(1,0)Q(1,0)

Q(0,1)Q(0,1)Q(1,1)Q(1,1)

Parametric Bicubic PatchesParametric Bicubic Patches

Point Q(u,v) defined by combining control points with polynomial blending functions:

1,1 1,2 1,3 1,4

2,1 2,2 2,3 2,4

3,1 3,2 3,3 3,4

4,1 4,2 4,3 4,4

( , )

P P P P

P P P PQ u v

P P P P

P P P P

T TUM M V

1,1 1,2 1,3 1,4

2,1 2,2 2,3 2,4

3,1 3,2 3,3 3,4

4,1 4,2 4,3 4,4

( , )

P P P P

P P P PQ u v

P P P P

P P P P

T TUM M V

Where M is a matrix describing the blending functionsWhere M is a matrix describing the blending functionsfor a parametric cubic curve (e.g., Bezier, B-spline, etc.)for a parametric cubic curve (e.g., Bezier, B-spline, etc.)

3 2 1u u uU 3 2 1u u uU

3 2 1v v vV 3 2 1v v vV

SummarySummary

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)