openvdb
openvdb copied to clipboard
Divide by zero checks
I noticed that there is no divide-by-zero check here:
} else {
// c projects inside the [a,b] interval.
t = t / denom; // => Divide
return a + (ab * t);
}
Also also there:
if (Abs(b) > Abs(a)) {
relError = Abs((a - b) / b); // => Divide
} else {
relError = Abs((a - b) / a); // => Divide
}
I'm not sure whether they would cause any trouble.
I noticed that there is no divide-by-zero check here:
} else { // c projects inside the [a,b] interval. t = t / denom; // => Divide return a + (ab * t); }
This is already handled here.
@EmperorYP7 Thanks! 😄 In that line, I was specifically concerned about denom variable which is non-negative (can be zero) as commented in the code:
// always nonnegative since denom = ||ab||^2
double denom = ab.dot(ab);