There is a bug in lq.c which causes "outside" points to be missed. An automated test is available here, showing the bug in action: http://nicolas.brodu.free.fr/opensteer/lqtest.cpp
(Is there a way to attach a file in the forum?)
The bug comes from the fact a raw float -> int conversion truncates toward 0, not toward -inf. Using floorf solves the problem.
The code pretended to handle points outside the box, but apparently I always used it in situations where they were constrained to stay inside. It (and the bug) date back to this project: http://www.red3d.com/cwr/papers/2000/pip.html
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hello,
There is a bug in lq.c which causes "outside" points to be missed. An automated test is available here, showing the bug in action:
http://nicolas.brodu.free.fr/opensteer/lqtest.cpp
(Is there a way to attach a file in the forum?)
The bug comes from the fact a raw float -> int conversion truncates toward 0, not toward -inf. Using floorf solves the problem.
Example: minBinX = (int) ((((x - radius) - lq->originx) / lq->sizex) * lq->divx);
Should be: minBinX = (int) floorf((((x - radius) - lq->originx) / lq->sizex) * lq->divx);
The patched lq.c is available here:
http://nicolas.brodu.free.fr/opensteer/lq.c
Cheers,
Nicolas
Thank you very much for tracking this down: https://sourceforge.net/tracker/index.php?func=detail&aid=1735167&group_id=77546&atid=550583
The code pretended to handle points outside the box, but apparently I always used it in situations where they were constrained to stay inside. It (and the bug) date back to this project: http://www.red3d.com/cwr/papers/2000/pip.html