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

Change in forEachTriangle #76

Open PaulTorfs opened 2 years ago

PaulTorfs commented 2 years ago

I do suggest the following change in forEachTriange (the version on the website does only provide one coordinate (and even the wrong one), this version returns both x and y coordinates:

function forEachTriangle(points, delaunay, callback) {
  for (let t = 0; t < delaunay.triangles.length / 3; t++) {
    callback(t, pointsOfTriangle(delaunay, t).map(p => [points[2*p],points[2*p+1]]));
  }
}
redblobgames commented 2 years ago

Oh, yes, this is an issue but not sure what I should do about it — if you store points as nested [[x0,y0], [x1,y1], [x2,y2], …] then the helper code you need will be different than if you store the flat version [x0, y0, x1, y1, x2, y2, …]. Right now the guide is written for the nested point structure.

PaulTorfs commented 2 years ago

Hi Mapbox maintainer,

Thanks, I did not consider the point of view you made in your mail. But I started with the example in the README.md of your GitHub page, where you give a no-nested example as a first start. It may be an idea to make both consistent?

Anyhow: thanks for your swift answer,

Greetings from a misty and grey Netherlands,

Paul Torfs

On Tue, Jan 18, 2022 at 1:35 AM Amit Patel @.***> wrote:

Oh, yes, this is an issue but not sure what I should do about it — if you store points as nested [[x0,y0], [x1,y1], [x2,y2], …] then the helper code you need will be different than if you store the flat version [x0, y0, x1, y1, x2, y2, …]. Right now the guide is written for the nested point structure.

— Reply to this email directly, view it on GitHub https://github.com/mapbox/delaunator/issues/76#issuecomment-1014974306, or unsubscribe https://github.com/notifications/unsubscribe-auth/AKWFYQM4PWGJEXGN43WQ4GTUWSYW7ANCNFSM5MEI74RQ . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.

You are receiving this because you authored the thread.Message ID: @.***>