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

[Question] Can somebody please try to explain halfedges? #54

Closed trsh closed 4 years ago

trsh commented 4 years ago
const points = [[-500, 0], [0, 500], [500, 0], [1000, 500], [1500, 0]];

const delaunay = Delaunator.from(points);
console.log(delaunay.triangles);
console.log(delaunay.halfedges);

Uint32Array(9) [2, 0, 1, 1, 3, 2, 3, 4, 2]
Int32Array(9) [-1, -1, 5, -1, 8, 2, -1, -1, 4]

I can't make sense out of those numbers console.log(delaunay.halfedges)

Any help appreciated!

mourner commented 4 years ago

The docs exhaustively explain how to interpret numbers in halfgedges: https://mapbox.github.io/delaunator/