+ All Categories
Home > Documents > Advanced Graphics Lecture Four “Nobody expects the geometric inquisition” Alex Benton,...

Advanced Graphics Lecture Four “Nobody expects the geometric inquisition” Alex Benton,...

Date post: 17-Dec-2015
Category:
Upload: gwenda-hutchinson
View: 217 times
Download: 0 times
Share this document with a friend
Popular Tags:
36
Advanced Graphics Lecture Four “Nobody expects the geometric inquisition” Alex Benton, University of Cambridge – A.Benton@damtp. Supported in part by Googl
Transcript

Advanced Graphics

Lecture Four

“Nobody expects the geometric inquisition”

Alex Benton, University of Cambridge – [email protected]

Supported in part by Google UK, Ltd

Querying your geometry

Given a polygonal model, how might you find…• the normal at each vertex?

• the curvature at each vertex?

• the convex hull?

• the bounding box?

• the center of mass?

Querying your geometry

A recurring theme here will be,“The polygons are not the shape: the polygons approximate

the surface of the shape.”

Some questions from past lectures (e.g. ray-polygon intersection) were about the actual polygons.

But other questions, like the normal at a vertex, are really about approximating the underlying surface as closely as possible.

Normal at a vertex

Expressed as a limit, The normal of surface S at point P is the limit of the

cross-product between two (non-collinear) vectors from P to the set of points in S at a distance r from P as r goes to zero. [Excluding orientation.]

Normal at a vertex

Using the limit definition, is the ‘normal’ to a discrete surface necessarily a vector?• The normal to the surface at any point on a face is a

constant vector.

• The ‘normal’ to the surface at any edge is an arc swept out on a unit sphere between the two normals of the two faces.

• The ‘normal’ to the surface at a vertex is a space swept out on the unit sphere between the normals of all of the adjacent faces.

Finding the normal at a vertex

Method 1: Take the average of the normals of surrounding polygons

Problem: splitting one adjacent face into 10,000 shards would skew the average

Finding the normal at a vertex

Method 2: Take the weighted average of the normals of surrounding polygons, weighted by the area of each face• 2a: Weight each face

normal by the area of the face divided by the total number of vertices in the face

Problem: Introducing new edges into a neighboring face (and thereby reducing its area) should not change the normal.

Should making a face larger affect the normal to the surface near its corners?• Argument for yes: If the

vertices interpolate the ‘true’ surface, then stretching the surface at a distance could still change the local normals.

Finding the normal at a vertex

Method 3: Take the weighted average of the normals of surrounding polygons, weighted by each polygon’s face angle at the vertex

Face angle: the angle α formed at the vertex v by the vectors to the next and previous vertices in the face F

ii

ii

ii

iii vv

vv

vv

vvvF

1

1

1

11cos),(

F F

F F

NvF

NvFvN

),(

),()(

Note: In this equation, arccos implies a convex polygon. Why?

Note: In this equation, arccos implies a convex polygon. Why?

Gaussian curvature

Informally speaking, the curvature of a surface expresses ‘how flat the surface isn’t’.• One can measure the directions

in which the surface is curving most; these are the directions of principal curvature, k1 and k2.

• The product of k1 and k2 is the scalar Gaussian curvature.

Gaussian curvature can also be defined for discrete (polyhedral) surfaces.

Gaussian curvature on discrete surfaces Formally, the Gaussian curvature of a region of a surface is the

ratio between the area of the unit sphere swept out by the normals of that region and the area of the region itself. The Gaussian curvature of a point is the limit of this ratio as the region tends to zero area.

On a discrete surface, however, normals do not vary smoothly; the normal to a face is constant on the face, and at edges and vertices the normal is—strictly speaking—undefined. Thus normals change instantaneously (as one's point of view travels across an edge from one face to another) or not at all (as one's point of view travels within a face.)

The Gaussian curvature of the surface of any polyhedral mesh is therefore zero everywhere except at the vertices, where it is infinite.

Angle deficit

The angle deficit AD(v) of a vertex v is defined to be two π minus the sum of the face angles of the adjacent faces.

90˚90˚

90˚ AD(v) = 360 ˚ – 270 ˚ = 90 ˚

F

vFvAD ),(2)(

Angle deficit

High angle deficit Low angle deficit Negative angle deficit

Angle deficit

Hmmm…

Genus, Poincaré and the Euler Characteristic

Formally, the genus g of a closed surface is...“a topologically invariant property of

a surface defined as the largest number of nonintersecting simple closed curves that can be drawn on the surface without separating it.”

--mathworld.com Informally, it’s the number of

coffee cup handles in the surface.

Genus 0

Genus 1

Genus, Poincaré and the Euler Characteristic

Given a polyhedral surface S without border where:• V = the number of vertices of S,

• E = the number of edges between those vertices,

• F = the number of faces between those edges,

• χ is the Euler Characteristic of the surface,

the Poincaré Formula states that:

gFEV 22

Genus, Poincaré and the Euler Characteristic

g = 0E = 12F = 6V = 8V-E+F = 2-2g = 2

g = 0E = 15F = 7V = 10V-E+F = 2-2g = 2

g = 1E = 24F = 12V = 12V-E+F = 2-2g = 0

4 faces

3 faces

The Euler Characteristic and angle deficit

Descartes’ Theorem of Total Angle Deficit states that on a surface S with Euler characteristic χ, the sum of the angle deficits of the vertices is 2πχ:

Cube: • χ = 2-2g = 2

• AD(v) = π/2

• 8(π/2) = 4π = 2πχ

Tetrahedron: • χ = 2-2g = 2

• AD(v) = π

• 4(π) = 4π = 2πχ

2)( SvAD

Voronoi diagrams

The Voronoi diagram(1) of a set of points Pi divides space into ‘cells’, where each cell Ci contains the points in space closer to Pi than any other Pj.

The Delaunay triangulation is the dual of the Voronoi diagram: a graph in which an edge connects every Pi which share a common edge in the Voronoi diagram. A Voronoi diagram (dotted lines) and its

dual Delaunay triangulation (solid).(1) AKA “Voronoi tesselation”, “Dirichelet domain”, “Thiessen polygons”, “plesiohedra”, “fundamental areas”, “domain of action”…

(1) AKA “Voronoi tesselation”, “Dirichelet domain”, “Thiessen polygons”, “plesiohedra”, “fundamental areas”, “domain of action”…

Voronoi diagrams Given a set S={p1,p2,…,pn}, the formal

definition of a Voronoi cell C(S,pi) is

C(S,pi)={p є Rd | ||p-pi||<||p-pj||, i≠j} The pi are called the generating points

of the diagram. Where three or more boundary edges

meet is a Voronoi point. Each Voronoi point is at the center of a circle (or sphere, or hypersphere…) which passes through the associated generating points and which is guaranteed to be empty of all other generating points.

(Equi-angularity) The Delaunay triangulation of S will have the largest face angles of any triangulation of S.

Delaunay triangulation applet by Paul Chew ©1997—2007 http://www.cs.cornell.edu/home/chew/Delaunay.html

Delaunay triangulation applet by Paul Chew ©1997—2007 http://www.cs.cornell.edu/home/chew/Delaunay.html

Voronoi diagrams and the medial axis

The medial axis of a surface is the set of all points within the surface equidistant to the two or more nearest points on the surface.

This can be used to extract a skeleton of the surface, for (for example) path-planning solutions, surface deformation, and animation.

Shape Deformation using a Skeleton to Drive Simplex TransformationsIEEE Transaction on Visualization and Computer Graphics, Vol. 14, No. 3, May/June 2008, Page 693-706Han-Bing Yan, Shi-Min Hu, Ralph R Martin, and Yong-Liang Yang

Approximating the Medial Axis from the Voronoi Diagram with a Convergence GuaranteeTamal K. Dey, Wulue Zhao

A Voronoi-Based Hybrid Motion Planner for Rigid BodiesM Foskey, M Garber, M Lin, DManocha       

Finding the Voronoi diagram There are three general classes of

algorithm for computing the Voronoi diagram / Delaunay triangulation:• Divide-and-conquer

• Sweep plane

• Fortune’s algorithm →

• Incremental insertion The Delaunay triangulation of a set

of points in Rn is the planar projection of a convex hull in Rn+1.• From 2D, loft the points

upwards, onto a parabola in 3D. The convex hull of the parabola is the Delaunay triangulation in the plane.

Fortune’s Algorithm for the plane-sweep construction of the Voronoi diagram (Steve Fortune, 1986.)

Fortune’s Algorithm for the plane-sweep construction of the Voronoi diagram (Steve Fortune, 1986.)

Voronoi cells in 3D

Silvan Oesterle, Michael Knauss

Convex hull

The convex hull of a set of points is the unique surface of least area which contains the set.• If a set of infinite half-planes have a finite non-empty

intersection, then the surface of their intersection is a convex polyhedron.

• If a polyhedron is convex then for any two faces A and B in the polyhedron, all points in B which are not in A lie to the same side of the plane containing A.

Every point on a convex hull has non-negative angle deficit.

The faces of a convex hull are always convex.

Finding the convex hull of a set of points

Method 1: For every triple of points in the set, define a plane P. If all other points in the set lie to the same side of P (dot-product test) then add P to the hull; else discard.

Problem 1: this works but it’s O(n4).

Finding the convex hull of a set of points

Method 2:1. Initialize C with a tetrahedron from any four non-colinear

points in the set. Orient the faces of C by taking the dot product of the center of each face with the average of the vertices of C.

2. For each vertex v, 1. For each face f of C,

1. If the dot product of the normal of f with the vector from the center of C to v is positive then v is ‘above’ f.

2. If v is above f then delete f and update a (sorted) list of all new border vertices.

2. Create a new triangular face from v to each pair of border vertices.

Problem 2:• This is O(n2) at best.

Finding the convex hull of a set of points

Method 3: The exterior boundary of the union of

the cells of the Delaunay triangulation of a set of points is its convex hull.

Algorithm:1. Find the Voronoi diagram of your point set

(O(n log n))2. Compute the Delaunay triangulation (2D) or

tetrahedralization (3D)3. Delete all faces of the simplices which aren’t

on the exterior border

The exterior border of the Delaunay triangulation is the convex hull of the point set.

Testing if a point is inside a convex hull

To test whether a point is inside a convex polyhedron, extend the 2D point-in-polygon test into 3D.• For each face, test the dot product of the normal of

the face with a vector from the face to the point. If the dot is ever negative, the point lies outside.

• If you’re storing normals at vertices, the same logic applies.

v1

v2

v3

v…v…

vn

Bounding volumes

Bounding boxes help to quickly accelerate volumetric tests, such as “does the laser hit the cow?”• Works great with scene graphs

• For many applications, bboxes don’t have to be tight

• Often choose fast hit testing over accuracy Axis-aligned bounding boxes

• max and min of x/y/z. Bounding spheres

• Max of radius from some rough center Bounding cylinders

• Common in early FPS games

Minimal bounding circle The minimum bounding circle of a set of points in a plane:

1. Let C be a circle of radius r enclosing all points.2. Let a be the point farthest from the center of C. Shrink r until C

touches a.3. Move the center of C towards a and shrink r until a second point

b lies on C. 4. If (|a-b| < 2r) then:

1. Shrink r until C touches a third point, e.2. If e lies on the opposite hemicircle from a and b, done.3. Else redefine a, b as the two furthest points of {a,b,e} and repeat.

This can clearly be generalized to three dimensions. This algorithm is O(n2). Nimrod Meggido (1983) has given a

more complicated—but linear-time—algorithm.

Oriented bounding boxes (OBBs)

Bounding spheres are rarely optimal. Axis-aligned bounding boxes are also suboptimal;

oriented bounding boxes will fit tighter.• OBBs are not quite so fast to test as AABBs but they have

fewer false positives.

Joe O’Rourke (1985) gives an O(n3) algorithm for finding oriented bounding boxes.

Centroids

The centroid of a surface is the center of mass of the volume enclosed by the surface.

This is not the same as the center of the bounding box.• We’ll assume that the ‘material’ within the

surface is of uniform density.

• We’ll also assume that we have a closed surface (without border.)

Centroids

Method 1: Take the average of all vertices.C = (Σ{v}(v)) / ||{v}||

Problem 1: as with normals, an area of bizarre density would skew the average.

True centroid Average of vertices

Center of bounding box

~50 verts ~500 verts

Centroids Method 2: Take the

average of the centers of the faces of the surface, weighting each by the area of the face.• This method works well for

convex polyhedra.

Problem 2: This is vulnerable to dense ‘wrinkles’ of many polygons packed into a small volume.

The average adult human brain has a surface area of approximately 2,500 cm2, a volume of roughly 1200 cm3, and weighs about 1400g. By comparison, a sphere of similar volume would have a surface area of 546 cm2. Brain image courtesy of Moprhonix.com.

Centroids Method 3a: Use “Monte Carlo”

integration. Find the bounding box of the surface and then choose billions of points at random inside the box; take the average of all those points which fall inside the surface.

Problem 3a: Testing for ‘inside’ is time-consuming (although it can be accelerated; try BSP trees.) Also, this lacks precision. And, frankly, finesse.

Method 3b: Decompose the polyhedron into convex polyhedra, then use method 2 to find the center of each. Average the centers, weighting each point by the volume of its convex polyhedron.

Problem 3b: Convex decomposition is solved, but it’s not trivial.• Convex regions decompose

rapidly to tetrahedra.• Nonconvex regions can be

tricky: tetrahedra may cross.

Centroids Method 4 (Mirtich, 1996):

1. The x, y and z co-ordinates of the center of mass of a volume V can be expressed as an integral over V.

2. Using the Divergence Theorem, which relates the integral over a volume to the integral over the surface of the volume, the co-ordinate integrals can be re-written as integrals over the surface.

3. These surface integrals can be converted to integrals over the projections of each of the polyhedral faces.

4. Using Green’s Theorem, which relates the integral over a planar area to the integral around its boundary, the integrals over the faces can be reduced to integrals over the projections of the edges. The edges are linear.

References Bounding volumes

• http://www.personal.kent.edu/~rmuhamma/Compgeometry/MyCG/CG-Applets/Center/centercli.htm

• M. Dyer and N. Megiddo, "Linear Programming in Low Dimensions." Ch. 38 in Handbook of Discrete and Computational Geometry (Ed. J. E. Goodman and J. O'Rourke). Boca Raton, FL: CRC Press, pp. 669-710, 1997.

• J. O'Rourke, Finding minimal enclosing boxes, Springer Netherlands, 1985 Centroids

• B. Mirtich, “Fast and Accurate Computation of Polyhedral Mass Properties”, Journal of Graphics Tools v.1 n.2, 1996.

• Kim et al, “Fast GPU Computation of the Mass Properties of a General Shape and its Application to Buoyancy Simulation”, The Visual Computer v.2 n.9-11, 2006

• Adapts Mirtich’s method to use modern GPU hardware acceleration

Voronoi diagrams• M. de Berg, O. Cheong, M. van Kreveld, M. Overmars, “Computational Geometry:

Algorithms and Applications”, Springer-Verlag, http://www.cs.uu.nl/geobook/ • http://www.ics.uci.edu/~eppstein/junkyard/nn.html


Recommended