OSDN Git Service

[added] epsilon equals methods to vectors.
authorbadlogicgames <badlogicgames@6c4fd544-2939-11df-bb46-9574ba5d0bfa>
Sun, 8 Jan 2012 00:14:57 +0000 (00:14 +0000)
committerbadlogicgames <badlogicgames@6c4fd544-2939-11df-bb46-9574ba5d0bfa>
Sun, 8 Jan 2012 00:14:57 +0000 (00:14 +0000)
gdx/src/com/badlogic/gdx/math/Vector2.java
gdx/src/com/badlogic/gdx/math/Vector3.java

index 23724cc..be654a1 100644 (file)
@@ -258,4 +258,18 @@ public class Vector2 implements Serializable {
                r.add(target.tmp().mul(alpha));\r
                return r;\r
        }\r
+       \r
+       /**\r
+        * Compares this vector with the other vector, using the supplied\r
+        * epsilon for fuzzy equality testing.\r
+        * @param obj\r
+        * @param epsilon\r
+        * @return whether the vectors are the same.\r
+        */\r
+       public boolean epsilonEquals(Vector2 obj, float epsilon) {\r
+               if(obj == null) return false;\r
+               if(Math.abs(obj.x - x) > epsilon) return false;\r
+               if(Math.abs(obj.y - y) > epsilon) return false;\r
+               return true;\r
+       }\r
 }\r
index 20352fd..fe844a8 100644 (file)
@@ -412,6 +412,13 @@ public class Vector3 implements Serializable {
                return true;\r
        }\r
 \r
+       /**\r
+        * Compares this vector with the other vector, using the supplied\r
+        * epsilon for fuzzy equality testing.\r
+        * @param obj\r
+        * @param epsilon\r
+        * @return whether the vectors are the same.\r
+        */\r
        public boolean epsilonEquals(Vector3 obj, float epsilon) {\r
                if(obj == null) return false;\r
                if(Math.abs(obj.x - x) > epsilon) return false;\r