Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Confusing first example in the docs #83

Open
erykciepiela opened this issue Apr 30, 2024 · 3 comments
Open

Confusing first example in the docs #83

erykciepiela opened this issue Apr 30, 2024 · 3 comments

Comments

@erykciepiela
Copy link

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!

@shaman4d
Copy link

Hi. I don't understand how to make it works.
I have such code:

import Delaunator from "delaunator";
const coords = [1,1,200,300, 400, 400,53,65,700,111];
const delaunay = new Delaunator(coords);
console.log(delaunay.triangles);

And got output in log something:

{
    "0": 1,
    "1": 2,
    "2": 4,
    "3": 4,
    "4": 3,
    "5": 1,
    "6": 4,
    "7": 0,
    "8": 3,
    "9": 3,
    "10": 0,
    "11": 1
}

No coords at all.

@redblobgames
Copy link
Collaborator

@shaman4d The output is not coordinates. The input is coordinates. The output is vertex ids or triangle ids. These ids are integers. The guide page shows sample code of how to use the ids to construct edges or triangles.

(Also, I think your question is unrelated to this issue which is about the numbers used for the sample points)

@shaman4d
Copy link

@shaman4d The output is not coordinates. The input is coordinates. The output is vertex ids or triangle ids. These ids are integers. The guide page shows sample code of how to use the ids to construct edges or triangles.

(Also, I think your question is unrelated to this issue which is about the numbers used for the sample points)

Hi. Thank you for your answer. I've got the idea!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants