From 48f529bc7a6c9329802dc2a921085e3a0d7e979e Mon Sep 17 00:00:00 2001 From: TomyLobo Date: Tue, 27 Dec 2011 19:03:18 +0100 Subject: [PATCH] Added Vector.lengthSq() --- src/main/java/com/sk89q/worldedit/Vector.java | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/src/main/java/com/sk89q/worldedit/Vector.java b/src/main/java/com/sk89q/worldedit/Vector.java index 79a030ef5..e488b3827 100644 --- a/src/main/java/com/sk89q/worldedit/Vector.java +++ b/src/main/java/com/sk89q/worldedit/Vector.java @@ -437,12 +437,19 @@ public class Vector { /** * Get the length of the vector. * - * @return distance + * @return length */ public double length() { - return Math.sqrt(Math.pow(x, 2) + - Math.pow(y, 2) + - Math.pow(z, 2)); + return Math.sqrt(x * x + y * y + z * z); + } + + /** + * Get the length^2 of the vector. + * + * @return length^2 + */ + public double lengthSq() { + return x * x + y * y + z * z; } /**