The Ramer–Douglas–Peucker algorithm takes a curve composed of line segments (connected points), and then finds a visually similar curve that requires fewer points.
The module returns a single function that accepts your input and outputs the simplified set of points.
- points
- Description: An array of points you wish to simplify. The points themselves can be
Vector2
objects or anything withX
andY
properties (such as a simple dictionary). - Type: array<Vector2-like>
- Required
- Description: An array of points you wish to simplify. The points themselves can be
- tolerance
- Description: A number defining the degree you wish to simplify your set of points. Higher means less points, but lower quality and loss in data complexity. Lower means more points, higher quality, and higher data complexity.
- Type: number
- Optional: Default is
1
- highestQuality
- Description: Whether or not to skip the radial distance simplification, which will increase quality but also increases complexity.
- Type: boolean
- Optional: Default is
false
- X
- Description: Specify a key name for X values.
- type: string
- Optional: Default is
x
- Y
- Description: Specify a key name for Y values.
- type: string
- Optional: Default is
y
- Description: An array of simplified points, re-using a subset of the points you passed in. (If you pass in
Vector2
s, you will getVector2
s back; if you pass in a dictionaries withX
andY
properties, you will get that back.) - Type: array<Vector2-like>