Ray recommends using <= when comparing to epsilon.

This allows epsilon of 0 to work.
This commit is contained in:
Michael Bayne
2011-10-11 13:17:05 -07:00
parent b67c0bfc48
commit 403bafce13
2 changed files with 4 additions and 4 deletions
+2 -2
View File
@@ -66,7 +66,7 @@ public class Vectors
* magnitude.
*/
public static boolean isEpsilonZero (double x, double y, double epsilon) {
return Math.abs(x) < epsilon && Math.abs(y) < epsilon;
return Math.abs(x) <= epsilon && Math.abs(y) <= epsilon;
}
/**
@@ -82,7 +82,7 @@ public class Vectors
* {@code epsilon}.
*/
public static boolean epsilonEquals (IVector v1, IVector v2, double epsilon) {
return Math.abs(v1.x() - v2.x()) < epsilon && Math.abs(v1.y() - v2.y()) < epsilon;
return Math.abs(v1.x() - v2.x()) <= epsilon && Math.abs(v1.y() - v2.y()) <= epsilon;
}
/**
+2 -2
View File
@@ -66,7 +66,7 @@ public class Vectors
* magnitude.
*/
public static boolean isEpsilonZero (float x, float y, float epsilon) {
return Math.abs(x) < epsilon && Math.abs(y) < epsilon;
return Math.abs(x) <= epsilon && Math.abs(y) <= epsilon;
}
/**
@@ -82,7 +82,7 @@ public class Vectors
* {@code epsilon}.
*/
public static boolean epsilonEquals (IVector v1, IVector v2, float epsilon) {
return Math.abs(v1.x() - v2.x()) < epsilon && Math.abs(v1.y() - v2.y()) < epsilon;
return Math.abs(v1.x() - v2.x()) <= epsilon && Math.abs(v1.y() - v2.y()) <= epsilon;
}
/**