Giter Site home page Giter Site logo

cuulee / delaunator Goto Github PK

View Code? Open in Web Editor NEW

This project forked from mapbox/delaunator

0.0 1.0 0.0 80 KB

A really fast JavaScript library for Delaunay triangulation of 2D points

Home Page: https://mapbox.github.io/delaunator/

License: ISC License

JavaScript 47.64% HTML 52.36%

delaunator's Introduction

delaunator

A really fast JavaScript library for Delaunay triangulation of 2D points. Implements a variation of the Sweep-hull algorithm.

Build Status

Example

var points = [[168, 180], [168, 178], [168, 179], [168, 181], [168, 183], ...];

var delaunay = new Delaunator(points);
console.log(delaunay.triangles);
// [623, 636, 619,  636, 444, 619, ...]

API Reference

new Delaunator(points[, getX, getY])

Constructs a delaunay triangulation object given an array of points ([x, y] by default). getX and getY are optional functions of the form (point) => value for custom point formats. Duplicate points are skipped.

delaunay.triangles

A flat Int32Array array of triangle indices (each group of three numbers forms a triangle).

Performance

Benchmark results against three fastest other libraries (bench.js on Macbook Pro Retina mid-2012, Node v7.9.0):

Uniform distribution

library 10,000 20,000 50,000 100,000 200,000 500,000 1,000,000
delaunator 26ms 40ms 174ms 327ms 658ms 2.07s 4.95s
faster-delaunay 78ms 140ms 328ms 776ms 1.74s 3.87s 6.99s
incremental-delaunay 81ms 154ms 428ms 874ms 1.74s 4.3s 9.03s
delaunay-fast 136ms 386ms 1.18s 3.03s 7.95s 28.2s 76.96s

Gaussian distribution

library 10,000 20,000 50,000 100,000 200,000 500,000 1,000,000
delaunator 22ms 39ms 162ms 270ms 586ms 1.86s 4.53s
faster-delaunay 76ms 172ms 291ms 692ms 1.19s 3.46s 6.36s
incremental-delaunay 74ms 154ms 410ms 806ms 1.67s 4.27s 8.3s
delaunay-fast 152ms 340ms 1.19s 3.2s 8.37s 30.03s 82.05s

Papers

The algorithm is based on ideas from the following papers:

delaunator's People

Watchers

 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.