From 6bbf167cb401a65252a729e23130f78a788c167e Mon Sep 17 00:00:00 2001 From: TomyLobo Date: Tue, 3 Jan 2012 01:06:15 +0100 Subject: [PATCH] Moved Vector.dot further up in the file and added Vector.cross. --- src/main/java/com/sk89q/worldedit/Vector.java | 34 +++++++++++++------ 1 file changed, 24 insertions(+), 10 deletions(-) diff --git a/src/main/java/com/sk89q/worldedit/Vector.java b/src/main/java/com/sk89q/worldedit/Vector.java index ffd4454bb..c2986a64c 100644 --- a/src/main/java/com/sk89q/worldedit/Vector.java +++ b/src/main/java/com/sk89q/worldedit/Vector.java @@ -485,6 +485,30 @@ public class Vector { return divide(length()); } + /** + * Gets the dot product of this and another vector. + * + * @param other + * @return the dot product of this and the other vector + */ + public double dot(Vector other) { + return x * other.x + y * other.y + z * other.z; + } + + /** + * Gets the dot product of this and another vector. + * + * @param other + * @return the dot product of this and the other 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 + ); + } + /** * Checks to see if a vector is contained with another. * @@ -628,16 +652,6 @@ public class Vector { return new Vector2D(x, z); } - /** - * Gets the dot product of this and another vector. - * - * @param other - * @return the dot product of this and the other vector - */ - public double dot(Vector other) { - return x * other.x + y * other.y + z * other.z; - } - /** * Gets the minimum components of two vectors. *