Presentation is loading. Please wait.

Presentation is loading. Please wait.

Geometric Algorithms João Comba. Example: Convex Hull convex Non-convex.

Similar presentations


Presentation on theme: "Geometric Algorithms João Comba. Example: Convex Hull convex Non-convex."— Presentation transcript:

1 Geometric Algorithms João Comba

2 Example: Convex Hull convex Non-convex

3 Example: Convex Hull p9p9 p2p2 p8p8 p6p6 p5p5 p4p4 p 11 p1p1 p7p7 p3p3 p 10 Input: p 1,p 2,p 3,p 4,p 5,p 6,p 7,p 8,p 9,p 10,p 11 Output: p 2,p 9,p 11,p 4,p 5,p 6,p 8,p 2 CH is a convex polygon

4 Example: Convex Hull p9p9 p2p2 p8p8 p6p6 p5p5 p4p4 p 11 p1p1 p7p7 p3p3 p 10

5 Quickhull p3p3 p1p1 p2p2 p7p7 p 11 p 10 p8p8 p5p5 p4p4 p9p9 p6p6 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

6 Quickhull p3p3 p1p1 p2p2 p7p7 p 11 p 10 p8p8 p5p5 p4p4 p9p9 p6p6 1.Find extreme points above, below, left and right 2.Define a quadrilateral connecting extreme points, discard internal points

7 Quickhull p3p3 p1p1 p2p2 p7p7 p 11 p 10 p8p8 p5p5 p4p4 p9p9 p6p6 1.Find extreme points above, below, left and right 2.Define a quadrilateral connecting extreme points, discard internal points Which Points are internal?

8 A Fact From Analytical Geometry P 3 is to the left of the line P 1 ->P 2 if and only if the sign of the following determinant is positive: P 1 (x 1, y 1 ) P 2 (x 2, y 2 ) P 3 (x 3, y 3 )

9 Quickhull p3p3 p1p1 p2p2 p7p7 p 11 p 10 p8p8 p5p5 p4p4 p9p9 p6p6 1.Find extreme points above, below, left and right 2.Define a quadrilateral connecting extreme points, discard internal points 3.Process 4 triangles recursively

10 Quickhull p3p3 p1p1 p2p2 p7p7 p 11 p 10 p8p8 p5p5 p4p4 p9p9 p6p6 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.

11 Quickhull p3p3 p1p1 p2p2 p7p7 p 11 p 10 p8p8 p5p5 p4p4 p9p9 p6p6 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?

12 A Fact From Analytical Geometry The area of the triangle  P 1 P 2 P 3 is ½ of the magnitude of the determinant P 1 (x 1, y 1 ) P 2 (x 2, y 2 ) P 3 (x 3, y 3 )

13 Quickhull p3p3 p1p1 p2p2 p7p7 p 11 p 10 p8p8 p5p5 p4p4 p9p9 p6p6 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

14 Quickhull p3p3 p1p1 p2p2 p7p7 p 11 p 10 p8p8 p5p5 p4p4 p9p9 p6p6 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

15 Quickhull p3p3 p1p1 p2p2 p7p7 p 11 p 10 p8p8 p5p5 p4p4 p9p9 p6p6 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

16 Quickhull p3p3 p1p1 p2p2 p7p7 p 11 p 10 p8p8 p5p5 p4p4 p9p9 p6p6 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

17 Quickhull p3p3 p1p1 p2p2 p7p7 p 11 p 10 p8p8 p5p5 p4p4 p9p9 p6p6 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

18 Quickhull p3p3 p1p1 p2p2 p7p7 p 11 p 10 p8p8 p5p5 p4p4 p9p9 p6p6 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

19 Quickhull p3p3 p1p1 p2p2 p7p7 p 11 p 10 p8p8 p5p5 p4p4 p9p9 p6p6 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

20 Quickhull p3p3 p1p1 p2p2 p7p7 p 11 p 10 p8p8 p5p5 p4p4 p9p9 p6p6 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

21 Quickhull p3p3 p1p1 p2p2 p7p7 p 11 p 10 p8p8 p5p5 p4p4 p9p9 p6p6 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

22 Quickhull p3p3 p1p1 p2p2 p7p7 p 11 p 10 p8p8 p5p5 p4p4 p9p9 p6p6 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

23 Quickhull p3p3 p1p1 p2p2 p7p7 p 11 p 10 p8p8 p5p5 p4p4 p9p9 p6p6 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?

24 Quickhull p3p3 p1p1 p2p2 p7p7 p 11 p 10 p8p8 p5p5 p4p4 p9p9 p6p6 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?

25 Quickhull p3p3 p1p1 p2p2 p7p7 p 11 p 10 p8p8 p5p5 p4p4 p9p9 p6p6 T(n) = O(n) + 2T(n/2) -> O(nlogn) T(n) = O(n) + T(n-1) ->O(n 2 ) 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


Download ppt "Geometric Algorithms João Comba. Example: Convex Hull convex Non-convex."

Similar presentations


Ads by Google