Git Product home page Git Product logo

luaalgorithms's Introduction

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

luaalgorithms's People

Contributors

evaera avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.