mapbox / delaunator

An incredibly fast JavaScript library for Delaunay triangulation of 2D points
https://mapbox.github.io/delaunator/
ISC License
2.24k stars 139 forks source link

Confusing first example in the docs #83

Open erykciepiela opened 2 months ago

erykciepiela commented 2 months ago

That's very minor, yet, may discourage users who are new to this excellent library and wants to evaluate it.

What I did with the first example:

const coords = [168,180, 168,178, 168,179, 168,181, 168,183, ...];

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

was to make it runnable by changing:

const coords = [168,180, 168,178, 168,179, 168,181, 168,183];

and to my surprise this yielded no triangles. Having a second look I found that all the points are on the same line so, indeed, no triangulation can be done.

Changing example shouldn't be hard but may save some time for new users, the time I have just wasted...

Thanks you for exceptional library, much appreciated!