CHAPTER 33 Computational Geometry - PowerPoint PPT Presentation

1 / 21
About This Presentation
Title:

CHAPTER 33 Computational Geometry

Description:

Is the branch of computer science that studies algorithms for solving geometric ... If then and are collinear. (0,0) y. x. Prohibited for. If is clockwise from ... – PowerPoint PPT presentation

Number of Views:172
Avg rating:3.0/5.0
Slides: 22
Provided by: feodorf
Category:

less

Transcript and Presenter's Notes

Title: CHAPTER 33 Computational Geometry


1
CHAPTER 33Computational Geometry
  • Is the branch of computer science that studies
    algorithms for solving geometric problems.
  • Has applications in many fields, including
  • computer graphics
  • robotics,
  • VLSI design
  • computer aided design
  • statistics
  • Deals with geometric objects such as points,
    line segments, polygons, etc.
  • Some typical problems considered
  • whether intersections occur in a set of lines.
  • finding vertices of a convex hull for points.
  • whether a line can be drawn separating two sets
    of points.
  • whether one point is visible from a second
    point, given some polygons that may block
    visibility.
  • optimal location of fire towers to view a
    region.
  • closest or most distant pair of points.
  • whether a point is inside or outside a polygon.

2
Cross products
3
Cross products (cont.)
4
Intersection of two line segments
5
Intersection of two line segments (cont.)
6
Determining whether any pair of segments
intersect.
7
(No Transcript)
8
The Algorithm ANY-SEGMENTS-INTERSECTION(S)
  • To maintain a total ordering T on the sweep line
    as it moves, we need the following operations
  • INSERT(T,s) insert segment s into T
  • DELETE(T,s) delete segment s from T
  • ABOVE(T,s) return the segment from T
    immediately above segment s
  • BELOW(T,s) return the segment from T
    immediately below segment s
  • Red-black trees can provide a balanced search
    tree which can support above operations in O(log
    n) time (see Ch. 13 in CLRS)
  • T? emptyset
  • Sort segment endpoints from left to right. Break
    ties by putting point with lower y-coordinate
    first.
  • For each point p in the sorted list (in order)
  • if p is left endpoint of segment s then
  • INSERT(T,s)
  • if ABOVE(T,s) exists and
    it intersects s or
  • BELOW(T,s) exists and it intersects s
    then return TRUE
  • if p is the right endpoint of segment
    then
  • if both ABOVE(T,s) and
    BELOW(T,s) exist and
  • ABOVE(T,s) intersects BELOW(T,s)
    then return TRUE
  • DELETE(T,s)
  • return FALSE

Animated demo http//www.lupinho.de/gishur/html/Sw
eeps.htmlsegment
9
Comments and Correctness
10
Correctness and Runtime
  • In either case, the order of T is correct before
    q is processed.
  • Only two cases are possible.
  • Either a or b is inserted into T at z and the
    other segment is above or below it. (In this
    case, intersection is detected by line (6) .)
  • Segments a and b are already in T and a segment c
    between them is deleted at z. (In this case, an
    intersection is detected by line (8).)
  • In either case the intersection of a and b at p
    is detected, so procedure cannot return a FALSE,
    as supposed.

a
p
c
q
b
x
z
  • Running Time
  • sort on line (2) takes O(n logn) time, using
    merge or heap sort.
  • since there are 2n events (endpoints) where
    sweep line stops, the loop iterates at most 2n
    times.
  • each iteration of loop takes O(log n) time,
    since red-black tree operations take O(log n)
    time.
  • Total time is O(n logn).

READ Ch. 33.1 and Ch 33.2 in CLRS.
11
Convex Hull Algorithms
12
The Problem and Approaches
13
Gift Wrapping or The Jarvis March Algorithm
14
Complexity of Jarvis March
15
Graham Scan Algorithm
16
Example and Runtime Computation
17
Correctness of Graham Scan
18
Correctness of Graham Scan (cont.)
19
Closest Pair of Points
20
Divide and Conquer Steps
21
Combine Step and Runtime
d
d
L
d
d
Possible coincident points, one in P and one in
P.
L
Runtime
  • The initial preprocessing step costs O(n logn)
  • The recurrence relation for the recursive
    portion is T(n),
  • where
  • Its solution is T(n) O(n logn). This gives also
    the total running time.

READ Ch. 33.3 and 33.4 in CLRS.
Write a Comment
User Comments (0)
About PowerShow.com