1 / 34

Computational Geometry for the Tablet PC

This lecture will cover the basics of computational geometry on a Tablet PC, including geometric primitives, intersections, and polygons. We will discuss algorithms for geometric computation, numerical issues with coordinates, and examples of degenerate cases. The lecture will also include an overview of the Voronoi Diagram.

fholly
Télécharger la présentation

Computational Geometry for the Tablet PC

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. ComputationalGeometry for the Tablet PC CSE 481b Lecture 17

  2. Announcements • Thursday, March 2 • ABET Program review • Give important feedback on the program • Free Donuts!

  3. Overview SUB: Ask for submission of a picture • Computational Geometry on the Tablet PC • Geometric primitives • Intersections • Polygons • Convexity • Voronoi Diagram

  4. Tablet Geometry SUB: What is Points[6.4]? • Basic structure – Stroke: sequence of points • Himetric coordinates • Sampled 150 times per second • Coordinates stored in an array Points

  5. Computational Geometry • Algorithms for geometric computation • Numerical issues with coordinates • Importance of degenerate cases • Examples of degenerate cases • Three lines intersecting at a point • Segments overlapping • Three points co-linear

  6. Basic geometry p2 • Point • p • Line segment • (p1, p2) • Distance • Dist(p1, p2) • Basic Test • LeftOf(p1, p2, p3) • CCW(p1, p2, p3) p p1 p3 p2 p1

  7. Counter Clockwise Test • CCW(p1, p2, p3) public static bool CcwTest(Point p1, Point p2, Point p3){ int q1 = (p1.Y - p2.Y)*(p3.X - p1.X); int q2 = (p2.X - p1.X)*(p3.Y - p1.Y); return q1 + q2 < 0; } p2 ASIDE: Give derivation based on the determinant p1 p3

  8. Segment intersection • Find intersection of (p1,p2) and (p3,p4) • Q = ap1 + (1-a)p2 • Q = bp3 + (1-b)p4 • Solve for a, b • Two equations, two unknowns • Intersect if 0 < a < 1 and 0 < b < 1 • Derived points • In general, try to avoid computing derived points in geometric algorithms

  9. Problem SUB Tell students segments are not co-linear • Determine if two line segments (p1, p2) and (p3,p4) intersect just using CCW Tests Student Submission

  10. Making intersection test more efficient • Take care of easy cases using coordinate comparisons • Only use CCW tests if bounding boxes intersect

  11. Computing intersections SUB Ignore degenerate cases • How many self intersections can a single stroke with n points have? Student Submission

  12. Segment intersection algorithm • Run time O(nlog n + Klog n) for finding K intersections • Sweepline Algorithm 3 6 5 1 2 7 4

  13. Event queue Start Segment (S2) End Segment (E2) Intersection (I2,4) Move sweepline to next event Maintain vertical order of segments as line sweeps across Start Segment Insert in list Check above and below for intersection End Segment Remove from list Check newly adjacent segments for intersection Intersection Reorder segments Check above and below for intersection Sweepline Algorithm

  14. Sweepline example 3 6 5 1 2 7 4

  15. Activity: Identify when each of the intersections is detected D A F C E B Student Submission

  16. Polygons • Sequence of points representing a closed path • Simple polygon – closed path with no self intersections

  17. Describe an algorithm to test if a point q is in a polygon P

  18. Polygon inclusion test • Is the point q inside the Polygon P?

  19. Convexity • Defn: Set S is convex if whenever p1, and p2 are in S, the segment (p1, p2) is contained in S

  20. Convex polygons • P = {p0, p1, . . . pn-1} • P is convex if • CCW(pi, pi+1, pi+2) for all i • Interpret subscripts mod n • Also holds for CW (depending on how points are ordered)

  21. Problem: Test if a point q is inside a convex polygon P using CCW Tests Student Submission SUB: Describe an algorithm using CCW Tests

  22. Convex hull • Smallest enclosing convex figure • Rubber band “algorithm”

  23. Compute the Convex Hull SUB: Students draw the hull Student Submission

  24. Illustrate insertion with diagram on right Algorithms • Convex hull algorithms: O(nlog n) • Related to sorting • Insertion algorithm • Gift Wrapping (Jarvis’s march) • Divide and Conquer • Graham Scan

  25. Convex Hull AlgorithmsGift wrapping

  26. Divide and Conquer

  27. Graham Scan • Polar sort the points around a point inside the hull • Scan points in CCW order • Discard any point that causes a CW turn • If CCW advance • If !CCW, discard current point and back up

  28. SUB: Students draw the hull Polar sort the red points around q(Start with p, number the points in CCW order) p q Student Submission SUB: Use the result for a first illustration of the algorithm

  29. Graham Scan Algorithm • Stack of vertices • Possible hull vertices • z – next vertex • y – top of stack • x – next on stack • If CCW(x, y, z) • Push(z) • If (! CCW(x, y, z)) • Pop stack x y z x z y

  30. GS Example to walk through

  31. Student submission: Give order vertices are discarded in the scan p Student Submission

  32. Voronoi Diagram • Given a set of points: subdivide space into the regions closest to each point Instructor Note:

  33. Compute the Voronoi Diagram Student Submission

  34. Algorithms for Computing the Voronoi

More Related