Skip to content
A repository of generic algorithms intended to be used within the Roblox game engine
Lua
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.gitignore
LICENSE
README.md
RamerDouglasPeucker.lua

README.md

RamerDouglasPeucker.lua

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.

Parameters:

  • points
    • Description: An array of points you wish to simplify. The points themselves can be Vector2 objects or anything with X and Y properties (such as a simple dictionary).
    • Type: array<Vector2-like>
    • Required
  • 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

Returns:

  • Description: An array of simplified points, re-using a subset of the points you passed in. (If you pass in Vector2s, you will get Vector2s back; if you pass in a dictionaries with X and Y properties, you will get that back.)
  • Type: array<Vector2-like>

Demo use case:

Simplifying player drawings to reduce instance overhead

You can’t perform that action at this time.