## geometry/

# vis_polyline_simplify.pro

includes main-level program This function simplifies the vertices of an `n`

-dimenstional polyline.
Vertices are removed if they are within a tolerance tangential distance from
an approximating line segment.

## Examples

See the main-level program at the end of this file for some examples. To run them, type:

```
IDL> .run vis_polyline_simplify
```

## Author information

- History
Original written by: Brad Gom, April 2004 Modified by Michael Galloy, 2010

## Routines

`result = vis_polyline_simplify_dot(x, y)`

Computes the dot product.

`result = vis_polyline_simplify_d2(x, y)`

Computes the distance squared of difference between points x and y

`vis_polyline_simplify_dp, tol2, vertices, j, k, mk`

This is the Douglas-Peucker recursive simplification routine.

`result = vis_polyline_simplify(vertices [, tolerance=float] [, factor=float])`

VIS_POLYLINE_SIMPLIFY uses the Douglas-Peucker (DP) approximation algorithm that is used extensively for both computer graphics and geographic information systems.

## Routine details

## top vis_polyline_simplify_dot

`result = vis_polyline_simplify_dot(x, y)`

Computes the dot product.

### Return value

float

### Parameters

- x in required type=vector
first parameter

- y in required type=vector
first parameter

## top vis_polyline_simplify_d2

`result = vis_polyline_simplify_d2(x, y)`

Computes the distance squared of difference between points x and y

### Return value

float

### Parameters

- x in required type=fltarr(2)
first point

- y in required type=fltarr(2)
second point

## top vis_polyline_simplify_dp

`vis_polyline_simplify_dp, tol2, vertices, j, k, mk`

This is the Douglas-Peucker recursive simplification routine. It marks
vertices that are part of the simplified polyline for approximating the
polyline subchain `vertices[j]`

to `vertices[k]`

.

### Parameters

- tol2 in required type=float
approximation tolerance squared

- vertices in required type=fltarr(m, n)
polyline array of vertex points

- j in required type=long
starting index fo subchain

- k in required type=long
ending index fo subchain

- mk in out required type=bytarr(n)
array of markers matching vertex array

`vertices`

## top vis_polyline_simplify

`result = vis_polyline_simplify(vertices [, tolerance=float] [, factor=float])`

`VIS_POLYLINE_SIMPLIFY`

uses the Douglas-Peucker (DP) approximation
algorithm that is used extensively for both computer graphics and geographic
information systems. See geometryalgorithms.com.

### Return value

This function returns the simplified array of vertices. If an error occurs, the output vertices will all be -1L.

### Parameters

- vertices in required type=fltarr(m, n)
An array of vertices representing the polyline. Must be a [m, n] array, where

`m`

is the dimensionality and`n`

is the number of vertices. Both`m > 1`

and`n > 1`

are required.

### Keywords

- tolerance in optional type=float
Set this keyword to the tolerance value to use. If

`tolerance`

is not set, or set to a negative or zero value, then the tolerance will be set automatically to the minimum average spacing along any dimension between points.Choice of tolerance is key to the amount of simplification. The routine approximates the polyline with line segments that are no further than tolerance from any vertices. Vertices that are within tolerance from the approximating lines are removed. If no tolerance is specified, the routine uses the minimum distance in each dimension between vertices, and multiplies this by

`factor`

as a tolerance.- factor in optional type=float default=1.
Set this keyword instead of

`tolerance`

to scale the automatic tolerance. For example,`FACTOR=10`

will use 10x the minimum average spacing between points as the tolerance. Ignored if`tolerance`

is set.

## File attributes

Modification date: | Mon Nov 29 18:32:39 2010 |

Lines: | 320 |

Docformat: | rst rst |