Once an interval was narrowed down to just two elements, the binary search algorithm always returned the lower of the two. That's not correct.
This bug was found by simulations of a one-pixel source that happens to be off by one pixel. If, in that example, the source would have been located at +1 or -1 pixel compared to the test that was run, this bug would have gone unnoticed.
Changes in "s-image.c" are mostly cosmetic to make it easier to reason why the formula works,
by removing the double negative. I think there was als oa 0.5 pixel offset before, but since it's hard to reason about, I opted for simplifying and making sure it's correct by testing a simulation.
Once an interval was narrowed down to just two elements, the binary search algorithm always returned the lower of the two. That's not correct.
This bug was found by simulations of a one-pixel source that happens to be off by one pixel. If, in that example, the source would have been located at +1 or -1 pixel compared to the test that was run, this bug would have gone unnoticed.
Changes in "s-image.c" are mostly cosmetic to make it easier to reason why the formula works, by removing the double negative. I think there was als oa 0.5 pixel offset before, but since it's hard to reason about, I opted for simplifying and making sure it's correct by testing a simulation.
fixes #50 closes #54