Skip to content
Snippets Groups Projects
Commit 23695cca authored by Dmitri Naumov's avatar Dmitri Naumov
Browse files

[MaL] Use std::fabs. Rename tol to eps.

parent b9a20b91
No related branches found
No related tags found
No related merge requests found
......@@ -134,30 +134,30 @@ bool operator< (TemplatePoint<T,DIM> const& a, TemplatePoint<T,DIM> const& b)
* lexicographical comparison of points taking an epsilon into account
* @param p0 first input Point3d
* @param p1 second input Point3d
* @param tol tolerance (if in the comparison operation the property fabs(p0[k] - p1[k]) < tol
* @param eps tolerance (if in the comparison operation the property abs(p0[k] - p1[k]) < eps
* holds for the k-th coordinate the points are assumed the be equal in this coordinate)
* @return true, if p0 is lexicographically smaller than p1
*/
template <typename T, std::size_t DIM>
bool lessEq(TemplatePoint<T, DIM> const& a, TemplatePoint<T, DIM> const& b,
double tol = std::numeric_limits<double>::epsilon())
double eps = std::numeric_limits<double>::epsilon())
{
// test a relative and an absolute criterion
if (fabs(a[0]-b[0]) > tol * std::min(fabs(b[0]), fabs(a[0])) && fabs(a[0]-b[0]) > tol) {
if ((std::fabs(a[0]-b[0]) > eps * std::min(std::fabs(b[0]), std::fabs(a[0])) && std::fabs(a[0]-b[0]) > eps) {
if (a[0] <= b[0])
return true;
else
return false;
} else {
// assume a[0] == b[0]
if (fabs (a[1]-b[1]) > tol * fabs(a[1]) && fabs(a[1]-b[1]) > tol) {
if (std::fabs (a[1]-b[1]) > eps * std::fabs(a[1]) && std::fabs(a[1]-b[1]) > eps) {
if (a[1] <= b[1])
return true;
else
return false;
} else {
// assume a[1] == b[1] and a[0] == b[0]
if (fabs (a[2]-b[2]) > tol * fabs(a[2]) && fabs(a[2]-b[2]) > tol) {
if (std::fabs (a[2]-b[2]) > eps * std::fabs(a[2]) && std::fabs(a[2]-b[2]) > eps) {
if (a[2] <= b[2])
return true;
else
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment