Presentation on theme: "Computational Geometry The systematic study of algorithms and data structures for geometric objects, with a focus on exact algorithms that are asymptotically."— Presentation transcript:
Computational Geometry The systematic study of algorithms and data structures for geometric objects, with a focus on exact algorithms that are asymptotically fast. Applications in Computer graphics VLSI design CAD/CAM Robotics Geographic Information Systems Geometric Modeling
Example 1 Proximity Closest café on campus? Voronoi diagram Delaunay triangulation
Example 2 Path Planning Robot How can a robot find a short route to the destination that avoids all obstacles?
Line Segments & Vectors p = (x, y ) 1 2 O = (0, 0)x y 1 2 Points (vectors): p, p, p p = p p p = (x x, y y ) 1 2 Line segment: p p = p p
Cross (Vector) Product x y (0, 0) p p 1 p + p p p is the signed area of the parallelogram. 1 2 p p = x y x y = p p = |p | |p | sin p and p are collinear iff p p =
Turning of Consecutive Segments Counterclockwise Clockwise No turn (collinear) p p p p p p pp p 0 12 p p p p > p p p p < p p p p = Segments p p and p p. Move from p to p then to p
Dot (Inner) Product x y (0, 0) p p 1 2 p p = x x + y y = p p = |p | |p | cos
A Segment & a Collinear Point p q r r p q q,r p Cross product is zero: pr pq = 0. // p, q, r collinear Does a line segment pq contain a collinear point r? Check the sign of the dot product rp rq Sign of rp rq + 0
Two Segments Intersect? One method: solve for the intersection point of the two lines containing the two line segments, and then check whether this point lies on both segments. In practice, the two input segments often do not intersect. Stage 1: quick rejection if their bounding boxes do not intersect Case 1: bounding boxes do not intersect; neither will the segments. bounding boxes (x, y ) 2 (x, y ) x x y y if and only if L M L right of M? L left of M? L above M? L below M?
Bounding Box Case 2: Bounding boxes intersect; the segments may or may not intersect. Needs to be further checked in Stage 2.
Stage 2 Two line segments do not intersect if and only if one segment lies entirely to one side of the line containing the other segment. p 1 p 2 p 3 p 4 ( p p ) ( p p ) and ( p p ) ( p p ) are both positive!
Necessary and Sufficient Condition p p 1 2 p p 3 4 Two line segments intersect iff each of the two pairs of cross products below have different signs (or one cross product in the pair is 0). (p p ) ( p p ) and ( p p ) ( p p ) p 1 p 2 p 3 p // the line through p p // intersects p p // the line through p p // intersects p p. 4 12