15
1/23/2014 1 On TINs and Voronoi daigrams (for class room discussion only) (compiled from web resources) Digital Elevation Models Originally developed as part of the process used to create ortho photos, but now widely used in other calculations (slope, aspect, line of sight, viewsheds, watersheds, etc.) and visualisation. Methods Of Representation Three main methods: Altitude matrices (grid/raster) Isolines - e.g. contours (vector) Triangulated Irregular Networks – TINs (vector) Isolines were the main method in traditional cartography, but are not very flexible for GIS. Altitude Matrices Very flexible for calculating contours, slope, aspects, etc. Disadvantages: Data redundancy if terrain is flat. Do not adjust to relief complexity. Exaggerated emphasis along lines of the grid. TINs TINs represent a surface using contiguous, non-overlapping irregular triangles. The areas inside each triangle have approximately the same slope and elevation. The corners of each triangle are generally at different altitudes. Edges form breaks of slope. Complex terrain can be accommodated using smaller triangles. Known features can be recorded accurately (not interpolated as in a raster). triangles work best in areas with sharp breaks in slope, where TIN edges can be aligned with breaks, e.g. along ridges or channels Conversion Methods TINs to altitude matrices. Grid superimposed. Height in each cell is a distance weighted average of the three corner points of the triangle within which the centre of the grid falls. Altitude matrix to TIN. Three stages: 1. Identify minimum number of corner points for the triangles; 2. Decide which points should be joined to form the triangles; 3. Convert to a data structure.

mod-4-b-Voronoi-TIN

Embed Size (px)

DESCRIPTION

Tin voronoi diagram

Citation preview

Page 1: mod-4-b-Voronoi-TIN

1/23/2014

1

On TINs and Voronoi daigrams

(for class room discussion only)

(compiled from web resources)

Digital Elevation Models

• Originally developed as part of the process used to create ortho photos, but now widely used in other calculations (slope, aspect, line of sight, viewsheds, watersheds, etc.) and visualisation.

Methods Of Representation

• Three main methods:

– Altitude matrices (grid/raster)

– Isolines - e.g. contours (vector)

– Triangulated Irregular Networks – TINs (vector)

• Isolines were the main method in traditional cartography, but are not very flexible for GIS.

Altitude Matrices

• Very flexible for calculating contours, slope, aspects, etc.

• Disadvantages:

– Data redundancy if terrain is flat.

– Do not adjust to relief complexity.

– Exaggerated emphasis along lines of the grid.

TINs

• TINs represent a surface using contiguous, non-overlapping irregular triangles.

• The areas inside each triangle have approximately the same slope and elevation.

• The corners of each triangle are generally at different altitudes.

• Edges form breaks of slope.• Complex terrain can be accommodated using smaller

triangles.• Known features can be recorded accurately (not interpolated

as in a raster).• triangles work best in areas with sharp breaks in slope,

where TIN edges can be aligned with breaks, e.g. along ridges or channels

Conversion Methods

• TINs to altitude matrices. Grid superimposed. Height in each cell is a distance weighted average of the three corner points of the triangle within which the centre of the grid falls.

• Altitude matrix to TIN. Three stages:

– 1. Identify minimum number of corner points for the triangles;

– 2. Decide which points should be joined to form the triangles;

– 3. Convert to a data structure.

Page 2: mod-4-b-Voronoi-TIN

1/23/2014

2

TIN Conversion Algorithms

• At least four methods can be used to decide on the corner points:

– Skeleton method

– Very important point method

– Hierarchy transform method

– Drop heuristic method

• At least two methods can be used to determine ‘joins’:

– Minimum distance

– Delauney triangles

See for details http://www.geog.ubc.ca/courses/klink/gis.notes/ncgia/u39.html

Delauney triangles

• A triangulation for given set of points P is called Delauney if every triangle has empty circumcircle, ie., circle passing through 3 vertices of a triangle does not contain any other point

• For 4 points, we have 2 possible traingulations, of which at least one is Delauney (unless all 4 are on the circle). See fig below.• If one of them not Delauney, we can select the other diagonal (called Lawson

Flip)

• Unique Delauney triangulation exists for P (when no 4 points are on a common circle)

Steps in creating TIN

• 1. how to pick sample points (from some existing, dense DEM or digitized contours) – try to select points at significant breaks of the

surface• Examine using 3x3 windows

• Select all points and then use some hueristic for dropping points

• how to connect points into triangles

• how to model the surface within each triangle– this is almost always resolved by using a plane

surface

Creating Triangles from selected points

• Prefer ‘fat’ traingles

• Distance Ordering method– compute the distance between all pairs of points, and sort

from lowest to highest

– connect the closest pair of points

– connect the next closest pair if the resulting line does not cross earlier lines

– repeat until no further lines can be selected

• Delauney triangulation– Make initial set and then examine groups of 4 at a time and

apply definition and flip

– Use Vornonoi based method

TIN Data Structure

• The data stucture used to record this information includes:

– A node list – i.e. list of the corner points

– A pointer list – for each node a list of the other nodes to which that node is connected (in clockwise direction)

– A trilist – lists the triangle on either side of each link.

Representation in ArcInfo

• Field-based and TIN for representing surfaces

Page 3: mod-4-b-Voronoi-TIN

1/23/2014

3

Voronoi DiagramsPost Office: What is the area of service?

q

q : free point

e

e : Voronoi edge

v

v : Voronoi vertex

pi

pi : site points

Definition of Voronoi Diagram

• Let P be a set of n distinct points (sites) in the plane.

• The Voronoi diagram of P is the subdivision of the plane into n cells, one for each site.

• A point q lies in the cell corresponding to a site pi ∈ P iffEuclidean_Distance( q, pi ) < Euclidean_distance( q, pj ), for each pi ∈ P, j ≠ i.

• We denote the Voronoi diagram of P by Vor(P).The cell that corresponds to a site pi is denotd by V(pi ),called the voronoi cellof pi.

Non-collinear sites form Voronoi half lines that meet at a vertex

A Voronoi vertex is the center of an emptycircle touching 3 or more sites.

v

Half lines

A vertex hasdegree ≥ 3

Voronoi Cells and Segments

v

Voronoi Cells and Segments

v

Unbounded CellBounded Cell

Segment

Four or more non-collinear sites are

necessary to create a bounded cell

Page 4: mod-4-b-Voronoi-TIN

1/23/2014

4

Degenerate Case: no bounded cells!

v

Characteristics of Voronoi Diagrams

1. Voronoi regions (cells) are bounded by line segments.

Special case :

Collinear points

If all the sites are collinear, then Vor(P) consist of n-1 parallel lines and n cells. Otherwise, Vor(P) is a connected graph and its edges are either line segments or half-lines.

Other Characteristics (Assumption: No 4 points are on the circle)

2. Vor(P) is connected

3. Each vertex (corner) of VD(P)has degree 3

4. The circle through the three pointsdefining a Vertex of the Voronoi

diagram does not contain any further point

5. Each nearest neighbor of one point defines an edge of the Voronoi region of the point.

6. The Voronoi region of a point is unbounded iff the point lies exactly on the convex hull of the point set.

Voronoi Diagram/Convex Hull Duality

Sites sharing a half-infinite edge are convex hull vertices

ev

pi

24

Dual: Delaunay Triangulation

Page 5: mod-4-b-Voronoi-TIN

1/23/2014

5

Size and Storage

Size of the Voronoi Diagram:

V(p) can have O(n) vertices

Size of the Voronoi DiagramThe number of vertices in the Voronoi diagram of a set of n points in the plane is at most 2n-5 and the number of edges is at most3n-6.

Example :

Application : Facility Location

• Seek location for new grocery store, whose distance to nearest store is as large as possible — center of largest empty circle

• One restriction: center in convex hull of the sites

Facility Location (cont)

Center in hull: p must be coincident with a voronoi vertex

Center on hull: p must lie on a voronoi edge

Largest Empty CircleOther useful analyses

• Nearest neighbor search

• Cluster analysis : dense sites give Voronoiregions of small area

• Closest pairs (each pair shares an edge)

Page 6: mod-4-b-Voronoi-TIN

1/23/2014

6

Constructing Voronoi Diagrams

Algo 1 : using half plane intersections

Constructing Voronoi Diagrams

Given a half plane intersection algorithm…

Constructing Voronoi Diagrams

Given a half plane intersection algorithm…

Repeat for each site

Running Time: O( n2 log n )

Constructing Voronoi Diagrams

• Algo 2 : Fortune’s Algorithm– Sweep line algorithm

• Voronoi diagram constructed as horizontal line sweeps the set of sites from top to bottom

• Incremental construction � maintains portion of diagram which cannot change due to sites below sweep line, keeping track of incremental changes for each site (and Voronoi vertex) it “sweeps”

Constructing Voronoi Diagrams

What is the invariant we are looking for?

Maintain a representation of the locus of points q that are closer to some site pi above the sweep line than to

the line itself (and thus to any site below the line).

ev

pi

Sweep Line

q

Constructing Voronoi Diagrams

Which points are closer to a site above the sweep line than to the sweep line itself?

Sweep Line

pi

q

The set of parabolic arcs form a beach-line that bounds the locus of all such points

Equidistance

Page 7: mod-4-b-Voronoi-TIN

1/23/2014

7

Constructing Voronoi Diagrams

Break points trace out Voronoi edges.

Equidistance

Sweep Line

pi

q

Constructing Voronoi Diagrams

Arcs flatten out as sweep line moves down.

Sweep Line

pi

q

Algo 3 : Divide and Conquer(Divide)

Input: A set of points (sites)

Output: A partitioning of the plane into regions of equalnearest neighbors.

Divide: Divide the point set into two halves

Divide and Conquer (Conquer)

Conquer: Recursively compute the Voronoi diagrams for the smaller point sets Abort condition: Voronoi diagram of a single point is the entire plane.

Divide and Conquer (Merge)

Merge the diagrams by a (monoton) sequence of edges)

The ResultThe finished Voronoi Diagram

Running time: With n given points : O(n log n)

Page 8: mod-4-b-Voronoi-TIN

1/23/2014

8

Geometrical Divide and Conquer

Problem: Determine all intersecting pairs of segments

A

BC

DE

A

BC

DE

S1 S2

S

EC

D

A

B

DAC - Construction of the Voronoi diagramDivide:Divide P by a vertical dividing line T into 2 equal size subsets say P1 and P2. If |P| = 1 ⇒⇒⇒⇒ completed.Conquer:Compute VD(P1 ) and VD(P2 ) recursively.

Merge:Compute the edge sequence K separating P1 and P2Cut VD(P1) and VD(P2 ) by means of K starting from VD(P1 ) and VD(P2 ) and K

P1

P2

T

Computation of K

P1 P2

First edge in K

Last edge in K

4 tangential points P1 P2Observation: K is y - monotonous

Determines intersection s1 of m with Vor(p1) below lDetermines intersection s2 of m with Vor(p2) below l

Incremental (sweep line) construction(p1 in P1 and p2 in P2 perpendicular with m, Sweep l)

Extend K by line segment l siSet l = siCompute new K defining pair p1, p2

Running time O(n)Vor(pi) are convex, therefore each one‘sforward - edge are only visited once.

Example

Algo 2 : Fortune’s Algorithm(details)

47

• Algo 2 : Fortune’s Algorithm– Sweep line algorithm

• Voronoi diagram constructed as horizontal line sweeps the set of sites from top to bottom

• Incremental construction � maintains portion of diagram which cannot change due to sites below sweep line, keeping track of incremental changes for each site (and Voronoi vertex) it “sweeps”

Page 9: mod-4-b-Voronoi-TIN

1/23/2014

9

Constructing Voronoi Diagrams

What is the invariant we are looking for?

Maintain a representation of the locus of points q that are closer to some site pi above the sweep line than to

the line itself (and thus to any site below the line).

ev

pi

Sweep Line

q

Constructing Voronoi Diagrams

Which points are closer to a site above the sweep line than to the sweep line itself?

Sweep Line

pi

q

The set of parabolic arcs form a beach-line that bounds the locus of all such points

Equidistance

Constructing Voronoi Diagrams

Break points trace out Voronoi edges.

Equidistance

Sweep Line

pi

q

Constructing Voronoi Diagrams

Arcs flatten out as sweep line moves down.

Sweep Line

pi

q

Eventually, the middle arc disappears.

Constructing Voronoi Diagrams

Sweep Line

pi

q

We have detected a circle that is empty (contains no sites) and touches 3 or more sites.

Constructing Voronoi Diagrams

Sweep Line

pi

q

Voronoi vertex!

Page 10: mod-4-b-Voronoi-TIN

1/23/2014

10

Beach Line properties

• Voronoi edges are traced by the break points as the sweep line moves down.– Emergence of a new break point(s) (from

formation of a new arc or a fusion of two existing break points) identifies a new edge

• Voronoi vertices are identified when two break points meet (fuse).– Decimation of an old arc identifies new vertex

Data Structures

• Current state of the Voronoi diagram– Doubly linked list of half-edge, vertex, cell records

• Current state of the beach line– Keep track of break points

– Keep track of arcs currently on beach line

• Current state of the sweep line– Priority event queue sorted on decreasing y-coordinate

Doubly Linked List (D)

• Goal: a simple data structure that allows an algorithm to traverse a Voronoi diagram’s segments, cells and vertices

ev

Cell(pi)

Doubly Linked List (D)

• Divide segments into uni-directional half-edges

• A chain of counter-clockwise half-edges forms a cell

• Define a half-edge’s “twin” to be its opposite half-edge of the same segment

e

v

Cell(pi)

Doubly Linked List (D)

• Cell Table– Cell(pi) : pointer to any incident half-edge

• Vertex Table– vi : list of pointers to all incident half-edges

• Doubly Linked-List of half-edges; each has:– Pointer to Cell Table entry– Pointers to start/end vertices of half-edge– Pointers to previous/next half-edges in the CCW chain– Pointer to twin half-edge

Balanced Binary Tree (T)

• Internal nodes represent break points between two arcs– Also contains a pointer to the D record of the edge being traced

• Leaf nodes represent arcs, each arc is in turn represented by the site that generated it– Also contains a pointer to a potential circle event

pi pj pk pl

< pj, pk>

< pi, pj> < pk, pl>

pi

pjpk

pl

l

Page 11: mod-4-b-Voronoi-TIN

1/23/2014

11

Balanced Binary Tree (T)

• Internal nodes represent break points between two arcs– Also contains a pointer to the D record of the edge being traced

• Leaf nodes represent arcs, each arc is in turn represented by the site that generated it– Also contains a pointer to a potential circle event

pi pj pk pl

< pj, pk>

< pi, pj> < pk, pl>

pi

pjpk

pl

l

Event Queue (Q)

• An event is an interesting point encountered by the sweep line as it sweeps from top to bottom– Sweep line makes discrete stops, rather than a continuous

sweep

• Consists of Site Events (when the sweep line encounters a new site point) and Circle Events (when the sweep line encounters the bottom of an empty circle touching 3 or more sites).

• Events are prioritized based on y-coordinate

Site Event

A new arc appears when a new site appears.

l

Site Event

A new arc appears when a new site appears.

l

Site Event

Original arc above the new site is broken into two� Number of arcs on beach line is O(n)

l

Circle Event

An arc disappears whenever an empty circle touches three or more sites and is tangent to the sweep line.

Sweep line helps determine that the circle is indeed empty.

Circle Event!Sweep Line

pi

q

Voronoi vertex!

Page 12: mod-4-b-Voronoi-TIN

1/23/2014

12

Event Queue Summary

• Site Events are – given as input– represented by the xy-coordinate of the site point

• Circle Events are– computed on the fly (intersection of the two bisectors in

between the three sites)– represented by the xy-coordinate of the lowest point of an

empty circle touching three or more sites– “anticipated”, these newly generated events may be false

and need to be removed later

• Event Queue prioritizes events based on their y-coordinates

Summarizing Data Structures

• Current state of the Voronoi diagram– Doubly linked list of half-edge, vertex, cell records

• Current state of the beach line– Keep track of break points

• Inner nodes of binary search tree; represented by a tuple

– Keep track of arcs currently on beach line• Leaf nodes of binary search tree; represented by a site that

generated the arc

• Current state of the sweep line– Priority event queue sorted on decreasing y-coordinate

Algorithm

1. Initialize • Event queue Q � all site events

• Binary search tree T � ∅• Doubly linked list D � ∅

2. While Q not ∅,• Remove event (e) from Q with largest y-

coordinate• HandleEvent(e, T, D)

Handling Site Events

1. Locate the existing arc (if any) that is above the new site

2. Break the arc by replacing the leaf node with a sub tree representing the new arc and its break points

3. Add two half-edge records in the doubly linked list4. Check for potential circle event(s), add them to

event queue if they exist

Locate the existing arc that is above the new site

pi pj pk pl

< pj, pk>

< pi, pj> < pk, pl>

• The x coordinate of the new site is used for the binary search

• The x coordinate of each breakpoint along the root to leaf pathis computed on the fly

pi

pjpk

pl

lpm

Break the Arc

pi pj pk

< pj, pk>

< pi, pj> < pk, pl>

Corresponding leaf replaced by a new sub-tree

pi

pjpk

pl

lpm

pm pl

< pl, pm>

< pm, pl>

plDifferent arcs can be identified by the same site!

Page 13: mod-4-b-Voronoi-TIN

1/23/2014

13

Add a new edge record in the doubly linked list

pi pj pk

< pj, pk>

< pi, pj> < pk, pl>

pm pl

< pl, pm>

< pm, pl>

pl

pi

pjpk

pl

lpm

New Half Edge Record

Endpoints � ∅

Pointers to two half-edge records

lpm

Checking for Potential Circle Events

• Scan for triple of consecutive arcs and determine if breakpoints converge– Triples with new arc in the middle do not have

break points that converge

Checking for Potential Circle Events

• Scan for triple of consecutive arcs and determine if breakpoints converge– Triples with new arc in the middle do not have

break points that converge

Checking for Potential Circle Events

• Scan for triple of consecutive arcs and determine if breakpoints converge– Triples with new arc in the middle do not have

break points that converge

Converging break points may not always yield a circle event

• Appearance of a new site before the circle event makes the potential circle non-empty

l

(The original circle event becomes a false alarm)

Handling Site Events

1. Locate the leaf representing the existing arc that is above the new site

– Delete the potential circle event in the event queue

2. Break the arc by replacing the leaf node with a sub tree representing the new arc and break points

3. Add a new edge record in the doubly linked list4. Check for potential circle event(s), add them to

queue if they exist– Store in the corresponding leaf of T a pointer to the new

circle event in the queue

Page 14: mod-4-b-Voronoi-TIN

1/23/2014

14

Handling Circle Events

1. Add vertex to corresponding edge record in doubly linked list

2. Delete from T the leaf node of the disappearing arc and its associated circle events in the event queue

3. Create new edge record in doubly linked list

4. Check the new triplets formed by the former neighboring arcs for potential circle events

A Circle Event

pi pj pk

< pj, pk>

< pi, pj> < pk, pl>

pi

pj

pkpl

lpm

pm pl

< pl, pm>

< pm, pl>

pl

Add vertex to corresponding edge record

pi pj pk

< pj, pk>

< pi, pj> < pk, pl>

pi

pj

pkpl

lpm

pm pl

< pl, pm>

< pm, pl>

pl

Half Edge Record

Endpoints.add(x, y)

Half Edge Record

Endpoints.add(x, y)

Link!

Deleting disappearing arc

pi pj pk

< pj, pk>

< pi, pj>

pi

pj

pkpl

lpm

pm pl

< pm, pl>

Deleting disappearing arc

pi pj pk

< pj, pk>

< pi, pj>

pi

pj

pkpl

lpm

pm pl

< pm, pl>

< pk, pm>

Create new edge record

pi pj pk

< pj, pk>

< pi, pj>

pi

pj

pkpl

lpm

pm pl

< pm, pl>

< pk, pm>

New Half Edge Record

Endpoints.add(x, y)

A new edge is traced out by the new break point < pk, pm>

Page 15: mod-4-b-Voronoi-TIN

1/23/2014

15

Check the new triplets for potential circle events

pi pj pk

< pj, pk>

< pi, pj>

pi

pj

pkpl

lpm

pm pl

< pm, pl>

< pk, pm>

Q y…

new circle event

Minor Detail

• Algorithm terminates when Q = ∅, but the beach line and its break points continue to trace the Voronoi edges– Terminate these “half-infinite” edges via a

bounding box

Algorithm Termination

pi pj pk

< pj, pk>

< pi, pj>

pi

pj

pkpl

l

pmpm pl

< pm, pl>

< pk, pm>

Q ∅

Algorithm Termination

pi pj

< pj, pm>

< pi, pj>

pi

pj

pkpl

l

pm

pm pl

< pm, pl>

Q ∅

Algorithm Termination

pi pj

< pj, pm>

< pi, pj>

pi

pj

pkpl

l

pm

pm pl

< pm, pl>

Q ∅

Terminate half-lines with a bounding box!