22
Efficient access to 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 Regular square grid – direct access to every part of the terrain: translate (x,y) to index values in grid array. TIN TIN – since it is a pointer structure, we should test each triangle. Inefficient . 1 1

t10

Embed Size (px)

DESCRIPTION

1. - PowerPoint PPT Presentation

Citation preview

Efficient access to TINEfficient 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 q2. use some method (like interpolation, weighted average etc.) to estimate an elevation

We will discuss methods for the part 1.

Compare:Regular square gridRegular square grid – direct access to every part of the terrain: translate (x,y) to index values in grid array.TINTIN – since it is a pointer structure, we should test each triangle. Inefficient.

11

We will discuss three methods of efficient access to a TIN:

Access using quad trees: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.

t2t3

t1t4

t5

t6

t7t8

t9

t10

t11

t4

x1 x2 x3 x4

y1

y2

y3

y4

y5

22

We will discuss three methods of efficient access to TIN:

Access using quad trees: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.

t2t3

t1t4

t5

t6

t7t8

t9

t10

t11

t4

t1 t2 t4 t8 t7 t5 t6 t6…

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.

x1 x2 x3 x4

y1

y2

y3

y4

x5

y5(x1, y1(,)x5, y5)

(x3, y1(,)x5, y3)

(x1, y3(,)x3, y5)

33

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…

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.

44

Another possibility is to take the smallest enclosing axis-parallel rectangle of each triangle of the TIN:

t1

t5 t4

t3

t2

t1

t2

t3

t4t5

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.

55

Access using planar point location: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: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 pWe choose a set of m points p11, …, p, …, pmm. When we query with a point q, we first determine the . When we query with a point q, we first determine the

point ppoint pii closest to q and then trace the line segment p closest to q and then trace the line segment p i i q, starting at the triangle containing pq, starting at the triangle containing p ii..

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 {p1 , p2 , p3 } is a chosen set of points and q is a 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.

t1

t2

t3

t4

66

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 terrain2) 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.

77

Converting between terrain modelsConverting between terrain models

Terrain data is entered into a GIS in various formats:- contour linecontour line, if maps are digitized by hand- gridgrid, if data is acquired by remote sensing photo-interpretation.

-random terrain point sample datarandom terrain point sample data

There are various reasons why data in one format may need to be transformed into another:1) gridgrid is huge in size – high memory requirements, slow algorithms execution2) contour linecontour line often needs to be interpreted anyway before anything useful can be done with it :)3) TINTIN is visualized as a contour map

88

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.

99

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 discard2) decide when to stop selecting or discarding

1010

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

1111

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 remove a polygon that appears after v is removed

a Delaunay triangulation of the polygon

1212

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: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(O)n log n( time.

1313

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!

t1

t2

1414

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.

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 TIN a final TIN with the error <= e

1515

The algorithm: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 }, SS S U {w }.

Continue at step 2.

a coarse TIN a final TIN with the error <= e

1616

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 Θ(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

1717

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

1818

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

t2t3

t5

t4

suppose v is a point with maximum error in t1

vv

q1

q2

q3

q1 q2 q3v

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

1919

it takes O)log n( time to find p and O)k log n( time to update the tree 丆.

So: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(O)n log n( time under the assumptions given.

2020

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.

2121

The endThe end