computational geometry

22

Upload: chyna

Post on 25-Feb-2016

54 views

Category:

Documents


1 download

DESCRIPTION

Computational Geometry. Ken George COT 4810 4/19/2008. Computational Geometry. Primary purpose was to further computer graphics, computer-aided design, and computer-aided manufacturing Used in several classical problems, as well - PowerPoint PPT Presentation

TRANSCRIPT

Page 1: Computational Geometry
Page 2: Computational Geometry

Primary purpose was to further computer graphics, computer-aided design, and computer-aided manufacturing

Used in several classical problems, as well Can be applied to any situation where the

problem can be expressed in geometric terms

2

Page 3: Computational Geometry

The field of computational geometry can be divided into three general classes of problems› Static› Geometric Queries› Dynamic

3

Page 4: Computational Geometry

Given input, construct the corresponding output Examples

› Finding the closest pair of points› Determining convex hulls› Polygonal Triangulation› Creating a Voronoi Diagram

4

Page 5: Computational Geometry

Given a set of points, find the closest two Brute force: O(n2)

For every point pFor every point q If p!=q and distance(p, q) < distance(p1,p2)

p1=p p2=q

Recursive Divide and Conquer: O(nlog2n)

5

Page 6: Computational Geometry

CP(X, Y)if X.length <= 3 return the closest pair elseDivide into: XL, YL, XR, YRdL= CP(XL, YL)dR= CP(XR, YR)d = min(dL, dR)Create Y stripd strip= something bigfor all points a in Y strip

for all points b in Y strip “near” aabDist = dist(Y strip[a], Y strip[b])if abDist = d strip thend strip= abDist

Return min(d, d strip )

6

Page 7: Computational Geometry

Given a set of points, create a minimal convex set which contains all points

The elastic band analogy:

7

Page 8: Computational Geometry

Begin at the leftmost point (in this example) From vertical line, sweep clockwise until point is

encountered Continue sweep from current angle at next point O(nh) O(n2)

8

Page 9: Computational Geometry

Sort points by angle in respect to first point› further sort equal angles by distance

O(n) time if the points are already sorted O(n logn) otherwise

Stack.push(Points[1]);Stack.push(Points[2]);FOR i = 3 TO Points.length

WHILE (Stack.length >= 2 and Cross_product(Stack.second, Stack.top, Points[i]) <= 0)Stack.pop;

Stack.push(Points[i]);

9

Page 10: Computational Geometry

Walk points from bottom Move only counterclockwise If clockwise move is found,

remove last step

10

Page 11: Computational Geometry

Breaking a polygon into triangular sections Can be used for modeling terrain and other

objects Euclidean minimum spanning tree is a subset of

the Delaunay Triangulation (naïve runtime O(n2))

11

Page 12: Computational Geometry

Given a set of points, partition according to closest point

Many useful applications http://www.diku.dk/hjemmesider/studerende/

duff/Fortune/

12

Page 13: Computational Geometry

Geometric searching problems Given a search space and query set Examples

› Range Searching› Ray Tracing

13

Page 14: Computational Geometry

Determine the number of points inside of a polygonal query section

14

Page 15: Computational Geometry

Computer graphics applications Can simulate accurate reflection and refraction Functions like backwards photon mapping

15

Page 16: Computational Geometry

For each pixel in image { Create ray from eyepoint passing through this pixel Initialize NearestT to INFINITY and NearestObject to NULLFor every object in scene {

If ray intersects this object { If t of intersection is less than NearestT {

Set NearestT to t of the intersection Set NearestObject to this object }

} }

If NearestObject is NULL { Fill this pixel with background color

} Else { Shoot a ray to each light source to check if in shadow If surface is reflective, generate reflection ray: recurse If surface is transparent, generate refraction ray: recurse Use NearestObject and NearestT to compute shading function Fill this pixel with color result of shading function }

}(Wikipedia)

16

Page 17: Computational Geometry

Modification of a Computational Geometry problem to a dynamic one

Input elements may be added, removed, or modified

Examples› Dynamic Range Search (Geometric Query)› Dynamic Convex Hull (Static Problem)

17

Page 18: Computational Geometry

A fourth class of problems Modifications of the previous three classes Example

› Point-in-Polygon Static or Geometric Query, depending on the situation

18

Page 19: Computational Geometry

Given a point and a polygon, determine whether or not the point lies within the polygon

Ray casting› Not the same as ray tracing!› Even-odd test

19

Page 20: Computational Geometry

Computing the winding number WN !=0 -> point is inside polygon Doesn’t work well for complex polygons (Θ(1)-Θ(0))/2π

20

Page 21: Computational Geometry

www.cs.wustl.edu/~rlg1/cse502/handouts/fastclosest.pdf

Images. www.commons.wikimedia.org http://www.diku.dk/hjemmesider/studerende/

duff/Fortune/

21

Page 22: Computational Geometry

What is the winding number for point P in relation to the polygon in the image below?

22