EPSILON meaning in collinearity test
What do you think eps
is when you look only at function signature?
inline bool are_collinear(Point const& p1, Point const& p2, Point const& p3, double eps = EPSILON)
Most likely it's allowed uncertainty in point position when they are still treated as collinear. In another words is "radius" of points.
It turns out to be another thing. It's allowed area of triangle made by those three points:
/// Test whether three points lie approximately on the same line.
/// @relates Point
inline bool are_collinear(Point const& p1, Point const& p2, Point const& p3,
double eps = EPSILON)
{
return are_near( cross(p3, p2) - cross(p3, p1) + cross(p2, p1), 0, eps);
}
If it's how it's designed and planned then I find it unfortunate and needed to be documented. It's not obvious from first sight on function implementation.
If it's not how it was planned then it needs to be changed, e.g.:
return are_near( cross(p3, p2) - cross(p3, p1) + cross(p2, p1), 0, eps*eps);
Such change is silent breaker of user code as it leaves signatures same and changes the meaning.
Edited by Sergei Izmailov