Thanks to visit codestin.com
Credit goes to www.scribd.com

0% found this document useful (0 votes)
21 views92 pages

06 Geometry Slides

Uploaded by

muradakhter
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
21 views92 pages

06 Geometry Slides

Uploaded by

muradakhter
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 92

Lecture 6:

Introduction to Geometry
Interactive Computer Graphics
Stanford CS248, Winter 2019
Increasing the complexity of our models
Transformations Geometry Materials, lighting, ...

Stanford CS248, Winter 2019


What is geometry?
“Earth” “measure”

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.

Plato: “...the earth is in appearance like one of those balls which have leather coverings in twelve pieces...”
Stanford CS248, Winter 2019
Examples of geometry

Photo of original Utah teapot


(now sitting in Computer History
Museum in Mountain View)

Martin Newell’s early teapot renderings


(Martin created teapot model in 1975 using
Bezier curves)
Stanford CS248, Winter 2019
Examples of geometry

Cornell Box: Originally created in 1984


(This image was rendered in 1985 by Cohen and Greenberg) Stanford CS248, Winter 2019
Examples of geometry

Photograph of scanned statue


(Statue purchased by Greg Turk at
a store on University Ave in 1994)

The Stanford Bunny


(Mesh created by reconstruction from laser scans) Stanford CS248, Winter 2019
Examples of geometry
Laser scan of Michelangelo’s David
(created as part of Stanford’s
Digital Michelangelo project in
1999)

Stanford CS248, Winter 2019


Examples of geometry

Curly hair in Pixar’s “Brave” (2012)


Stanford CS248, Winter 2019
Examples of geometry

Stanford CS248, Winter 2019


Examples of geometry

Stanford CS248, Winter 2019


Examples of geometry

Stanford CS248, Winter 2019


Examples of geometry

Stanford CS248, Winter 2019


Examples of geometry

Stanford CS248, Winter 2019


Examples of geometry

Stanford CS248, Winter 2019


Examples of geometry

Stanford CS248, Winter 2019


Examples of geometry

Stanford CS248, Winter 2019


What’s the best way to encode geometry
on a computer?

Stanford CS248, Winter 2019


No one “best” choice—geometry is hard!

“I hate meshes.
I cannot believe how hard this is.
Geometry is hard.”
—David Baraff
Senior Research Scientist
Pixar Animation Studios

Slide cribbed from Keenan Crane, Slide cribbed from Jeff Erickson. Stanford CS248, Winter 2019
Many ways to digitally encode geometry
EXPLICIT
- point cloud
- polygon mesh
- subdivision, NURBS
- ...
IMPLICIT
- level set
- algebraic surface
- L-systems
- ...
Each choice best suited to a different task/type of geometry
Stanford CS248, Winter 2019
“Implicit” representations of geometry
Points aren’t known directly, but satisfy some relationship
E.g., unit sphere is all points such that x2+y2+z2=1
More generally, f(x,y,z) = 0
f(x,y)
+1
f=0

-1
Stanford CS248, Winter 2019
Many implicit representations in graphics
algebraic surfaces
constructive solid geometry
level set methods
blobby surfaces
fractals
...

(Will see some of these a bit later.)


Stanford CS248, Winter 2019
But first, let’s play a game:

I’m thinking of an implicit surface


f(x,y,z)=0

Find any point on it.

Stanford CS248, Winter 2019


Give up?
My function was f(x,y,z) = x - 1.5 (a plane):
y

( 1.5, 0, 0 )

z x

Implicit surfaces make some tasks hard (like sampling).


Stanford CS248, Winter 2019
Let’s play another game.

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


2 2 2

I want to see if a point is inside it.

Stanford CS248, Winter 2019


Check if this point is inside the unit sphere
How about the point ( 3/4, 1/2, 1/4 )?
9/16 + 4/16 + 1/16 = 7/8 y
7/8 < 1
YES.
( 3/4, 1/2, 1/4 )

z x

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


Stanford CS248, Winter 2019
Recall: implicit form of a line
Easy to test if a point is on the “positive” or negative side of the line

V
P1

P0
L(x, y) = V · N = Ax + By + C
L(x, y) > 0 (for points on the shaded side of the line)
L(x, y) = 0 (for points on the line)
Stanford CS248, Winter 2019
“Explicit” representations of geometry
All points are given directly
E.g., points on sphere are

More generally:

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


Stanford CS248, Winter 2019
6 aspect aspect ⇥ tan(✓/2)aspect ⇥
7 tan(✓/2)
f =tan(✓/2)
cot(✓/2)
6 0 f 0 7 0
“Explicit” representations
P= 6
aspect
4 0 0 of geometryf = cot(✓/2)
zf ar+znear
znear zf ar
7
f = cot(✓/2)
2⇥zf ar⇥znear
znear zf ar 5
f
0 0 13 0
0 0 0
x3
spect More
x4 x generally:
5x1 xx62 xx37 xx
4 8 x5
7 x6 x7 x8
0 f 0 0 x
71 x2 x3 x4 x5 x6 x7 x8
2⇥zf ar⇥znear 7
0 0 Example:
znear zf ar a triangle
zf ar+znear
znear zf ar 5
0 0 1 0 tan(✓/2)
tan(✓/2) a b aspect
c tan(✓/2)
aspect aspect
2 f x = f ( , ) 3= a + (b a) + (c a)
aspect 0 03
2 0 3
6 f
0 077 0
0 a b c 6
0P = 6
0 f0 0 aspect 0
t 67
zf ar+znear 2⇥zf ar⇥znear 7 7
4 0 0
0 znear6 zf ar f zf ar0 5 0 7
f 0 0 P = 67 znear
zf ar+znear 2⇥zf ar⇥znear 7
zf ar+znear 0
2⇥zf 0
ar⇥znear 417 0 0 0znear zf ar 5
0 bznear
a czf ara znear zf ar 5 znear zf ar
0 0 1 0
0 1 0
x
Triangles:
a b c

a b c
a b c b a c a
Stanford CS248, Winter 2019
Many explicit representations in graphics
triangle meshes
polygon meshes
subdivision surfaces
NURBS
point clouds
...

(Will see some of these a bit later.)


Stanford CS248, Winter 2019
But first, let’s play a game:

I’ll give you an explicit surface.

You give me some points on it.

Stanford CS248, Winter 2019


Sampling an explicit surface
My surface is f( u, v ) = ( 1.5, u, v ).
Just plug in any values (u,v)! y

z x

Explicit surfaces make some tasks easy (like sampling).


Stanford CS248, Winter 2019
Let’s play another game.

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

I want to see if a point is inside it.

Stanford CS248, Winter 2019


Check if this point is inside the torus
My surface is f(u,v) = ( 2+cos(u))cos(v), 2+cos(u))sin(v), sin(u) )
How about the point (1,√3,5/4)? y

...NO!

( 1, √3, 5/4 )

z x

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


Stanford CS248, Winter 2019
CONCLUSION:
Some representations work better than
others—depends on the task!

Stanford CS248, Winter 2019


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

Let’s take a look at some common


representations used in computer graphics.

Stanford CS248, Winter 2019


Algebraic surfaces (implicit)
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 for complex shapes!


Stanford CS248, Winter 2019
Constructive solid geometry (implicit)
Build more complicated shapes via Boolean operations
Basic operations:
UNION
DIFFERENCE
INTERSECTION

Then build more


complex expressions:

Stanford CS248, Winter 2019


Blobby surfaces (implicit)
Instead of booleans, gradually blend surfaces together:

Easier to understand in 2D:


2
|x p|
p (x) := e (Gaussian centered at p)

(Sum of Gaussians centered at different points)

f = 0.5 f = 0.4 f = 0.3


Stanford CS248, Winter 2019
Blending distance functions (implicit)
A distance function gives distance to closest point on object
Can blend any two distance functions d1, d2:

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


d1 (x) 2
d2 (x) 2 1
f (x) := e +e
2
Appearance depends on exactly how we combine functions
Q: How do we implement a simple Boolean union?
A: Just take the minimum:
Stanford CS248, Winter 2019
Scene of pure distance functions (not easy!)
TODO: Iñigo Quilez example; link

See http://iquilezles.org/www/material/nvscene2008/nvscene2008.htm
Stanford CS248, Winter 2019
Level set methods (implicit)
Implicit surfaces have some nice features (e.g., merging/splitting)
But, hard to describe complex shapes in closed form
Alternative: store a grid of values approximating function
-.55 -.45 -.35 -.30 -.25

-.30 -.25 -.20 -.10 -.10

-.20 -.15 -.10 .10 .15

-.05 .10 .05 .25 .35

.15 .20 .25 .55 .60

Surface is found where interpolated values equal zero


Provides much more explicit control over shape (like a texture)
Often demands sophisticated filtering (trilinear, tricubic…)
Stanford CS248, Winter 2019
Level sets from medical data (CT, MRI, etc.)
Level sets encode, e.g., constant tissue density

Stanford CS248, Winter 2019


Level sets in physical simulation
Level set encodes distance to air-liquid boundary

See http://physbam.stanford.edu
Stanford CS248, Winter 2019
Level set storage
Drawback: storage for 2D surface is now O(n3)
Can reduce cost by storing only a narrow band of distances
around surface:

In this figure:
red = clearly within water green = regions where we store level set values to encode surface
blue = clearly outside water Stanford CS248, Winter 2019
Fractals (implicit)
No precise definition; exhibit self-similarity, detail at all scales
New “language” for describing natural phenomena
Hard to control shape!

Stanford CS248, Winter 2019


Mandelbrot set - definition
For each point c in the plane:
- double the angle
- square the magnitude
- add the original point c
- repeat

If the point remains bounded (never goes to ∞), it’s in the set.
Stanford CS248, Winter 2019
Mandelbrot set - examples

starting point
(converges)

(periodic)

(diverges)

Stanford CS248, Winter 2019


Mandelbrot set - zooming in
For each point c in the plane:
- double the angle, square the magnitude
- add the original point c
- repeat
If the point remains bounded (never goes to ∞), it’s in the set
In complex numbers:

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


Stanford CS248, Winter 2019
Iterated function systems

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


Stanford CS248, Winter 2019
Implicit representations - pros and cons
Pros:
- 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

Stanford CS248, Winter 2019


What about explicit representations?

Stanford CS248, Winter 2019


Point cloud (explicit)
Easiest representation: list of points (x,y,z)
Often augmented with normals
Easily represent any kind of geometry
Useful for LARGE datasets (>>1 point/pixel)
Hard to interpolate undersampled regions
Hard to do processing / simulation / …

Stanford CS248, Winter 2019


Point cloud via laser scanning

Image Credit: 3Dling Stanford CS248, Winter 2019


Another example: Microsoft XBox 360 Kinect

Image credit: iFixIt

Illuminant RGB Sensor Monochrome Infrared


(Infrared Laser + diffuser) 640x480 Sensor

Stanford CS248, Winter 2019


Structured light
System: one light source emitting known beam + one camera measuring scene appearance
If the scene is at reference plane, image that will be recorded by camera is known
(correspondence between pixel in recorded image and scene point is known)
Reference plane

zref

b
Known light f
source

Single spot illuminant is inefficient! x d


(must “scan” scene with spot to get depth, so high latency to retrieve a single depth image) Stanford CS248, Winter 2019
Infrared image of Kinect illuminant output

Credit: www.futurepicture.org
Stanford CS248, Winter 2019
Infrared image of Kinect illuminant output

Credit: www.futurepicture.org
Stanford CS248, Winter 2019
Polygon mesh (explicit)
Store vertices and polygons (most often triangles or quads)
Easier to do processing/simulation, adaptive sampling
More complicated data structures
Perhaps most common representation in graphics

(Much more about polygon meshes in upcoming lectures!)


Stanford CS248, Winter 2019
Triangle mesh (explicit) 3

Store vertices as triples of coordinates (x,y,z)


Store triangles as triples of indices (i,j,k)
E.g., tetrahedron: VERTICES TRIANGLES 2
x y z i j k
0: -1 -1 -1 0 2 1 0
1: 1 -1 1 0 3 2
2: 1 1 -1 3 0 1
3: -1 1 1 3 1 2
1
Use linear interpolation to define points inside triangles:
c
v f(u,v)

a b

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


u Stanford CS248, Winter 2019
Linear interpolation of samples (in 1D)

f1

f0

x0 x x1
f (t) = (1 t)f0 + tf1
x x0
t=
x1 x0 Stanford CS248, Winter 2019
Can think of linear interpolation as linear
combination of two functions
Weights are given by the two values (f0 and f1) being interpolated
f1

f0 t

(1 t)

x0 x x1
f (t)f=
(t)(1= (1t)f0t)f
+ 0tf+
1 tf1

Stanford CS248, Winter 2019


Problem with piecewise linear interpolation:
derivates not continuous
f1
f2
f0

x0 x1 x2

Stanford CS248, Winter 2019


Smooth interpolation?
continuous
first derivative
f1
f2
f0

x0 x1 x2

Stanford CS248, Winter 2019


Bernstein basis
Why limit ourselves to just linear interpolation?
More flexibility by using higher-order polynomials
Instead of usual basis (1, x, x2, x3, ...), use Bernstein basis:
degree “n choose k”
0≤x≤1

k=0,…,n

1
2

1
1
2
Stanford CS248, Winter 2019
Bézier curves (explicit)
A Bézier curve is a curve expressed in the Bernstein basis:
control points

For n=1, just get a line segment!


For n=3, get “cubic Bézier”:
Important features:
1. interpolates endpoints
2. tangent to end segments
3. contained in convex hull (nice for rasterization)

Stanford CS248, Winter 2019


Piecewise Bézier curves (explicit)
More interesting shapes: piece together many Bézier curves
Widely-used technique (Illustrator, fonts, SVG, etc.)

Formally, piecewise Bézier curve:


piecewise Bézier

single Bézier

Stanford CS248, Winter 2019


Vector fonts

The Quick Brown


Fox Jumps Over
The Lazy Dog
ABCDEFGHIJKLMNOPQRSTUVWXYZ
abcdefghijklmnopqrstuvwxyz 0123456789

credit: Randall Branding

Baskerville font - represented as cubic Bézier splines


Stanford CS248, Winter 2019
Bézier curves — tangent continuity
To get “seamless” curves, want points and tangents to line up:

Ok, but how?


Each curve is cubic: u3p0 + 3u2(1-u)p1 + 3u(1-u)2p2 + (1-u)3p3
Q: How many constraints vs. degrees of freedom?
Q: Could you do this with quadratic Bézier? Linear Bézier?

Stanford CS248, Winter 2019


Tensor product
Can use a pair of curves to get a surface
Value 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”):

u
v

Stanford CS248, Winter 2019


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

1
2

1
1
2

Stanford CS248, Winter 2019


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

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

Stanford CS248, Winter 2019


Notice anything fishy about the last
picture?

Stanford CS248, Winter 2019


Bézier patches are too simple
Notice that exactly four patches
meet around every vertex!

In practice, this is far


too constrained.

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

Stanford CS248, Winter 2019


Spline patch schemes
There 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!

Stanford CS248, Winter 2019


Subdivision (explicit or implicit?)
Alternative starting point for curves/surfaces: subdivision
Start with control curve
Insert new vertex at each edge midpoint
Update vertex positions according to fixed rule
For careful choice of averaging rule, yields smooth curve
- Some subdivision schemes correspond to well-known spline
schemes!

Slide cribbed from Don Fussell. Stanford CS248, Winter 2019


Subdivision surfaces (explicit)
Start with coarse polygon mesh (“control cage”)
Subdivide each element
Update vertices via local averaging
Many possible rule:
- Catmull-Clark (quads)
- Loop (triangles)
- ...
Common issues:
- interpolating or approximating?
- continuity at vertices?
Easier than splines for modeling; harder to evaluate pointwise
Stanford CS248, Winter 2019
Subdivision in action (Pixar’s “Geri’s Game”)

Stanford CS248, Winter 2019


Surfaces and manifolds

Stanford CS248, Winter 2019


Manifold assumption
I’ll now introduce the idea of manifold geometry
Can be hard to understand motivation at first!
- Will become more clear next class
v

Stanford CS248, Winter 2019


Smooth surfaces
Intuitively, a surface is the boundary or “shell” of an object
(Think about the candy shell, not the chocolate.)
Surfaces are manifold:
- If you zoom in far enough (at any point) looks like a plane*
- E.g., the Earth from space vs. from the ground

*…or can easily be flattened into the plane, without cutting or ripping. Stanford CS248, Winter 2019
Why is the manifold property valuable?
Makes life simple: all surfaces look the same (at least locally)
Gives us coordinates! (at least locally)

Stanford CS248, Winter 2019


Isn’t every shape manifold?
No, for instance:

Center point never looks like the plane, no matter how close we get.
Stanford CS248, Winter 2019
More examples of smooth surfaces
Which of these shapes are manifold?

Stanford CS248, Winter 2019


A manifold polygon mesh has fans, not fins
For polygonal surfaces just two easy conditions to check:
1. Every edge is contained in only two polygons (no “fins”)
2. The polygons containing each vertex make a single “fan”

YES YES

NO

NO

Stanford CS248, Winter 2019


What about boundary?
The boundary is where the surface “ends.”
E.g., waist and ankles on a pair of pants.
Locally, looks like a half disk
Globally, each boundary forms a loop

YES

Polygon mesh:
- one polygon per boundary edge
- boundary vertex looks like “pacman”
Stanford CS248, Winter 2019
Measurements of surfaces

Stanford CS248, Winter 2019


Surface tangent

Stanford CS248, Winter 2019


Surface normal (N) is orthogonal to all tangents

Stanford CS248, Winter 2019


A common visualization of normals
Encode normal direction as RGB color as difference from gray
R = 0.5 + 0.5 N.x
Notice: scale and bias normal values so we can represent
G = 0.5 + 0.5 N.y
negative components of normal as valid colors
B = 0.5 + 0.5 N.z

Image credit: https://www.3dgep.com/forward-plus/ Stanford CS248, Winter 2019


Curvature is change in normal

Stanford CS248, Winter 2019


Radius of curvature

curvature

Stanford CS248, Winter 2019


Acknowledgements
Thanks to Keenan Crane and Ren Ng for slide materials

Stanford CS248, Winter 2019

You might also like