Presentation is loading. Please wait.

Presentation is loading. Please wait.

Efficient access to TIN Regular square grid TIN Efficient access to TIN Let q := (x, y) be a point. We want to estimate an elevation at a point q: 1. should.

Similar presentations


Presentation on theme: "Efficient access to TIN Regular square grid TIN Efficient access to TIN Let q := (x, y) be a point. We want to estimate an elevation at a point q: 1. should."— Presentation transcript:

1 Efficient access to TIN Regular square grid TIN Efficient access to TIN Let q := (x, y) be a point. We want to estimate an elevation at a point q: 1. should find a triangle of a TIN that includes q 2. use some method (like interpolation, weighted average etc.) to estimate an elevation We will discuss methods for the part 1. Compare: Regular square grid – direct access to every part of the terrain: translate (x,y) to index values in grid array. TIN – since it is a pointer structure, we should test each triangle. Inefficient.1

2 Access using quad trees: We will discuss three methods of efficient access to a TIN: Access using quad trees: quad tree is a regular tree of degree 4. Its nodes represent a recursive decomposition of a big square (a root) into four subsquares (the children of the root), and so on. Decomposition stops when the part of the TIN that falls in the subsquare is simple enough – only a few vertices lie inside the square. t2 t3 t1 t4 t5 t6 t7t8 t9 t10 t11 t4 x1x1 x2x2 x3x3 x4x4 y1y1 y2y2 y3y3 y4y4 y5y5 2

3 Access using quad trees: We will discuss three methods of efficient access to TIN: Access using quad trees: quad tree is a regular search tree of degree 4. Its nodes represent a recursive decomposition of a big square (a root) into four subsquares (the children of the root), and so on. Decomposition stops when the part of the TIN that falls in the subsquare is simple enough – only a few vertices lie inside the square. t2 t3 t1 t4 t5 t6 t7t8 t9 t10 t11 t4 t1t2t4t8t7t5t6 … … At leaf node we store a pointer to a triangle that contains the center of the square. To find a triangle that contains q: 1) go down the tree till get a triangle 2)walk in the topological structure to locate the triangle that contains the query point. x1x1 x2x2 x3x3 x4x4 y1y1 y2y2 y3y3 y4y4 x5x5 y5y5 (x 1, y 1 ),(x 5, y 5 ) (x 3, y 1 ),(x 5, y 3 ) (x 1, y 3 ),(x 3, y 5 ) 3

4 2) walk in the topological structure to locate the triangle that contains the query point: - start with the triangle t 1 since it contains the center of the base rectangle that contains q. - tests all the neighbor triangles of t 1 - tests all the neighbor triangles of the neighbor triangles of t 1 and so on… a base rectangle; points to the triangle that contains its center t1 In our case, we would find the queried point q in the second round. 4

5 Another possibility is to take the smallest enclosing axis-parallel rectangle of each triangle of the TIN: t1t1 t5t5 t4t4 t3t3 t2t2 t1t1 t2t2 t3t3 t4t4 t5t5 In our example, got five rectangles. Now we execute quad tree algorithm on them. When get a query of a point q, we will find all the rectangles (leafs) that contain q, and then, testing the triangles of those rectangles find the triangle that contains the point q. 5

6 Access using planar point location: Access using Jump-and-walk strategy: We choose a set of m points p 1, …, p m. When we query with a point q, we first determine the point p i closest to q and then trace the line segment p i q, starting at the triangle containing p i. Access using planar point location: For a TIN with n triangles, it is possible to construct and O(n) size data structure that allows for point location in O(log n) time. (Saw in one of the previous lectures) Access using Jump-and-walk strategy: Let p be a point of a TIN, and q be a queried point. We traverse the TIN in a straight line from p to q. We choose a set of m points p 1, …, p m. When we query with a point q, we first determine the point p i closest to q and then trace the line segment p i q, starting at the triangle containing p i. We typically encounter much fewer triangles on the way than if we would traverse the whole structure. If m ~ n 1/3, the expected query time is O(n 1/3 ) under some distribution assumptions. Example: Suppose {p 1, p 2, p 3 } is a chosen set of points and q is a query point. Since p 3 is the closest point to q, it is a start point. The triangle t 1 contains it. We can compute in O(1) which edge t 1 of intersects with p i q. This edge contains pointer to two triangles that share it – in our case t 1 and t 2. So we move to the triangle t 2 and test if it contains q. If so, stop and return the current triangle. If not, repeat the process when the staring point is the intersection point of the edge of the current triangle with p i q. t1 t2 t3 t46

7 Windowing: Windowing: Sometimes a user is interested in a part of a terrain, that is defined by some window. All triangles intersecting that rectangle should be located. The algorithm consists of two steps: 1) locate the position of the window on the terrain 2) locate all the TIN triangles that intersect with the window For example, we can traverse TIN from the upper left corner of the window to the upper right corner, then from the upper right corner to the bottom right corner and so on, using Jump-and-Walk strategy with given starting point. The traversal can be done in time linear in the number of triangles intersecting the window. 7

8 Converting between terrain models Converting between terrain models contour line grid Terrain data is entered into a GIS in various formats: - contour line, if maps are digitized by hand - grid, if data is acquired by remote sensing photo-interpretation. random terrain point sample data grid contour line TIN - random terrain point sample data There are various reasons why data in one format may need to be transformed into another: 1) grid is huge in size – high memory requirements, slow algorithms execution 2) contour line often needs to be interpreted anyway before anything useful can be done with it :) 3) TIN is visualized as a contour map 8

9 Conversion from point sample data to TIN: Conversion from point sample data to TIN: Suppose a set P of n points in the plane is given, each with an elevation value. To convert this information into a TIN, we can simply - triangulate the point set using Delaunay triangulation, for example – it attempts to create well-shaped triangles. - simplify a TIN to get a one with less number of points Note: It is known that the problem of computing a TIN with the minimum number of vertices, given a TIN and a maximum allowed error, is an NP-hard problem. 9

10 Conversion from grid to TIN: Conversion from grid to TIN: We will discuss two algorithms for converting a grid into TIN. Both have the following distinguishing features: 1) select which grid points to keep or discard 2) decide when to stop selecting or discarding 10

11 The drop heuristic method (by Jay Lee): The drop heuristic method (by Jay Lee): A grid can simply be triangulated to a fine regular triangulation and get TIN as a result. After this we would like to reduce number of vertices of a TIN. - takes a TIN as its input, and iteratively discard one vertex at a time. a start TIN (triangulated grid)a result TIN 11

12 The algorithm: The algorithm: To decide which vertex should be discarded we do the following iteration: 1. For each vertex v in the TIN: - temporarily remove v - compute the Delaunay triangulation of the appearing polygon - determine the vertical distance error(v) of v to the new TIN (v lies in one of the new triangles in the polygon, so this is easy to do) - add v back to the TIN Store error(v) for each vertex v in a balanced binary tree T, with point to v. At v we store a pointer back to the corresponding node in T. v is the vertex to removea polygon that appears after v is removed a Delaunay triangulation of the polygon 12

13 2. Consider the node w with smallest error(w) from T. If it is greater than the pre-specified maximum error, the algorithm stops. 3. Remove w from T and from TIN. Let w 1, … w j be the vertices adjacent to w. Triangulate the polygon defined by w 1, … w j using the Delaunay triangulation. 4. For every vertex w i {w 1, … w j } - remove error(w i ) from T. - recompute the vertical distance to the terrain as if w i was removed (like in the first step) and insert it into T. Continue at step 2. Time complexity: O(n log n) Time complexity: typical case – all vertices in the TIN have constant degree. - O(n log n) time to build T that we start with (for each node v it takes a constant time to triangulate a polygon defined by its neighbors, constant time to compute error(v) and O(log n) time to inset it into T ) - each iteration requires O(log n) time: - O(log n) time for minimum search - O(log n) time to delete w - constant time for updating T with appropriate values of error(w i ) the algorithm runs in O(n log n) time. 13

14 Note: suppose in current iteration a node w was discarded, and nodes {w 1, … w k } were discarded before. The error at nodes {w 1, … w k } can become bigger now :( So there is no guarantee that the error at all of the discarded vertices really is within the pre-specified error. The drop heuristic method completely forgets about vertices that are discarded. Although, at the expense of more computation, a variant of the method could still consider them. an elevation of this point is approximated by the triangle t 1 now an elevation of this point is approximated by new the triangle t 2 – the error can become bigger! t1 t214 The second method we would discuss really guarantees that the final TIN has error at most e when e is a part of an input.

15 Incremental refinement: Incremental refinement: takes a grid and a maximum allowed error e as its input. It starts with a coarse TIN with only a few vertices, and keep adding more points from the grid to the TIN to obtain less error. a coarse TINa final TIN with the error <= e 15

16 The algorithm: S The algorithm: 1. Let P be the set of midpoints of grid cells. Let S be a set of four corner points of P and P P \S. To decide which vertex should be added we do the following iteration: 2. Compute the Delaunay triangulation DT(S) of S. 3. For each v P determine in which triangle of DT(S) it falls. Store with each triangle of DT(S) a list of the points of P \S that lie in it. 4. If each v P \S is approximated with an error at most e, the algorithm stops. Otherwise, let w be the point with the maximal error. P P \ {w }, S S U {w }. Continue at step 2. a coarse TINa final TIN with the error <= e 16

17 The algorithm implementation: The algorithm implementation: 1. Naive implementation: - at most n times a Delaunay triangulation is computed; - for each one, the points in P are distributed among the triangles of DT(S). it takes Θ(n 3 ) tests of type “point in triangle”, if linear number of points are added to S. (for each computation of DT(S), for each node v check for each triangle t if v is in t.) 2. Fast implementation: a) Doesn’t compute the Delaunay triangulation from scratch, but updates the existing one. Assume p ∈ P is going to be removed from P and added to S. - locate the triangle t of DT(S) that contains p - find the vertices that will become neighbors of p in DT(S U {p}) (don’t explain how) - update DT(S) only for these vertices ( if k is the number of neighbors of p), it takes O(k + log n) time b) Now we have to distribute points of P \ {p} over the triangles of DT(S U {p}) (only the triangles of which p is a vertex have changed) - collect all the points of the triangles that removed by addition of p - distribute them among the new triangles ( if m is the number of points in the triangles incident to p in DT(S U {p}) ), it takes O(k m) time 17

18 p is the point with the maximum error an updated TIN neighbors of p in DT(S U {p}) k = 5 these points must be relocated 18

19 b) Last step – locating the point v ∈ P \S with a maximum error. Here we use a balanced binary tree 丆.For each triangle of the TIN determine the point of P inside it with the maximum error and store it in 丆. 丆 is sorted on error. The point p with the maximum error is the rightmost leaf of 丆, and this leaf contains a pointer to the triangle of the TIN that contains p. Now the step (a) is executed. Delete from 丆 all the points of the triangles that were destroyed. For each of the new triangles must determine in its list a point with the maximum error and store it in 丆. t1 t2 t3 t5 t4 suppose v is a point with maximum error in t1 v v q1q1 q2q2 q3q3 q1q1 q2q2 q3q3 v a binary tree 丆 that contains one point from each triangle of the TIN with the maximum error each node in 丆 has point to its triangle in the TIN each triangle has a pointer to the list of the nodes it contains p p is a point with the maximum error in the TIN – is going to be added to the TIN For more efficient locating of points that have to be removed from 丆, each point in the list contains pointer to the corresponding node in 丆 (if one exists) t1 19

20 it takes O(log n) time to find p and O(k log n) time to update the tree 丆. So: O(n log n) So: - in the worst case, m and k are both linear in n, giving O(n 3 ). - BUT one can expect that k is usually constant, and after a couple of iteration, m will probably be much smaller than n. the fast implementation of the algorithm takes O(n log n) time under the assumptions given. 20

21 Conversion from contour line to TIN: Conversion from contour line to TIN: Each region of the contour line map can be seen as a polygon with holes. It can be simply triangulated. There is the “constrained Delaunay triangulation” algorithm, that close to the standard Delaunay algorithm, and it takes as an input a set of edges that must be present in the result triangulation. 21

22 The end


Download ppt "Efficient access to TIN Regular square grid TIN Efficient access to TIN Let q := (x, y) be a point. We want to estimate an elevation at a point q: 1. should."

Similar presentations


Ads by Google