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

delete obsolete func based on: https://github.com/libigl/libigl/issue… #1810

Merged
merged 1 commit into from May 26, 2021

Conversation

xarthurx
Copy link
Contributor

…s/1783#issuecomment-845248820

Fixes #1783

#1783 (comment)

Checklist

  • All changes meet libigl style-guidelines.
  • Adds new .cpp file.
  • Adds corresponding unit test.
  • This is a minor change.

@alecjacobson
Copy link
Contributor

Wow. I didn't even realize this old function was defined for integer coordinates. I'm guess it wasn't getting used much. For posterity, if anyone was using this function before. Perhaps like this:

std::vector<std::vector<unsigned int > >poly;
unsigned int xt,yt;
bool res = igl::point_in_poly(poly,xt,yt);

You could switch to calling igl::winding_number:

Eigen::MatrixXd V;
igl::list_to_matrix(poly,V);
Eigen::MatrixXi E(V.rows(),2);
for(int v = 0;v<V.rows();v++){ E.row(v) << v,(v+1)%V.rows(); }
bool res = std::abs(igl::winding_number(V,E,Eigen::RowVector2d(xt,yt))>0.5;

For most users, you'll already have your polygon in the V format. igl::winding_number can also process many query points (in parallel). In the future, it'd be nice to implement the fast variants of wn for point-in-poly queries.

In my experience, igl::winding_number will hold up pretty well w.r.t. floating point robustness, with the most obvious pitfall of the singularity for points directly on the polygon (or "too close" for good floating point math). For a robust query, probably CGAL is needed.

@alecjacobson alecjacobson merged commit 7342dbe into libigl:main May 26, 2021
@jdumas jdumas added this to In progress in Core module via automation May 26, 2021
@jdumas jdumas added this to the v3.0.0 milestone May 26, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Core module
In progress
Development

Successfully merging this pull request may close these issues.

multiplication out of "unsigned int" range in function "point_in_poly"
3 participants