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

tsearch: Point not inserted #46

Open
Jean-Romain opened this issue Oct 24, 2019 · 2 comments
Open

tsearch: Point not inserted #46

Jean-Romain opened this issue Oct 24, 2019 · 2 comments
Labels
Milestone

Comments

@Jean-Romain
Copy link
Contributor

Jean-Romain commented Oct 24, 2019

Reproducible example given by email:

library(geometry)
source("dumpdata.txt")
D = delaunayn(cbind(x,y))
tsearch(x,y,D,x1,y1)
#> Error in C_tsearch(x, y, t, xi, yi, bary): Failed to insert point into QuadTree.
#> Please post input to tsearch  (or tsearchn at
#> https://github.com/davidcsterratt/geometry/issues
#> or email the maintainer.

🔖 dumpdata.txt

@davidcsterratt davidcsterratt added this to the 0.4.5 milestone Oct 25, 2019
@Jean-Romain
Copy link
Contributor Author

Jean-Romain commented Oct 30, 2019

As expected it is a problem of computer precision. At the level 6 the quadrants are no longer aligned with the main bounding box of the quadtree because of the successive division by 2. There is nothing to do but increasing the default epsilon to 1.0e-10. I think epsilon should be a parameter modifiable by the user.

SEXP C_tsearch(NumericVector x, NumericVector y, IntegerMatrix elem, NumericVector xi, NumericVector yi, bool bary = false, double eps = 1.0e-12)

Another option is to expend a bit the bounding box of the quadtree. This also fix this issue without changing epsilon but I can't swear we won't have potential computer precision issues in other quadrants.

double range = xrange > yrange ? xrange/2 : yrange/2;

Add L202

range *= 1.01;

@Toby-Stegman-cbec
Copy link

Greetings,

I have run into this same issue ("Failed to insert point into QuadTree."), and have tried to edit Rtsearch.cpp function as stated above and reinstall the package to no avail. If I use the "orig" method in place of the "quadtree" method the function appears to work very well. I will try and work up a smaller example dataset to share. The code as it stands would need some simplification to share.

Thanks for all your work on this!

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

No branches or pull requests

3 participants