computational geometry
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 PresentationTRANSCRIPT
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
The field of computational geometry can be divided into three general classes of problems› Static› Geometric Queries› Dynamic
3
Given input, construct the corresponding output Examples
› Finding the closest pair of points› Determining convex hulls› Polygonal Triangulation› Creating a Voronoi Diagram
4
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
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
Given a set of points, create a minimal convex set which contains all points
The elastic band analogy:
7
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
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
Walk points from bottom Move only counterclockwise If clockwise move is found,
remove last step
10
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
Given a set of points, partition according to closest point
Many useful applications http://www.diku.dk/hjemmesider/studerende/
duff/Fortune/
12
Geometric searching problems Given a search space and query set Examples
› Range Searching› Ray Tracing
13
Determine the number of points inside of a polygonal query section
14
Computer graphics applications Can simulate accurate reflection and refraction Functions like backwards photon mapping
15
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
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
A fourth class of problems Modifications of the previous three classes Example
› Point-in-Polygon Static or Geometric Query, depending on the situation
18
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
Computing the winding number WN !=0 -> point is inside polygon Doesn’t work well for complex polygons (Θ(1)-Θ(0))/2π
20
www.cs.wustl.edu/~rlg1/cse502/handouts/fastclosest.pdf
Images. www.commons.wikimedia.org http://www.diku.dk/hjemmesider/studerende/
duff/Fortune/
21
What is the winding number for point P in relation to the polygon in the image below?
22