Presentation is loading. Please wait.

Presentation is loading. Please wait.

Introduction to Spatial Computing CSE 555

Similar presentations


Presentation on theme: "Introduction to Spatial Computing CSE 555"— Presentation transcript:

1 Introduction to Spatial Computing CSE 555
Algorithms for Spatial Data Some slides adapted from Worboys and Duckham (2004) GIS: A Computing Perspective, Second Edition, CRC Press

2 Few Common Geometric Algorithms

3 Distance and Angle between points
Length of a line segment can be computed as the distance between successive pairs of points The bearing, , of q from p is given by the unique solution in the interval [0,360] of the simultaneous equations:

4 Distance from point to Line
Distance from a point to a line implies minimum distance For a straight line segment, distance computation depends on whether p is in middle(l) or end(l) For a polyline, distance to each line segment must be calculated A polygon calculation is as for polyline (distance to boundary of polygon)

5 Area of a polygon (1/2) Let P be a simple polygon (no boundary self-intersections) with vertex vectors: (x1, y1), (x2, y2), ..., (xn, yn) where (x1, y1) = (xn, yn) Then the area is: In the case of a triangle pqr

6 Area of a polygon (2/2) Area may be positive or negative
In fact, area(pqr) = -area(qpr) If p is to the left of qr then the area is positive, if p is to the right of qr then the area is negative

7 Centroid of a polygon The centroid of a polygon (or center of gravity) of a (simple) polygonal object (P = (x1, y1), (x2, y2), ..., (xn, yn) where (x1, y1) = (xn, yn)) is the point at which it would balance if it were cut out of a sheet of material of uniform density:

8 Point in a polygon Determining whether a point is inside a polygon is one of the most fundamental operations in a spatial database Semi-line algorithm: checks for odd or even numbers of intersections of a semi-line with polygon Winding algorithm: sums bearings from point to polygon vertices. The point is inside if a full turn (360 or -360) is observed. Vertices should be visited in order (clockwise or anti-clockwise). Need to follow the boundary in order. In other words no re-tracing of the same boundary edge is allowed.

9 Collinearity and Point on a segment
Boolean operation colinear(a,b,c) determine whether points a, b and c lie on the same straight line Colinear(a,b,c) = true if and only if side (a,b,c) =0 Operation point_on_segment(p,l) returns the Boolean value true if p ∈ l (line segment l having end-points q and r) Determine whether p, q, r are collinear If yes, then p ∈ l if and only if p ∈ (minimum bounding box) MMB (l)

10 Segment Intersection Two line segments ab and cd can only intersect if a and b are on opposite sides of cd and c and d are on opposite sides of ab Therefore two line segments intersect if the following inequalities hold

11 Polygon Triangulation

12 Motivating Need through Tessellations
Tessellations: a partition of the plane as the union of a set of disjoint areal objects Regular polygon: a polygon with all edges the same length and all internal angles equal Vertex figure: the polygon formed by joining in order the mid points of all edges incident with the vertex Regular tessellation: a tessellation of a surface for which all the participating polygons and vertex figures are regular and equal Square grid is most commonly used regular tessellation Provides the raster representation of spatial data

13 Irregular Tessellated representations
Irregular tessellation: a tessellation for which the participating polygons are not all regular and equal TIN (triangulated irregular networks) is the most commonly used irregular tessellations The irregularity of a TIN allows the resolution to vary over the surface, capturing finer details where required. TINs are often derived from the elevation data of a rasterized digital elevation model (DEM). An advantage of using a TIN over a raster DEM is that the points of a TIN are distributed variably based on an algorithm. We can decide which points are most necessary to an accurate representation of the terrain.

14 Sample Triangulated Irregular Networks

15 Interpolating the height using Triangulation
Point x is inside or on the boundary of the triangle abc, x = a + b + c Where  ,  , and  are scalar coefficients that can be uniquely determined, such that:  +  +  = 1 The height hx can now be found by using hx = ha + hb + hc

16 Delaunay Triangulation
Delaunay triangulation: constituent triangles in a Delaunay triangulations are “as nearly equilateral as possible” Each circumcircle of a constituent triangle does not include any other triangulation point within it Proximal polygon: A region Rp around a point p with the property that every location in Rp is nearer to p than to any other point Voronoi diagram: the dual of a Delaunay triangulations The set of proximal polygons constitutes a Voronoi diagram

17 Properties of Delaunay Triangulation
Given an initial point set P for which no sets of three points are collinear (to avoid degenerate cases) The Delaunay triangulation is unique The external edges of the triangulation from the convex hull of P (i.e., the smallest convex set containing P) The circumcircles of the triangles contain no members of P in their interior The triangles in a Delaunay triangulation are best-possible with respect to regularity (closest to equilateral)

18 Polygon Triangulation (Optional Material)

19 Triangulation of Polygons – Y monotones
A simple polygon is y-monotone if any horizontal line intersects it in a connected set (or not at all) If not a y-monotone then partition a polygon into y-monotone polygons (covered later) Triangulate each y-monotone polygon P2 P3 P4 P5 P6 P7 P8 P9

20 Triangulation of Polygons – Y monotones
Input: (a) A point set P of an Y-monotone. (b) Left and right chains of P merge the vertices of the left and right chains of P into y-sorted order p 1 ,…, p n . Put the points p 1 and p 2 into an empty stack S. For i←3 𝑡𝑜 𝑛−1 3.1 If p i and top S are on different chains 3.1.1 Pop all vertices from S and add a diagonal between p i and each popped vertex except the last. 3.1.2 push p i−1 and p i onto S 3.2 Else pop S 3.2.1 pop S 3.2.2 pop the other vertices from S while they are visible from p i , and add a diagonal between p i and each popped vertex push last popped vertex back onto S push p i onto S. 4. Add diagonals from the last vertex p n to all stack vertices except first and last

21 Triangulation of Polygons – Y monotones
3. For i←3 𝑡𝑜 𝑛−1 3.1 If p i and top S are on different chains 3.1.1 Pop all vertices from S and add a diagonal between p i and each popped vertex except the last. 3.1.2 push p i−1 and p i onto S 3.2 Else 3.2.1 Pop(s) 3.2.2 pop the other vertices from S while they are visible from p i , and add a diagonal between p i and each popped vertex push last popped vertex back onto S push p i onto S. 4. Add diagonals from the last vertex p n to all stack vertices except first and last P2 P3 P4 P5 P6 Stack S P2 P1 P7 P8 i=3 Processing P3 P9

22 Triangulation of Polygons – Y monotones
3. For i←3 𝑡𝑜 𝑛−1 3.1 If 𝒑 𝐢 𝐚𝐧𝐝 𝐭𝐨𝐩 𝐒 are on different chains 3.1.1 Pop all vertices from S and add a diagonal between p i and each popped vertex except the last. 3.1.2 push p i−1 and p i onto S 3.2 Else 3.2.1 Pop(s) 3.2.2 pop the other vertices from S while they are visible from p i , and add a diagonal between p i and each popped vertex push last popped vertex back onto S push p i onto S. 4. Add diagonals from the last vertex p n to all stack vertices except first and last P2 P3 P4 P5 P6 Stack S P2 P1 P7 P8 i=3 Processing P3 P9

23 Triangulation of Polygons – Y monotones
3. For i←3 𝑡𝑜 𝑛−1 3.1 If 𝒑 𝐢 𝐚𝐧𝐝 𝐭𝐨𝐩 𝐒 are on different chains 3.1.1 Pop all vertices from S and add a diagonal between 𝒑 𝒊 and each popped vertex except the last. 3.1.2 push p i−1 and p i onto S 3.2 Else 3.2.1 Pop(s) 3.2.2 pop the other vertices from S while they are visible from p i , and add a diagonal between p i and each popped vertex push last popped vertex back onto S push p i onto S. 4. Add diagonals from the last vertex p n to all stack vertices except first and last P2 P3 P4 P5 P6 Stack S P2 P1 P7 P8 i=3 Processing P3 P9

24 Triangulation of Polygons – Y monotones
3. For i←3 𝑡𝑜 𝑛−1 3.1 If 𝒑 𝐢 𝐚𝐧𝐝 𝐭𝐨𝐩 𝐒 are on different chains 3.1.1 Pop all vertices from S and add a diagonal between p i and each popped vertex except the last. 3.1.2 push p i−1 and p i onto S 3.2 Else 3.2.1 Pop(s) 3.2.2 pop the other vertices from S while they are visible from p i , and add a diagonal between p i and each popped vertex push last popped vertex back onto S push p i onto S. 4. Add diagonals from the last vertex p n to all stack vertices except first and last P2 P3 P4 P5 P6 Stack S P7 P8 i=3 Processing P3 P9

25 Triangulation of Polygons – Y monotones
3. For i←3 𝑡𝑜 𝑛−1 3.1 If 𝒑 𝐢 𝐚𝐧𝐝 𝐭𝐨𝐩 𝐒 are on different chains 3.1.1 Pop all vertices from S and add a diagonal between p i and each popped vertex except the last. 3.1.2 push 𝒑 𝐢−𝟏 and 𝒑 𝒊 onto S 3.2 Else 3.2.1 Pop(s) 3.2.2 pop the other vertices from S while they are visible from p i , and add a diagonal between p i and each popped vertex push last popped vertex back onto S push p i onto S. 4. Add diagonals from the last vertex p n to all stack vertices except first and last P2 P3 P4 P5 P6 Stack S P7 P8 i=3 Processing P3 P9

26 Triangulation of Polygons – Y monotones
3. For i←3 𝑡𝑜 𝑛−1 3.1 If 𝒑 𝐢 𝐚𝐧𝐝 𝐭𝐨𝐩 𝐒 are on different chains 3.1.1 Pop all vertices from S and add a diagonal between p i and each popped vertex except the last. 3.1.2 push 𝒑 𝐢−𝟏 and 𝒑 𝒊 onto S 3.2 Else 3.2.1 Pop(s) 3.2.2 pop the other vertices from S while they are visible from p i , and add a diagonal between p i and each popped vertex push last popped vertex back onto S push p i onto S. 4. Add diagonals from the last vertex p n to all stack vertices except first and last P2 P3 P4 P5 P6 Stack S P3 P2 P7 P8 i=3 Processing P3 P9

27 Triangulation of Polygons – Y monotones
3. For 𝒊←𝟑 𝒕𝒐 𝒏−𝟏 3.1 If 𝑝 i and top S are on different chains 3.1.1 Pop all vertices from S and add a diagonal between p i and each popped vertex except the last. 3.1.2 push p i−1 and p i onto S 3.2 Else 3.2.1 Pop(s) 3.2.2 pop the other vertices from S while they are visible from p i , and add a diagonal between p i and each popped vertex push last popped vertex back onto S push p i onto S. 4. Add diagonals from the last vertex p n to all stack vertices except first and last P2 P3 P4 P5 P6 Stack S P3 P2 P7 P8 i=4 Processing P4 P9

28 Triangulation of Polygons – Y monotones
3. For i←3 𝑡𝑜 𝑛−1 3.1 If 𝑝 i and top S are on different chains 3.1.1 Pop all vertices from S and add a diagonal between p i and each popped vertex except the last. 3.1.2 push p i−1 and p i onto S 3.2 Else 3.2.1 Pop(s) 3.2.2 pop the other vertices from S while they are visible from p i , and add a diagonal between p i and each popped vertex push last popped vertex back onto S push p i onto S. 4. Add diagonals from the last vertex p n to all stack vertices except first and last P2 P3 P4 P5 P6 Stack S P3 P2 P7 P8 i=4 Processing P4 P9

29 Triangulation of Polygons – Y monotones
3. For i←3 𝑡𝑜 𝑛−1 3.1 If 𝑝 i and top S are on different chains 3.1.1 Pop all vertices from S and add a diagonal between p i and each popped vertex except the last. 3.1.2 push p i−1 and p i onto S 3.2 Else 3.2.1 Pop(s) 3.2.1 pop the other vertices from S while they are visible from p i , and add a diagonal between p i and each popped vertex push last popped vertex back onto S push p i onto S. 4. Add diagonals from the last vertex p n to all stack vertices except first and last P2 P3 P4 P5 P6 Stack S P3 P2 P7 P8 i=4 Processing P4 P9

30 Triangulation of Polygons – Y monotones
3. For i←3 𝑡𝑜 𝑛−1 3.1 If 𝑝 i and top S are on different chains 3.1.1 Pop all vertices from S and add a diagonal between p i and each popped vertex except the last. 3.1.2 push p i−1 and p i onto S 3.2 Else 3.2.1 Pop(s) 3.2.1 pop the other vertices from S while they are visible from p i , and add a diagonal between p i and each popped vertex push last popped vertex back onto S push p i onto S. 4. Add diagonals from the last vertex p n to all stack vertices except first and last P2 P3 P4 P5 P6 Stack S P2 P7 P8 i=4 Processing P4 P9

31 Triangulation of Polygons – Y monotones
3. For i←3 𝑡𝑜 𝑛−1 3.1 If 𝑝 i and top S are on different chains 3.1.1 Pop all vertices from S and add a diagonal between p i and each popped vertex except the last. 3.1.2 push p i−1 and p i onto S 3.2 Else 3.2.1 Pop(s) 3.2.1 pop the other vertices from S while they are visible from 𝒑 𝒊 , and add a diagonal between 𝒑 𝒊 and each popped vertex push last popped vertex back onto S push p i onto S. 4. Add diagonals from the last vertex p n to all stack vertices except first and last P2 P3 P4 P5 P6 Stack S P2 P7 P8 i=4 Processing P4 P9

32 Triangulation of Polygons – Y monotones
3. For i←3 𝑡𝑜 𝑛−1 3.1 If 𝑝 i and top S are on different chains 3.1.1 Pop all vertices from S and add a diagonal between p i and each popped vertex except the last. 3.1.2 push p i−1 and p i onto S 3.2 Else 3.2.1 Pop(s) 3.2.1 pop the other vertices from S while they are visible from 𝒑 𝒊 , and add a diagonal between 𝒑 𝒊 and each popped vertex push last popped vertex back onto S push p i onto S. 4. Add diagonals from the last vertex p n to all stack vertices except first and last P2 P3 P4 P5 P6 Stack S P7 P8 i=4 Processing P4 P9

33 Triangulation of Polygons – Y monotones
3. For i←3 𝑡𝑜 𝑛−1 3.1 If 𝑝 i and top S are on different chains 3.1.1 Pop all vertices from S and add a diagonal between p i and each popped vertex except the last. 3.1.2 push p i−1 and p i onto S 3.2 Else 3.2.1 Pop(s) 3.2.1 pop the other vertices from S while they are visible from 𝑝 𝑖 , and add a diagonal between 𝑝 𝑖 and each popped vertex push last popped vertex back onto S push 𝒑 𝒊 onto S. 4. Add diagonals from the last vertex p n to all stack vertices except first and last P2 P3 P4 P5 P6 Stack S P7 P8 i=4 Processing P4 P9

34 Triangulation of Polygons – Y monotones
3. For i←3 𝑡𝑜 𝑛−1 3.1 If 𝑝 i and top S are on different chains 3.1.1 Pop all vertices from S and add a diagonal between p i and each popped vertex except the last. 3.1.2 push p i−1 and p i onto S 3.2 Else 3.2.1 Pop(s) 3.2.1 pop the other vertices from S while they are visible from 𝑝 𝑖 , and add a diagonal between 𝑝 𝑖 and each popped vertex push last popped vertex back onto S push 𝒑 𝒊 onto S. 4. Add diagonals from the last vertex p n to all stack vertices except first and last P2 P3 P4 P5 P6 Stack S P4 P2 P7 P8 i=4 Processing P4 P9

35 Triangulation of Polygons – Y monotones
3. For 𝐢←𝟑 𝒕𝒐 𝒏−𝟏 3.1 If 𝑝 i and top S are on different chains 3.1.1 Pop all vertices from S and add a diagonal between p i and each popped vertex except the last. 3.1.2 push p i−1 and p i onto S 3.2 Else 3.2.1 Pop(s) 3.2.1 pop the other vertices from S while they are visible from 𝑝 𝑖 , and add a diagonal between 𝑝 𝑖 and each popped vertex push last popped vertex back onto S push 𝑝 𝑖 onto S. 4. Add diagonals from the last vertex p n to all stack vertices except first and last P2 P3 P4 P5 P6 Stack S P4 P2 P7 P8 i=5 Processing P5 P9

36 Triangulation of Polygons – Y monotones
3. For i←3 𝑡𝑜 𝑛−1 3.1 If 𝒑 𝐢 𝐚𝐧𝐝 𝐭𝐨𝐩 𝐒 are on different chains 3.1.1 Pop all vertices from S and add a diagonal between p i and each popped vertex except the last. 3.1.2 push p i−1 and p i onto S 3.2 Else 3.2.1 Pop(s) 3.2.1 pop the other vertices from S while they are visible from 𝑝 𝑖 , and add a diagonal between 𝑝 𝑖 and each popped vertex push last popped vertex back onto S push 𝑝 𝑖 onto S. 4. Add diagonals from the last vertex p n to all stack vertices except first and last P2 P3 P4 P5 P6 Stack S P4 P2 P7 P8 i=5 Processing P5 P9

37 Triangulation of Polygons – Y monotones
3. For i←3 𝑡𝑜 𝑛−1 3.1 If 𝒑 𝐢 𝐚𝐧𝐝 𝐭𝐨𝐩 𝐒 are on different chains 3.1.1 Pop all vertices from S and add a diagonal between 𝒑 𝒊 and each popped vertex except the last. 3.1.2 push p i−1 and p i onto S 3.2 Else 3.2.1 Pop(s) 3.2.1 pop the other vertices from S while they are visible from 𝑝 𝑖 , and add a diagonal between 𝑝 𝑖 and each popped vertex push last popped vertex back onto S push 𝑝 𝑖 onto S. 4. Add diagonals from the last vertex p n to all stack vertices except first and last P2 P3 P4 P5 P6 Stack S P4 P2 P7 P8 i=5 Processing P5 P9

38 Triangulation of Polygons – Y monotones
3. For i←3 𝑡𝑜 𝑛−1 3.1 If 𝒑 𝐢 𝐚𝐧𝐝 𝐭𝐨𝐩 𝐒 are on different chains 3.1.1 Pop all vertices from S and add a diagonal between 𝒑 𝒊 and each popped vertex except the last. 3.1.2 push p i−1 and p i onto S 3.2 Else 3.2.1 Pop(s) 3.2.1 pop the other vertices from S while they are visible from 𝑝 𝑖 , and add a diagonal between 𝑝 𝑖 and each popped vertex push last popped vertex back onto S push 𝑝 𝑖 onto S. 4. Add diagonals from the last vertex p n to all stack vertices except first and last P2 P3 P4 P5 P6 Stack S P7 P8 i=5 Processing P5 P9

39 Triangulation of Polygons – Y monotones
3. For i←3 𝑡𝑜 𝑛−1 3.1 If 𝒑 𝐢 𝐚𝐧𝐝 𝐭𝐨𝐩 𝐒 are on different chains 3.1.1 Pop all vertices from S and add a diagonal between 𝑝 𝑖 and each popped vertex except the last. 3.1.2 push 𝒑 𝐢−𝟏 and 𝒑 𝒊 onto S 3.2 Else 3.2.1 Pop(s) 3.2.1 pop the other vertices from S while they are visible from 𝑝 𝑖 , and add a diagonal between 𝑝 𝑖 and each popped vertex push last popped vertex back onto S push 𝑝 𝑖 onto S. 4. Add diagonals from the last vertex p n to all stack vertices except first and last P2 P3 P4 P5 P6 Stack S P7 P8 i=5 Processing P5 P9

40 Triangulation of Polygons – Y monotones
3. For i←3 𝑡𝑜 𝑛−1 3.1 If 𝒑 𝐢 𝐚𝐧𝐝 𝐭𝐨𝐩 𝐒 are on different chains 3.1.1 Pop all vertices from S and add a diagonal between 𝑝 𝑖 and each popped vertex except the last. 3.1.2 push 𝒑 𝐢−𝟏 and 𝒑 𝒊 onto S 3.2 Else 3.2.1 Pop(s) 3.2.1 pop the other vertices from S while they are visible from 𝑝 𝑖 , and add a diagonal between 𝑝 𝑖 and each popped vertex push last popped vertex back onto S push 𝑝 𝑖 onto S. 4. Add diagonals from the last vertex p n to all stack vertices except first and last P2 P3 P4 P5 P6 Stack S P5 P4 P7 P8 i=5 Processing P5 P9

41 Triangulation of Polygons – Y monotones
3. For 𝐢←𝟑 𝒕𝒐 𝒏−𝟏 3.1 If 𝑝 i and top S are on different chains 3.1.1 Pop all vertices from S and add a diagonal between 𝑝 𝑖 and each popped vertex except the last. 3.1.2 push 𝑝 𝑖−1 and 𝑝 𝑖 onto S 3.2 Else 3.2.1 Pop(s) 3.2.1 pop the other vertices from S while they are visible from 𝑝 𝑖 , and add a diagonal between 𝑝 𝑖 and each popped vertex push last popped vertex back onto S push 𝑝 𝑖 onto S. 4. Add diagonals from the last vertex p n to all stack vertices except first and last P2 P3 P4 P5 P6 Stack S P5 P4 P7 P8 i=6 Processing P6 P9

42 Triangulation of Polygons – Y monotones
3. For i←3 𝑡𝑜 𝑛−1 3.1 If 𝑝 i and top S are on different chains 3.1.1 Pop all vertices from S and add a diagonal between 𝑝 𝑖 and each popped vertex except the last. 3.1.2 push 𝑝 𝑖−1 and 𝑝 𝑖 onto S 3.2 Else 3.2.1 Pop(s) 3.2.1 pop the other vertices from S while they are visible from 𝑝 𝑖 , and add a diagonal between 𝑝 𝑖 and each popped vertex push last popped vertex back onto S push 𝑝 𝑖 onto S. 4. Add diagonals from the last vertex p n to all stack vertices except first and last P2 P3 P4 P5 P6 Stack S P5 P4 P7 P8 i=6 Processing P6 P9

43 Triangulation of Polygons – Y monotones
3. For i←3 𝑡𝑜 𝑛−1 3.1 If 𝑝 i and top S are on different chains 3.1.1 Pop all vertices from S and add a diagonal between 𝑝 𝑖 and each popped vertex except the last. 3.1.2 push 𝑝 𝑖−1 and 𝑝 𝑖 onto S 3.2 Else 3.2.1 Pop(s) 3.2.1 pop the other vertices from S while they are visible from 𝑝 𝑖 , and add a diagonal between 𝑝 𝑖 and each popped vertex push last popped vertex back onto S push 𝑝 𝑖 onto S. 4. Add diagonals from the last vertex p n to all stack vertices except first and last P2 P3 P4 P5 P6 Stack S P5 P4 P7 P8 i=6 Processing P6 P9

44 Triangulation of Polygons – Y monotones
3. For i←3 𝑡𝑜 𝑛−1 3.1 If 𝑝 i and top S are on different chains 3.1.1 Pop all vertices from S and add a diagonal between 𝑝 𝑖 and each popped vertex except the last. 3.1.2 push 𝑝 𝑖−1 and 𝑝 𝑖 onto S 3.2 Else 3.2.1 Pop(s) 3.2.1 pop the other vertices from S while they are visible from 𝑝 𝑖 , and add a diagonal between 𝑝 𝑖 and each popped vertex push last popped vertex back onto S push 𝑝 𝑖 onto S. 4. Add diagonals from the last vertex p n to all stack vertices except first and last P2 P3 P4 P5 P6 Stack S P4 P7 P8 i=6 Processing P6 P9

45 Triangulation of Polygons – Y monotones
3. For i←3 𝑡𝑜 𝑛−1 3.1 If 𝑝 i and top S are on different chains 3.1.1 Pop all vertices from S and add a diagonal between 𝑝 𝑖 and each popped vertex except the last. 3.1.2 push 𝑝 𝑖−1 and 𝑝 𝑖 onto S 3.2 Else 3.2.1 Pop(s) 3.2.1 pop the other vertices from S while they are visible from 𝒑 𝒊 , and add a diagonal between 𝒑 𝒊 and each popped vertex push last popped vertex back onto S push 𝑝 𝑖 onto S. 4. Add diagonals from the last vertex p n to all stack vertices except first and last P2 P3 P4 P5 P6 Stack S P4 P7 P8 i=6 Processing P6 P9

46 Triangulation of Polygons – Y monotones
3. For i←3 𝑡𝑜 𝑛−1 3.1 If 𝑝 i and top S are on different chains 3.1.1 Pop all vertices from S and add a diagonal between 𝑝 𝑖 and each popped vertex except the last. 3.1.2 push 𝑝 𝑖−1 and 𝑝 𝑖 onto S 3.2 Else 3.2.1 Pop(s) 3.2.1 pop the other vertices from S while they are visible from 𝒑 𝒊 , and add a diagonal between 𝒑 𝒊 and each popped vertex push last popped vertex back onto S push 𝑝 𝑖 onto S. 4. Add diagonals from the last vertex p n to all stack vertices except first and last P2 P3 P4 P5 P6 Stack S P7 P8 i=6 Processing P6 P9

47 Triangulation of Polygons – Y monotones
3. For i←3 𝑡𝑜 𝑛−1 3.1 If 𝑝 i and top S are on different chains 3.1.1 Pop all vertices from S and add a diagonal between 𝑝 𝑖 and each popped vertex except the last. 3.1.2 push 𝑝 𝑖−1 and 𝑝 𝑖 onto S 3.2 Else 3.2.1 Pop(s) 3.2.1 pop the other vertices from S while they are visible from 𝑝 𝑖 , and add a diagonal between 𝑝 𝑖 and each popped vertex push last popped vertex back onto S push 𝑝 𝑖 onto S. 4. Add diagonals from the last vertex p n to all stack vertices except first and last P2 P3 P4 P5 P6 Stack S P7 P8 i=6 Processing P6 P9

48 Triangulation of Polygons – Y monotones
3. For i←3 𝑡𝑜 𝑛−1 3.1 If 𝑝 i and top S are on different chains 3.1.1 Pop all vertices from S and add a diagonal between 𝑝 𝑖 and each popped vertex except the last. 3.1.2 push 𝑝 𝑖−1 and 𝑝 𝑖 onto S 3.2 Else 3.2.1 Pop(s) 3.2.1 pop the other vertices from S while they are visible from 𝑝 𝑖 , and add a diagonal between 𝑝 𝑖 and each popped vertex push last popped vertex back onto S push 𝑝 𝑖 onto S. 4. Add diagonals from the last vertex p n to all stack vertices except first and last P2 P3 P4 P5 P6 Stack S P4 P7 P8 i=6 Processing P6 P9

49 Triangulation of Polygons – Y monotones
3. For i←3 𝑡𝑜 𝑛−1 3.1 If 𝑝 i and top S are on different chains 3.1.1 Pop all vertices from S and add a diagonal between 𝑝 𝑖 and each popped vertex except the last. 3.1.2 push 𝑝 𝑖−1 and 𝑝 𝑖 onto S 3.2 Else 3.2.1 Pop(s) 3.2.1 pop the other vertices from S while they are visible from 𝑝 𝑖 , and add a diagonal between 𝑝 𝑖 and each popped vertex push last popped vertex back onto S push 𝒑 𝒊 onto S. 4. Add diagonals from the last vertex p n to all stack vertices except first and last P2 P3 P4 P5 P6 Stack S P4 P7 P8 i=6 Processing P6 P9

50 Triangulation of Polygons – Y monotones
3. For i←3 𝑡𝑜 𝑛−1 3.1 If 𝑝 i and top S are on different chains 3.1.1 Pop all vertices from S and add a diagonal between 𝑝 𝑖 and each popped vertex except the last. 3.1.2 push 𝑝 𝑖−1 and 𝑝 𝑖 onto S 3.2 Else 3.2.1 Pop(s) 3.2.1 pop the other vertices from S while they are visible from 𝑝 𝑖 , and add a diagonal between 𝑝 𝑖 and each popped vertex push last popped vertex back onto S push 𝒑 𝒊 onto S. 4. Add diagonals from the last vertex p n to all stack vertices except first and last P2 P3 P4 P5 P6 Stack S P4 P6 P7 P8 i=6 Processing P6 P9

51 Triangulation of Polygons – Y monotones
3. For 𝐢←𝟑 𝒕𝒐 𝒏−𝟏 3.1 If 𝑝 i and top S are on different chains 3.1.1 Pop all vertices from S and add a diagonal between 𝑝 𝑖 and each popped vertex except the last. 3.1.2 push 𝑝 𝑖−1 and 𝑝 𝑖 onto S 3.2 Else 3.2.1 Pop(s) 3.2.1 pop the other vertices from S while they are visible from 𝑝 𝑖 , and add a diagonal between 𝑝 𝑖 and each popped vertex push last popped vertex back onto S push 𝑝 𝑖 onto S. 4. Add diagonals from the last vertex p n to all stack vertices except first and last P2 P3 P4 P5 P6 Stack S P4 P6 P7 P8 i=7 Processing P7 P9

52 Triangulation of Polygons – Y monotones
3. For i←3 𝑡𝑜 𝑛−1 3.1 If 𝑝 i and top S are on different chains 3.1.1 Pop all vertices from S and add a diagonal between 𝑝 𝑖 and each popped vertex except the last. 3.1.2 push 𝑝 𝑖−1 and 𝑝 𝑖 onto S 3.2 Else 3.2.1 Pop(s) 3.2.1 pop the other vertices from S while they are visible from 𝑝 𝑖 , and add a diagonal between 𝑝 𝑖 and each popped vertex push last popped vertex back onto S push 𝑝 𝑖 onto S. 4. Add diagonals from the last vertex p n to all stack vertices except first and last P2 P3 P4 P5 P6 Stack S P4 P6 P7 P8 i=7 Processing P7 P9

53 Triangulation of Polygons – Y monotones
3. For i←3 𝑡𝑜 𝑛−1 3.1 If 𝑝 i and top S are on different chains 3.1.1 Pop all vertices from S and add a diagonal between 𝑝 𝑖 and each popped vertex except the last. 3.1.2 push 𝑝 𝑖−1 and 𝑝 𝑖 onto S 3.2 Else 3.2.1 Pop(s) 3.2.1 pop the other vertices from S while they are visible from 𝑝 𝑖 , and add a diagonal between 𝑝 𝑖 and each popped vertex push last popped vertex back onto S push 𝑝 𝑖 onto S. 4. Add diagonals from the last vertex p n to all stack vertices except first and last P2 P3 P4 P5 P6 Stack S P4 P6 P7 P8 i=7 Processing P7 P9

54 Triangulation of Polygons – Y monotones
3. For i←3 𝑡𝑜 𝑛−1 3.1 If 𝑝 i and top S are on different chains 3.1.1 Pop all vertices from S and add a diagonal between 𝑝 𝑖 and each popped vertex except the last. 3.1.2 push 𝑝 𝑖−1 and 𝑝 𝑖 onto S 3.2 Else 3.2.1 Pop(s) 3.2.1 pop the other vertices from S while they are visible from 𝑝 𝑖 , and add a diagonal between 𝑝 𝑖 and each popped vertex push last popped vertex back onto S push 𝑝 𝑖 onto S. 4. Add diagonals from the last vertex p n to all stack vertices except first and last P2 P3 P4 P5 P6 Stack S P6 P7 P8 i=7 Processing P7 P9

55 Triangulation of Polygons – Y monotones
3. For i←3 𝑡𝑜 𝑛−1 3.1 If 𝑝 i and top S are on different chains 3.1.1 Pop all vertices from S and add a diagonal between 𝑝 𝑖 and each popped vertex except the last. 3.1.2 push 𝑝 𝑖−1 and 𝑝 𝑖 onto S 3.2 Else 3.2.1 Pop(s) 3.2.1 pop the other vertices from S while they are visible from 𝒑 𝒊 , and add a diagonal between 𝒑 𝒊 and each popped vertex push last popped vertex back onto S push 𝑝 𝑖 onto S. 4. Add diagonals from the last vertex p n to all stack vertices except first and last P2 P3 P4 P5 P6 Stack S P6 P7 P8 i=7 Processing P7 P9

56 Triangulation of Polygons – Y monotones
3. For i←3 𝑡𝑜 𝑛−1 3.1 If 𝑝 i and top S are on different chains 3.1.1 Pop all vertices from S and add a diagonal between 𝑝 𝑖 and each popped vertex except the last. 3.1.2 push 𝑝 𝑖−1 and 𝑝 𝑖 onto S 3.2 Else 3.2.1 Pop(s) 3.2.1 pop the other vertices from S while they are visible from 𝒑 𝒊 , and add a diagonal between 𝒑 𝒊 and each popped vertex push last popped vertex back onto S push 𝑝 𝑖 onto S. 4. Add diagonals from the last vertex p n to all stack vertices except first and last P2 P3 P4 P5 P6 Stack S P7 P8 i=7 Processing P7 P9

57 Triangulation of Polygons – Y monotones
3. For i←3 𝑡𝑜 𝑛−1 3.1 If 𝑝 i and top S are on different chains 3.1.1 Pop all vertices from S and add a diagonal between 𝑝 𝑖 and each popped vertex except the last. 3.1.2 push 𝑝 𝑖−1 and 𝑝 𝑖 onto S 3.2 Else 3.2.1 Pop(s) 3.2.1 pop the other vertices from S while they are visible from 𝑝 𝑖 , and add a diagonal between 𝑝 𝑖 and each popped vertex push last popped vertex back onto S push 𝑝 𝑖 onto S. 4. Add diagonals from the last vertex p n to all stack vertices except first and last P2 P3 P4 P5 P6 Stack S P7 P8 i=7 Processing P7 P9

58 Triangulation of Polygons – Y monotones
3. For i←3 𝑡𝑜 𝑛−1 3.1 If 𝑝 i and top S are on different chains 3.1.1 Pop all vertices from S and add a diagonal between 𝑝 𝑖 and each popped vertex except the last. 3.1.2 push 𝑝 𝑖−1 and 𝑝 𝑖 onto S 3.2 Else 3.2.1 Pop(s) 3.2.1 pop the other vertices from S while they are visible from 𝑝 𝑖 , and add a diagonal between 𝑝 𝑖 and each popped vertex push last popped vertex back onto S push 𝑝 𝑖 onto S. 4. Add diagonals from the last vertex p n to all stack vertices except first and last P2 P3 P4 P5 P6 Stack S P6 P7 P8 i=7 Processing P7 P9

59 Triangulation of Polygons – Y monotones
3. For i←3 𝑡𝑜 𝑛−1 3.1 If 𝑝 i and top S are on different chains 3.1.1 Pop all vertices from S and add a diagonal between 𝑝 𝑖 and each popped vertex except the last. 3.1.2 push 𝑝 𝑖−1 and 𝑝 𝑖 onto S 3.2 Else 3.2.1 Pop(s) 3.2.1 pop the other vertices from S while they are visible from 𝑝 𝑖 , and add a diagonal between 𝑝 𝑖 and each popped vertex push last popped vertex back onto S push 𝒑 𝒊 onto S. 4. Add diagonals from the last vertex p n to all stack vertices except first and last P2 P3 P4 P5 P6 Stack S P6 P7 P8 i=7 Processing P7 P9

60 Triangulation of Polygons – Y monotones
3. For i←3 𝑡𝑜 𝑛−1 3.1 If 𝑝 i and top S are on different chains 3.1.1 Pop all vertices from S and add a diagonal between 𝑝 𝑖 and each popped vertex except the last. 3.1.2 push 𝑝 𝑖−1 and 𝑝 𝑖 onto S 3.2 Else 3.2.1 Pop(s) 3.2.1 pop the other vertices from S while they are visible from 𝑝 𝑖 , and add a diagonal between 𝑝 𝑖 and each popped vertex push last popped vertex back onto S push 𝒑 𝒊 onto S. 4. Add diagonals from the last vertex p n to all stack vertices except first and last P2 P3 P4 P5 P6 Stack S P7 P6 P7 P8 i=7 Processing P7 P9

61 Triangulation of Polygons – Y monotones
3. For 𝐢←𝟑 𝒕𝒐 𝒏−𝟏 3.1 If 𝑝 i and top S are on different chains 3.1.1 Pop all vertices from S and add a diagonal between 𝑝 𝑖 and each popped vertex except the last. 3.1.2 push 𝑝 𝑖−1 and 𝑝 𝑖 onto S 3.2 Else 3.2.1 Pop(s) 3.2.1 pop the other vertices from S while they are visible from 𝑝 𝑖 , and add a diagonal between 𝑝 𝑖 and each popped vertex push last popped vertex back onto S push 𝑝 𝑖 onto S. 4. Add diagonals from the last vertex p n to all stack vertices except first and last P2 P3 P4 P5 P6 Stack S P7 P6 P7 P8 i=8 Processing P8 P9

62 Triangulation of Polygons – Y monotones
3. For i←3 𝑡𝑜 𝑛−1 3.1 If 𝒑 𝐢 𝐚𝐧𝐝 𝐭𝐨𝐩 𝐒 are on different chains 3.1.1 Pop all vertices from S and add a diagonal between 𝑝 𝑖 and each popped vertex except the last. 3.1.2 push 𝑝 𝑖−1 and 𝑝 𝑖 onto S 3.2 Else 3.2.1 Pop(s) 3.2.1 pop the other vertices from S while they are visible from 𝑝 𝑖 , and add a diagonal between 𝑝 𝑖 and each popped vertex push last popped vertex back onto S push 𝑝 𝑖 onto S. 4. Add diagonals from the last vertex p n to all stack vertices except first and last P2 P3 P4 P5 P6 Stack S P7 P6 P7 P8 i=8 Processing P8 P9

63 Triangulation of Polygons – Y monotones
3. For i←3 𝑡𝑜 𝑛−1 3.1 If 𝒑 𝐢 𝐚𝐧𝐝 𝐭𝐨𝐩 𝐒 are on different chains 3.1.1 Pop all vertices from S and add a diagonal between 𝒑 𝒊 and each popped vertex except the last. 3.1.2 push 𝑝 𝑖−1 and 𝑝 𝑖 onto S 3.2 Else 3.2.1 Pop(s) 3.2.1 pop the other vertices from S while they are visible from 𝑝 𝑖 , and add a diagonal between 𝑝 𝑖 and each popped vertex push last popped vertex back onto S push 𝑝 𝑖 onto S. 4. Add diagonals from the last vertex p n to all stack vertices except first and last P2 P3 P4 P5 P6 Stack S P7 P6 P7 P8 i=8 Processing P8 P9

64 Triangulation of Polygons – Y monotones
3. For i←3 𝑡𝑜 𝑛−1 3.1 If 𝒑 𝐢 𝐚𝐧𝐝 𝐭𝐨𝐩 𝐒 are on different chains 3.1.1 Pop all vertices from S and add a diagonal between 𝒑 𝒊 and each popped vertex except the last. 3.1.2 push 𝑝 𝑖−1 and 𝑝 𝑖 onto S 3.2 Else 3.2.1 Pop(s) 3.2.1 pop the other vertices from S while they are visible from 𝑝 𝑖 , and add a diagonal between 𝑝 𝑖 and each popped vertex push last popped vertex back onto S push 𝑝 𝑖 onto S. 4. Add diagonals from the last vertex p n to all stack vertices except first and last P2 P3 P4 P5 P6 Stack S P7 P8 i=8 Processing P8 P9

65 Triangulation of Polygons – Y monotones
3. For i←3 𝑡𝑜 𝑛−1 3.1 If 𝒑 𝐢 𝐚𝐧𝐝 𝐭𝐨𝐩 𝐒 are on different chains 3.1.1 Pop all vertices from S and add a diagonal between 𝑝 𝑖 and each popped vertex except the last. 3.1.2 push 𝒑 𝒊−𝟏 and 𝒑 𝒊 onto S 3.2 Else 3.2.1 Pop(s) 3.2.1 pop the other vertices from S while they are visible from 𝑝 𝑖 , and add a diagonal between 𝑝 𝑖 and each popped vertex push last popped vertex back onto S push 𝑝 𝑖 onto S. 4. Add diagonals from the last vertex p n to all stack vertices except first and last P2 P3 P4 P5 P6 Stack S P7 P8 i=8 Processing P8 P9

66 Triangulation of Polygons – Y monotones
3. For i←3 𝑡𝑜 𝑛−1 3.1 If 𝒑 𝐢 𝐚𝐧𝐝 𝐭𝐨𝐩 𝐒 are on different chains 3.1.1 Pop all vertices from S and add a diagonal between 𝑝 𝑖 and each popped vertex except the last. 3.1.2 push 𝒑 𝒊−𝟏 and 𝒑 𝒊 onto S 3.2 Else 3.2.1 Pop(s) 3.2.1 pop the other vertices from S while they are visible from 𝑝 𝑖 , and add a diagonal between 𝑝 𝑖 and each popped vertex push last popped vertex back onto S push 𝑝 𝑖 onto S. 4. Add diagonals from the last vertex p n to all stack vertices except first and last P2 P3 P4 P5 P6 Stack S P8 P7 P7 P8 i=8 Processing P8 P9

67 Triangulation of Polygons – Y monotones
3. For 𝐢←𝟑 𝒕𝒐 𝒏−𝟏 3.1 If 𝑝 i and top S are on different chains 3.1.1 Pop all vertices from S and add a diagonal between 𝑝 𝑖 and each popped vertex except the last. 3.1.2 push 𝑝 𝑖−1 and 𝑝 𝑖 onto S 3.2 Else 3.2.1 Pop(s) 3.2.1 pop the other vertices from S while they are visible from 𝑝 𝑖 , and add a diagonal between 𝑝 𝑖 and each popped vertex push last popped vertex back onto S push 𝑝 𝑖 onto S. 4. Add diagonals from the last vertex p n to all stack vertices except first and last P2 P3 P4 P5 P6 Stack S P8 P7 P7 P8 i=9 Processing P9 P9

68 Triangulation of Polygons – Y monotones
3. For i←3 𝑡𝑜 𝑛−1 3.1 If 𝑝 i and top S are on different chains 3.1.1 Pop all vertices from S and add a diagonal between 𝑝 𝑖 and each popped vertex except the last. 3.1.2 push 𝑝 𝑖−1 and 𝑝 𝑖 onto S 3.2 Else 3.2.1 Pop(s) 3.2.1 pop the other vertices from S while they are visible from 𝑝 𝑖 , and add a diagonal between 𝑝 𝑖 and each popped vertex push last popped vertex back onto S push 𝑝 𝑖 onto S. 4. Add diagonals from the last vertex 𝒑 𝒏 to all stack vertices except first and last P2 P3 P4 P5 P6 Stack S P8 P7 P7 P8 i=4 Processing P9 P9

69 Creating Y monotones Start Vertex

70 Creating Y monotones Start Vertex Regular Vertex

71 Creating Y monotones Start Vertex Regular Vertex

72 Creating Y monotones Start Vertex Regular Vertex Merge Vertex

73 Creating Y monotones Start Vertex Merge Vertex Regular Vertex

74 Creating Y monotones Start Vertex Merge Vertex Regular Vertex
Split Vertex

75 Creating Y monotones Start Vertex Merge Vertex Regular Vertex
Split Vertex

76 Creating Y monotones Start Vertex Merge Vertex Regular Vertex
Split Vertex End Vertex

77 Creating Y monotones Start Vertex Merge Vertex Regular Vertex
Split Vertex End Vertex

78 Creating Y monotones Start Vertex Merge Vertex Regular Vertex
Split Vertex End Vertex

79 Creating Y monotones To partition P into a y-montones, we need to get rid of spilt (Purple) and merge (Red) nodes

80 Creating Y monotones To partition P into y-montones, we need to get rid of spilt (Purple) and merge (Red) nodes Downward diagonals from merge nodes Upward diagonals from split nodes

81 Creating Y monotones To partition P into y-montones, we need to get rid of spilt (Purple) and merge (Red) nodes Downward diagonals from merge nodes Upward diagonals from split nodes 2. Where do edges go?

82 Creating Y monotones Helpers:
Let helper(ej) be the lowest vertex above the sweep-line such that the horizontal segment connecting the vertex to ej lies inside P ej Helper(ej)

83 Creating Y monotones Removing Merge Nodes: For a merge node (vj), Let ej be the edge immediately to the left of it. vj becomes the helper once we reach it Whenever helper(ej) is replaced by some. vertex vm, add a diagonal from vm to vj. vj ej

84 Creating Y monotones Removing Merge Nodes: For a merge node (vj), Let ej be the edge immediately to the left of it. vj becomes the helper once we reach it Whenever helper(ej) is replaced by some. vertex vm, add a diagonal from vm to vj. If it is never replaced then we can connect it to lower end point of ej vj ej vm

85 Creating Y monotones Removing Split Nodes: For a split vertex (vj), Let ej be the edge immediately to the left of it. Add a diagonal from vj to helper(ej) ej Helper(ej)

86 Where would this be connected?
Creating Y monotones Removing Split Nodes: For a split vertex (vj), Let ej be the edge immediately to the left of it. Add a diagonal from vj to helper(ej) ej Helper(ej) Where would this be connected?


Download ppt "Introduction to Spatial Computing CSE 555"

Similar presentations


Ads by Google