predicates
predicates copied to clipboard
Invalid incircle unit test
The incircle unit test is invalid. There is a roundoff in r2
calculation, so r2
is always equals to n*n
despite the perturbation of q
.
const double y[] = {q[0] - x[0], q[1] - x[1]};
const double r2 = y[0]*y[0] + y[1]*y[1];
if (r2 < n*n) assert(p > 0);
else if (r2 > n*n) assert(p < 0);
Hence the assertion statements are never executed. You can write
if (r2 < n*n) assert(0);
else if (r2 > n*n) assert(0);
to check it out.
Well that's embarrassing, good catch! My first thought is to use the GNU multi-precision library. If you want to fix this I'd gladly accept the PR, or I can do that myself.
A code coverage analyzer would have made it obvious that neither of those branches was taken.
Sorry. I think there's no strong reason to fix this since the easy case test works well.