Skip to content

A repository of generic algorithms that can be used within Roblox and other environments.

License

Notifications You must be signed in to change notification settings

evaera/LuaAlgorithms

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 

Repository files navigation

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
  • 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

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

About

A repository of generic algorithms that can be used within Roblox and other environments.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages