Ray recommends using <= when comparing to epsilon.
This allows epsilon of 0 to work.
This commit is contained in:
@@ -66,7 +66,7 @@ public class Vectors
|
|||||||
* magnitude.
|
* magnitude.
|
||||||
*/
|
*/
|
||||||
public static boolean isEpsilonZero (double x, double y, double epsilon) {
|
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}.
|
* {@code epsilon}.
|
||||||
*/
|
*/
|
||||||
public static boolean epsilonEquals (IVector v1, IVector v2, double 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;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -66,7 +66,7 @@ public class Vectors
|
|||||||
* magnitude.
|
* magnitude.
|
||||||
*/
|
*/
|
||||||
public static boolean isEpsilonZero (float x, float y, float epsilon) {
|
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}.
|
* {@code epsilon}.
|
||||||
*/
|
*/
|
||||||
public static boolean epsilonEquals (IVector v1, IVector v2, float 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;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user