Introduction to Geometry - Computer...

Preview:

Citation preview

Computer GraphicsCMU 15-462/15-662

Introduction to Geometry

CMU 15-462/662, Fall 2015

A1 Due Yesterday, A2 Out Very Soon!Start building up “Scotty3D”; first part is 3D modeling

Scotty3D

(Start from the cube you described in Lecture 1!)

CMU 15-462/662, Fall 2015

3D Modeling CompetitionWinners will get their models 3D printed!

(This mesh was created in Scotty3D in about 5 minutes... you can do much better!)

CMU 15-462/662, Fall 2015

Increasing the complexity of our modelsMaterials, lighting, ...GeometryTransformations

CMU 15-462/662, Fall 2015

What is geometry?

Ceci n'est pas géométrie.See: Paul Lockhart, “A Mathematician’s Lament “

CMU 15-462/662, Fall 2015

What is geometry?

ge•om•et•ry /jēˈämətrē/ n.1. The study of shapes, sizes, patterns, and positions.2. The study of spaces where some quantity (lengths, angles, etc.) can be measured.

“Earth” “measure”

Plato: “...the earth is in appearance like one of those balls which have leather coverings in twelve pieces...”

CMU 15-462/662, Fall 2015

How can we describe geometry?IMPLICIT EXPLICIT

CURVATURE

LINGUISTIC“unit circle”

SYMMETRICrotate

DYNAMICTOMOGRAPHIC

(constant density)

DISCRETE

n ➞ ∞

CMU 15-462/662, Fall 2015

Given all these options, what’s the best way to encode geometry on a computer?

CMU 15-462/662, Fall 2015

Examples of geometry

CMU 15-462/662, Fall 2015

Examples of geometry

CMU 15-462/662, Fall 2015

Examples of geometry

CMU 15-462/662, Fall 2015

Examples of geometry

CMU 15-462/662, Fall 2015

Examples of geometry

CMU 15-462/662, Fall 2015

Examples of geometry

CMU 15-462/662, Fall 2015

Examples of geometry

CMU 15-462/662, Fall 2015

Examples of geometry

CMU 15-462/662, Fall 2015

Examples of geometry

CMU 15-462/662, Fall 2015

It’s a Jungle Out There!

CMU 15-462/662, Fall 2015

No one “best” choice—geometry is hard!

“I hate meshes. I cannot believe how hard this is. Geometry is hard.”

—David BaraffSenior Research ScientistPixar Animation Studios

Slide cribbed from Jeff Erickson.

CMU 15-462/662, Fall 2015

Many ways to digitally encode geometryEXPLICIT- point cloud- polygon mesh- subdivision, NURBS- ...IMPLICIT- level set- algebraic surface- L-systems- ...Each choice best suited to a different task/type of geometry

CMU 15-462/662, Fall 2015

“Implicit” Representations of GeometryPoints aren’t known directly, but satisfy some relationshipE.g., unit sphere is all points x such that x2+y2+z2=1More generally, f(x,y,z) = 0

-1

+1f(x,y)

0

f = 0

CMU 15-462/662, Fall 2015

Many implicit representations in graphicsalgebraic surfacesconstructive solid geometrylevel set methodsblobby surfacesfractals...

(Will see some of these a bit later.)

CMU 15-462/662, Fall 2015

But first, let’s play a game:

I’m thinking of an implicit surface f(x,y,z)=0.

Find any point on it.

CMU 15-462/662, Fall 2015

Give up?

y

xz

( 1.23, 0, 0 )

My function was f(x,y,z) = -1.23 (a plane):

Implicit surfaces make some tasks hard (like sampling).

CMU 15-462/662, Fall 2015

Let’s play another game.

I have a new surface f(x,y,z) = x2 + y2 + z2 - 1

I want to see if a point is inside it.

CMU 15-462/662, Fall 2015

Check if this point is inside the unit sphere

xz

y

Implicit surfaces make other tasks easy (like inside/outside tests).

9/16 + 4/16 + 1/16 = 7/8

7/8 < 1

YES.

How about the point ( 3/4, 1/2, 1/4 )?

( 3/4, 1/2, 1/4 )

CMU 15-462/662, Fall 2015

“Explicit” Representations of GeometryAll points are given directlyE.g., points on sphere are

More generally:

(Might have a bunch of these maps, e.g., one per triangle!)

CMU 15-462/662, Fall 2015

Many explicit representations in graphicstriangle meshespolygon meshessubdivision surfacesNURBSpoint clouds...

(Will see some of these a bit later.)

CMU 15-462/662, Fall 2015

But first, let’s play a game:

I’ll give you an explicit surface.

You give me some points on it.

CMU 15-462/662, Fall 2015

Sampling an explicit surface

y

xz

My surface is f( u, v ) = ( 1.23, u, v ).

Explicit surfaces make some tasks easy (like sampling).

Just plug in any values (u,v)!

CMU 15-462/662, Fall 2015

Let’s play another game.

I have a new surface f(u,v).

I want to see if a point is inside it.

CMU 15-462/662, Fall 2015

Check if this point is inside the torus

xz

y

Explicit surfaces make other tasks hard (like inside/outside tests).

My surface is f(u,v) = ( 2+cos(u))cos(v), 2+cos(u))sin(v), sin(u) )

...NO!

( 1, √3, 5/4 )

How about the point (1,√3,5/4)?

CMU 15-462/662, Fall 2015

CONCLUSION:Some representations work better

than others—depends on the task!

CMU 15-462/662, Fall 2015

Different representations will also be better suited to different types of geometry.

Let’s take a look at some common representations used in computer graphics.

Surface is zero set of a polynomial in x, y, z (“algebraic variety”)Examples:

What about more complicated shapes?

Very hard to come up with polynomials! CMU 15-462/662, Fall 2015

Algebraic Surfaces (Implicit)

CMU 15-462/662, Fall 2015

Constructive Solid Geometry (Implicit)Build more complicated shapes via Boolean operationsBasic operations:

Then chain together expressions:

UNION

INTERSECTION

DIFFERENCE

Instead of Booleans, gradually blend surfaces together:

Easier to understand in 2D:

CMU 15-462/662, Fall 2015

Blobby Surfaces (Implicit)

(Gaussian centered at p)

(Sum of Gaussians centered at different points)

CMU 15-462/662, Fall 2015

Blending Distance Functions (Implicit)A distance function gives distance to closest point on objectCan blend any two distance functions d1, d2:

Similar strategy to points, though many possibilities. E.g.,

Appearance depends on exactly how we combine functionsQ: How do we implement a simple Boolean union?A: Just take the minimum:

CMU 15-462/662, Fall 2015

Scene of pure distance functions (not easy!)

See http://iquilezles.org/www/material/nvscene2008/nvscene2008.htm

CMU 15-462/662, Fall 2015

Level Set Methods (Implicit)Implicit surfaces have some nice features (e.g., merging/splitting)But, hard to describe complex shapes in closed formAlternative: store a grid of values approximating function

Surface is found where interpolated values equal zeroProvides much more explicit control over shape (like a texture)

-.45

-.25

-.15

.10

.20

-.35

-.20

-.10

.05

.25

-.30

-.10

.10

.25

.55

-.25

-.10

.15

.35

.60

-.55

-.30

-.20

-.05

.15

CMU 15-462/662, Fall 2015

Level Sets from Medical Data (CT, MRI, etc.)Level sets encode, e.g., constant tissue density

CMU 15-462/662, Fall 2015

Level Sets in Physical SimulationLevel set encodes distance to air-liquid boundary

See http://physbam.stanford.edu

CMU 15-462/662, Fall 2015

Level Set StorageDrawback: storage for 2D surface is now O(n3)Can reduce cost by storing only a narrow band around surface:

CMU 15-462/662, Fall 2015

Fractals (Implicit)No precise definition; exhibit self-similarity, detail at all scalesNew “language” for describing natural phenomenaHard to control shape!

CMU 15-462/662, Fall 2015

Mandelbrot Set - DefinitionFor each point c in the plane:- double the angle- square the magnitude- add the original point c- repeatComplex version:- Replace z with z2+c

If the point remains bounded (never goes to ∞), it’s in the set.

CMU 15-462/662, Fall 2015

Mandelbrot Set - Examples

starting point(converges)

(periodic)

(diverges)

CMU 15-462/662, Fall 2015

Mandelbrot Set - Zooming In

(Colored according to how quickly each point diverges/converges.)

CMU 15-462/662, Fall 2015

Iterated Function Systems

Scott Draves (CMU Alumnus) - see http://electricsheep.org

CMU 15-462/662, Fall 2015

Implicit Representations - Pros & ConsPros:- description can be very compact (e.g., a polynomial)- easy to determine if a point is in our shape (just plug it in!)- other queries may also be easy (e.g., distance to surface)- for simple shapes, exact description/no sampling error- easy to handle changes in topology (e.g., fluid)Cons:- expensive to find all points in the shape (e.g., for drawing)- very difficult to model complex shapes

CMU 15-462/662, Fall 2015

What about explicit representations?

CMU 15-462/662, Fall 2015

Point Cloud (Explicit)Easiest representation: list of points (x,y,z)Often augmented with normalsEasily represent any kind of geometryUseful for LARGE datasets (>>1 point/pixel)Difficult to draw in undersampled regionsHard to do processing / simulation

CMU 15-462/662, Fall 2015

Polygon Mesh (Explicit)Store vertices and polygons (most often triangles or quads)Easier to do processing/simulation, adaptive samplingMore complicated data structuresPerhaps most common representation in graphics

(Much more about polygon meshes in upcoming lectures!)

CMU 15-462/662, Fall 2015

Triangle Mesh (Explicit)Store vertices as triples of coordinates (x,y,z)Store triangles as triples of indices (i,j,k)E.g., tetrahedron:

0

1

2

3

x y z0: -1 -1 -11: 1 -1 12: 1 1 -13: -1 1 1

VERTICESi j k0 2 10 3 23 0 13 1 2

TRIANGLES

Can think of triangle as affine map from plane into space:

uf(u,v) = a + u(b-a) + v(c-a)

v f(u,v)

a b

c

CMU 15-462/662, Fall 2015

Bernstein BasisWhy limit ourselves to just affine functions?More flexibility by using higher-order polynomialsInstead of usual basis (1, x, x2, x3, ...), use Bernstein basis:

“n choose k”

k=0,…,n

degree0≤x≤1

12

1

12

1

A Bézier curve is a curve expressed in the Bernstein basis:

CMU 15-462/662, Fall 2015

Bézier Curves (Explicit)

control points

For n=1, just get a line segment!For n=3, get “cubic Bézier”:Important features:1. interpolates endpoints2. tangent to end segments3. contained in convex hull (nice for rasterization)

CMU 15-462/662, Fall 2015

Higher-order Bézier Curves?What if we want a more interesting curve?High-degree Bernstein polynomials don’t interpolate well:

Very hard to control!

CMU 15-462/662, Fall 2015

Piecewise Bézier Curves (Explicit)Instead, piece together many low-order Bézier curvesWidely-used technique (Illustrator, fonts, SVG, etc.)

Formally, piecewise Bézier curve:piecewise Bézier

single Bézier

CMU 15-462/662, Fall 2015

Bézier Curves — tangent continuityTo get “seamless” curves, want tangents to line up:

Ok, but how?Each curve is cubic: u3p0 + 3u2(1-u)p1 + 3u(1-u)2p2 + (1-u)3p3

Want endpoints of each segment to meetWant tangents at endpoints to meetQ: How many constraints vs. degrees of freedom?Q: Could you do this with quadratic Bézier? Linear Bézier?

CMU 15-462/662, Fall 2015

Tensor ProductCan use a pair of curves to get a surfaceValue at any point (u,v) given by product of a curve f at u and a curve g at v (sometimes called the “tensor product”):

CMU 15-462/662, Fall 2015

Bézier PatchesBézier patch is sum of (tensor) products of Bernstein bases

12

1

12

1

CMU 15-462/662, Fall 2015

Bézier SurfaceJust as we connected Bézier curves, can connect Bézier patches to get a surface:

Q: Can we always get tangent continuity? (Think: how many constraints? How many degrees of freedom?)

Very easy to draw: just dice each patch into regular (u,v) grid!

CMU 15-462/662, Fall 2015

Notice anything fishy about the last picture?

CMU 15-462/662, Fall 2015

Bézier Patches are Too SimpleNotice that exactly four patches meet around every vertex!

In practice, far too constrained.

To make interesting shapes (with good continuity), we need patches that allow more interesting connectivity...

CMU 15-462/662, Fall 2015

Spline patch schemesThere are many alternatives!NURBS, Gregory, Pm, polar…Tradeoffs:- degrees of freedom- continuity- difficulty of editing- cost of evaluation- generality- …As usual: pick the right tool for the job!

CMU 15-462/662, Fall 2015

Subdivision (Explicit or Implicit?)Alternative starting point for curves/surfaces: subdivisionStart with control curveInsert new vertex at each edge midpointUpdate vertex positions according to fixed ruleFor careful choice of averaging rule, yields smooth curve- Some subdivision schemes correspond to well-known

spline schemes!

Slide cribbed from Don Fussell.

CMU 15-462/662, Fall 2015

Subdivision Surfaces (Explicit)Start with coarse polygon mesh (“control cage”)Subdivide each elementUpdate vertices via local averagingMany possible rule:- Catmull-Clark (quads)- Loop (triangles)- ...Common issues:- interpolating or approximating?- continuity at vertices?Easier than splines for modeling; harder to evaluate pointwise

CMU 15-462/662, Fall 2015

Subdivision in Action (Pixar’s “Geri’s Game”)

CMU 15-462/662, Fall 2015

Next time: Curves, Surfaces, & Meshes

Recommended