Skip to content

Bug in the face order check #1394

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

Merged
merged 4 commits into from
Jan 13, 2025
Merged

Conversation

hazzlerr
Copy link
Contributor

Current check for a polygon order is incorrect, and it breaks on the following test:

Screenshot 2024-11-15 181100
Here's the code that generates this test:

vector<Point> pts = {{0, 2}, {1, 3}, {0, 1}, {1, 0}, {-1, 0}, {-1, 3}};
vector<vector<size_t>> adj(pts.size());
auto add_edge = [&](int u, int v) {
    adj[u].push_back(v);
    adj[v].push_back(u);
};
add_edge(0, 1);
add_edge(1, 2);
add_edge(2, 3);
add_edge(3, 4);
add_edge(4, 5);
add_edge(5, 0);

For an outer face (1→2→3→4→5→0), the previous version of the algorithm would first check the triplet 1→2→3. Since this triplet is ordered in counter-clockwise order, it would incorrectly mark this face as inner.

So, instead we should use something different. I used the oriented area, however, since the coordinates are stored as int64_t, I had to use __int128, which doesn't feel that elegant.

@hazzlerr hazzlerr changed the title Fixed face order check Bug in the face order check Nov 20, 2024
@adamant-pwn adamant-pwn merged commit 2ebecc1 into cp-algorithms:main Jan 13, 2025
Bhaskar1312 pushed a commit to Bhaskar1312/cp-algorithms that referenced this pull request Apr 19, 2025
* Fixed face order check

* Update test_planar_faces.cpp
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

Successfully merging this pull request may close these issues.

2 participants