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

Triangulation.hull clock-wise instead of counter-clockwise? #12

Closed
andreesteve opened this issue Jan 5, 2021 · 2 comments
Closed

Triangulation.hull clock-wise instead of counter-clockwise? #12

andreesteve opened this issue Jan 5, 2021 · 2 comments
Labels
bug Something isn't working

Comments

@andreesteve
Copy link
Collaborator

Thanks for the port!

The docs indicate that the indices returned by Triangulation.hull are counter-clockwise.

hull: Vec<usize>
[−]
A vector of indices that reference points on the convex hull of the triangulation, counter-clockwise.

However I see them being returned clockwise. Which one is the right expectation?

Sample test:

use delaunator::*;

fn main() {
    let p = vec![
        Point { x: 0.0, y: 0.0 },
        Point { x: 1.0, y: 1.0 },
        Point { x: -1.0, y: 1.0 },
    ];
    triangulate(&p)
        .unwrap().hull.iter()
        .for_each(|s| println!("Hull {}: {:?}", *s, p[*s]));
}

for which I get:

Hull 0: [0, 0]
Hull 2: [-1, 1]
Hull 1: [1, 1]
@mourner mourner added the bug Something isn't working label Jun 10, 2021
@mourner
Copy link
Owner

mourner commented Jun 10, 2021

It should be counter-clockwise (as a convention and to match delaunator in JS), so it might be a bug.

@andreesteve
Copy link
Collaborator Author

This was my mistake. I assumed the Y axis upright, in such orientation the triangle is oriented clockwise.
image

However, the library expects Y to be pointing downwards, in which case the orientation is correct.

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants