From e1428602af9b5e3a3bb40ab3dcf4c2b896ee4afc Mon Sep 17 00:00:00 2001 From: TomyLobo Date: Sun, 8 Jan 2012 03:21:35 +0100 Subject: [PATCH] Fixed Vector.cross and optimized the Vector tests slightly. --- src/main/java/com/sk89q/worldedit/Vector.java | 6 +++--- .../java/com/sk89q/worldedit/VectorTest.java | 16 ++++++++-------- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/src/main/java/com/sk89q/worldedit/Vector.java b/src/main/java/com/sk89q/worldedit/Vector.java index 1082c16d2..13dbb2428 100644 --- a/src/main/java/com/sk89q/worldedit/Vector.java +++ b/src/main/java/com/sk89q/worldedit/Vector.java @@ -503,9 +503,9 @@ public class Vector { */ public Vector cross(Vector other) { return new Vector( - y * other.z + z * other.y, - z * other.x + x * other.z, - x * other.y + y * other.x + y * other.z - z * other.y, + z * other.x - x * other.z, + x * other.y - y * other.x ); } diff --git a/src/test/java/com/sk89q/worldedit/VectorTest.java b/src/test/java/com/sk89q/worldedit/VectorTest.java index eece15fb3..4b1830de3 100644 --- a/src/test/java/com/sk89q/worldedit/VectorTest.java +++ b/src/test/java/com/sk89q/worldedit/VectorTest.java @@ -100,16 +100,16 @@ public class VectorTest { final Vector b = new Vector(bx,by,bz); assertTrue(a.isCollinearWith(b)); assertTrue(b.isCollinearWith(a)); - assertTrue(a.multiply(-1).isCollinearWith(b)); - assertTrue(a.isCollinearWith(b.multiply(-1))); + assertTrue(a.multiply(-1.0).isCollinearWith(b)); + assertTrue(a.isCollinearWith(b.multiply(-1.0))); } private void assertNotCollinear(double ax, double ay, double az, double bx, double by, double bz) { final Vector a = new Vector(ax,ay,az); final Vector b = new Vector(bx,by,bz); assertFalse(a.isCollinearWith(b)); assertFalse(b.isCollinearWith(a)); - assertFalse(a.multiply(-1).isCollinearWith(b)); - assertFalse(a.isCollinearWith(b.multiply(-1))); + assertFalse(a.multiply(-1.0).isCollinearWith(b)); + assertFalse(a.isCollinearWith(b.multiply(-1.0))); } private void assertCollinear(double ax, double az, double bx, double bz) { @@ -117,15 +117,15 @@ public class VectorTest { final Vector2D b = new Vector2D(bx,bz); assertTrue(a.isCollinearWith(b)); assertTrue(b.isCollinearWith(a)); - assertTrue(a.multiply(-1).isCollinearWith(b)); - assertTrue(a.isCollinearWith(b.multiply(-1))); + assertTrue(a.multiply(-1.0).isCollinearWith(b)); + assertTrue(a.isCollinearWith(b.multiply(-1.0))); } private void assertNotCollinear(double ax, double az, double bx, double bz) { final Vector2D a = new Vector2D(ax,az); final Vector2D b = new Vector2D(bx,bz); assertFalse(a.isCollinearWith(b)); assertFalse(b.isCollinearWith(a)); - assertFalse(a.multiply(-1).isCollinearWith(b)); - assertFalse(a.isCollinearWith(b.multiply(-1))); + assertFalse(a.multiply(-1.0).isCollinearWith(b)); + assertFalse(a.isCollinearWith(b.multiply(-1.0))); } }