E N D
1 Efficient access to TINLet 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 q2. use some method (like interpolation, weighted average etc.) to estimate an elevationWe 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.
2 y5 t3 t1 t2 y4 t4 y3 t4 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. t8 t7 t5 y2 t10 t9 t6 y1 t11 x1 x2 x3 x4
3 (x1, y1),(x5, y5) y5 (x1, y3),(x3, y5) t3 t1 t2 (x3, y1),(x5, y3) y4 t4 … y3 t4 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. t8 t7 t5 y2 t10 t9 t6 y1 t11 … t1 t2 t4 t8 t7 t5 t6 t6 x1 x2 x3 x4 x5 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 triangle2)walk in the topological structure to locate the triangle that contains the query point.
4 2) walk in the topological structure to locate the triangle that contains the query point:- start with the triangle t1 since it contains the center of the base rectangle that contains q.- tests all the neighbor triangles of t1- tests all the neighbor triangles of the neighbor triangles of t1 and so on… t1 a base rectangle;points to the triangle that contains its center In our case, we would find the queried point q in the second round.
5 Another possibility is to take the smallest enclosing axis-parallel rectangle of each triangle of the TIN: t2 t2 t3 t3 t1 t1 t5 t4 t4 t5 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.
6 Example:Suppose {p1 , p2 , p3 } is a chosen set of points and q isa query point.Since p3 is the closest point to q, it is a start point. The triangle t1 contains it.We can compute in O(1) which edge t1 of intersects with pi q. This edge contains pointer to two triangles that share it – in our case t1 and t2. So we move to the triangle t2 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 pi q. 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 p1, …, pm. When we query with a point q, we first determine the point pi closest to q and then trace the line segment pi q, starting at the triangle containing pi. t4 t3 t2 t1 We typically encounter much fewer triangles on the way than if we would traverse the whole structure.If m ~ n1/3, the expected query time is O(n 1/3) under some distribution assumptions.
7 The algorithm consists of two steps:1) locate the position of the window on the terrain2) locate all the TIN triangles that intersect with the windowFor 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. 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 traversal can be done in time linear in the number of triangles intersecting the window.
8 Converting between terrain models 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 dataThere 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 execution2) contour line often needs to be interpreted anyway before anything useful can be done with it :)3) TIN is visualized as a contour map
9 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 pointsNote: 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.
10 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 discard2) decide when to stop selecting or discarding
11 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
12 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 remove a polygon that appears after v is removed a Delaunay triangulation of the polygon
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 w1, … wj be the vertices adjacent to w. Triangulate the polygon defined by w1, … wj using the Delaunay triangulation.4. For every vertex wi{w1, … wj } - remove error(wi) from T. - recompute the vertical distance to the terrain as if wi was removed (like in the first step) and insert it into T. Continue at step 2. 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(wi) the algorithm runs in O(n log n) time.
14 t1 t2 Note: suppose in current iteration a node w was discarded, and nodes {w1, … wk } were discarded before. The error at nodes {w1, … wk } 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 t1 now an elevation of this point is approximated by new the triangle t2 – the error can become bigger! 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 a coarse TIN a final TIN with the error <= e 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.
16 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 PP \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 vPdetermine 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 vP \S is approximated with an error at most e, the algorithm stops. Otherwise, let w be the point with the maximal error.PP \ {w }, SSU {w }.Continue at step 2. a coarse TIN a final TIN with the error <= e
17 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 Θ(n3) 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
18 neighbors of p in DT(S U {p}) k = 5 these points must be relocated p is the point with the maximum error an updated TIN
p 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) p is a point with the maximum error in the TIN – is going to be added to the TIN 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 丆. a binary tree 丆that contains one point from each triangle of the TIN with the maximum error q1 t2 t3 v v q2 t1 t4 q3 t5 t1 each node in 丆 has point to its triangle in the TIN v q1 q2 q3 suppose v is a point with maximum error in t1 each triangle has a pointer to the list of the nodes it contains
20 it takes O(log n) time to find p and O(k log n) time to update the tree 丆. So:- in the worst case, m and k are both linear in n, giving O(n3) .- 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.
21 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.