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

Does the hull contain edges that have no twins? #57

Closed vchizhov closed 4 years ago

vchizhov commented 4 years ago

After triangulation, should the hull contain edge indices that have no twins? This doesn't seem to be the case for delaunator-cpp, so I am wondering whether that is a mistake there, or if it's something that's also unsupported by the original code.

mourner commented 4 years ago

Not sure how delaunator-cop differs here, but half-edges on the hull have no twins by definition — convex hull forms the outer boundary of the Delaunay triangulation, meaning there are no faces on the outer side.

Fil commented 4 years ago

Another remark is that the hull references point indices, not (half-)edge indices.

vchizhov commented 4 years ago

Another remark is that the hull references point indices, not (half-)edge indices.

That seems to have been the issue, now everything's as it should be. Shouldn't these comments be edited then:

this._hullPrev = new Uint32Array(n); // edge to prev edge
this._hullNext = new Uint32Array(n); // edge to next edge
this._hullTri = new Uint32Array(n); // edge to adjacent triangle

This is what confused me I guess. Since those are actually vertex idx -> next/prev vertex idx, and -> tri edge idx respectively.