geometric algorithms joão comba. example: convex hull convex non-convex
Post on 17-Dec-2015
244 Views
Preview:
TRANSCRIPT
Example: Convex HullExample: Convex Hull
p9
p2
p8
p6
p5
p4
p11
p1
p7p3
p10
Input: p1,p2,p3,p4,p5,p6,p7,p8,p9,p10,p11
Output: p2,p9,p11,p4,p5,p6,p8,p2
CH is a convex polygon
QuickhullQuickhull
p3
p1
p2
p7
p11
p10
p8
p5
p4p9
p6
1. Find extreme points above, below, left and right
2. Define a quadrilateral connecting extreme points, discard internal points
3. Process 4 triangles recursively
4. For each triangle, find vertex with the greatest distance from the triangle baseline.
5. Define another triangle and discard internal triangles
6. Process 2 triangles recursively
QuickhullQuickhull
p3
p1
p2
p7
p11
p10
p8
p5
p4p9
p6
1. Find extreme points above, below, left and right
2. Define a quadrilateral connecting extreme points, discard internal points
QuickhullQuickhull
p3
p1
p2
p7
p11
p10
p8
p5
p4p9
p6
1. Find extreme points above, below, left and right
2. Define a quadrilateral connecting extreme points, discard internal points
Which Points are internal?
A Fact From Analytical Geometry
•P3 is to the left of the line P1->P2 if and only if the sign of the following determinant is positive:
P1 (x1, y1) P2 (x2, y2)
P3 (x3, y3)
0
1
1
1
311223321321
33
22
11
yxyxyxyxyxyx
yx
yx
yx
QuickhullQuickhull
p3
p1
p2
p7
p11
p10
p8
p5
p4p9
p6
1. Find extreme points above, below, left and right
2. Define a quadrilateral connecting extreme points, discard internal points
3. Process 4 triangles recursively
QuickhullQuickhull
p3
p1
p2
p7
p11
p10
p8
p5
p4p9
p6
1. Find extreme points above, below, left and right
2. Define a quadrilateral connecting extreme points, discard internal points
3. Process 4 triangles recursively
4. For each triangle, find vertex with the greatest distance from the triangle baseline.
QuickhullQuickhull
p3
p1
p2
p7
p11
p10
p8
p5
p4p9
p6
1. Find extreme points above, below, left and right
2. Define a quadrilateral connecting extreme points, discard internal points
3. Process 4 triangles recursively
4. For each triangle, find vertex with the greatest distance from the triangle baseline.
How to calculate a vertex’s distance from a line?
A Fact From Analytical Geometry
•The area of the triangle P1 P2 P3 is ½ of the magnitude of the determinant
P1 (x1, y1) P2 (x2, y2)
P3 (x3, y3)
2
|| isThat
1
1
1
311223321321
311223321321
33
22
11
yxyxyxyxyxyx
yxyxyxyxyxyx
yx
yx
yx
QuickhullQuickhull
p3
p1
p2
p7
p11
p10
p8
p5
p4p9
p6
1. Find extreme points above, below, left and right
2. Define a quadrilateral connecting extreme points, discard internal points
3. Process 4 triangles recursively
4. For each triangle, find vertex with the greatest distance from the triangle baseline.
5. Define another triangle and discard internal triangles
QuickhullQuickhull
p3
p1
p2
p7
p11
p10
p8
p5
p4p9
p6
1. Find extreme points above, below, left and right
2. Define a quadrilateral connecting extreme points, discard internal points
3. Process 4 triangles recursively
4. For each triangle, find vertex with the greatest distance from the triangle baseline.
5. Define another triangle and discard internal triangles
6. Process 2 triangles recursively
QuickhullQuickhull
p3
p1
p2
p7
p11
p10
p8
p5
p4p9
p6
1. Find extreme points above, below, left and right
2. Define a quadrilateral connecting extreme points, discard internal points
3. Process 4 triangles recursively
4. For each triangle, find vertex with the greatest distance from the triangle baseline.
5. Define another triangle and discard internal triangles
6. Process 2 triangles recursively
QuickhullQuickhull
p3
p1
p2
p7
p11
p10
p8
p5
p4p9
p6
1. Find extreme points above, below, left and right
2. Define a quadrilateral connecting extreme points, discard internal points
3. Process 4 triangles recursively
4. For each triangle, find vertex with the greatest distance from the triangle baseline.
5. Define another triangle and discard internal triangles
6. Process 2 triangles recursively
QuickhullQuickhull
p3
p1
p2
p7
p11
p10
p8
p5
p4p9
p6
1. Find extreme points above, below, left and right
2. Define a quadrilateral connecting extreme points, discard internal points
3. Process 4 triangles recursively
4. For each triangle, find vertex with the greatest distance from the triangle baseline.
5. Define another triangle and discard internal triangles
6. Process 2 triangles recursively
QuickhullQuickhull
p3
p1
p2
p7
p11
p10
p8
p5
p4p9
p6
1. Find extreme points above, below, left and right
2. Define a quadrilateral connecting extreme points, discard internal points
3. Process 4 triangles recursively
4. For each triangle, find vertex with the greatest distance from the triangle baseline.
5. Define another triangle and discard internal triangles
6. Process 2 triangles recursively
QuickhullQuickhull
p3
p1
p2
p7
p11
p10
p8
p5
p4p9
p6
1. Find extreme points above, below, left and right
2. Define a quadrilateral connecting extreme points, discard internal points
3. Process 4 triangles recursively
4. For each triangle, find vertex with the greatest distance from the triangle baseline.
5. Define another triangle and discard internal triangles
6. Process 2 triangles recursively
QuickhullQuickhull
p3
p1
p2
p7
p11
p10
p8
p5
p4p9
p6
1. Find extreme points above, below, left and right
2. Define a quadrilateral connecting extreme points, discard internal points
3. Process 4 triangles recursively
4. For each triangle, find vertex with the greatest distance from the triangle baseline.
5. Define another triangle and discard internal triangles
6. Process 2 triangles recursively
QuickhullQuickhull
p3
p1
p2
p7
p11
p10
p8
p5
p4p9
p6
1. Find extreme points above, below, left and right
2. Define a quadrilateral connecting extreme points, discard internal points
3. Process 4 triangles recursively
4. For each triangle, find vertex with the greatest distance from the triangle baseline.
5. Define another triangle and discard internal triangles
6. Process 2 triangles recursively
QuickhullQuickhull
p3
p1
p2
p7
p11
p10
p8
p5
p4p9
p6
1. Find extreme points above, below, left and right
2. Define a quadrilateral connecting extreme points, discard internal points
3. Process 4 triangles recursively
4. For each triangle, find vertex with the greatest distance from the triangle baseline.
5. Define another triangle and discard internal triangles
6. Process 2 triangles recursively
QuickhullQuickhull
p3
p1
p2
p7
p11
p10
p8
p5
p4p9
p6
1. Find extreme points above, below, left and right
2. Define a quadrilateral connecting extreme points, discard internal points
3. Process 4 triangles recursively
4. For each triangle, find vertex with the greatest distance from the triangle baseline.
5. Define another triangle and discard internal triangles
6. Process 2 triangles recursively
Time Efficiency?
QuickhullQuickhull
p3
p1
p2
p7
p11
p10
p8
p5
p4p9
p6
1. Find extreme points above, below, left and right
2. Define a quadrilateral connecting extreme points, discard internal points
3. Process 4 triangles recursively
4. For each triangle, find vertex with the greatest distance from the triangle baseline.
5. Define another triangle and discard internal triangles
6. Process 2 triangles recursively
Time Efficiency?
Time Efficiency of Steps 4, 5, 6?
QuickhullQuickhull
p3
p1
p2
p7
p11
p10
p8
p5
p4p9
p6
T(n) = O(n) + 2T(n/2) -> O(nlogn)T(n) = O(n) + T(n-1) ->O(n2)
T(n) = O(n) + T(a) + T(b)
1. Find extreme points above, below, left and right
2. Define a quadrilateral connecting extreme points, discard internal points
3. Process 4 triangles recursively
4. For each triangle, find vertex with the greatest distance from the triangle baseline.
5. Define another triangle and discard internal triangles
6. Process 2 triangles recursively
top related