From 0346228310716df9d2b225d27b019128ca8711c8 Mon Sep 17 00:00:00 2001 From: aumgn Date: Tue, 13 Mar 2012 10:05:33 +0100 Subject: [PATCH] Add positive() to Vector and Vector2D --- src/main/java/com/sk89q/worldedit/Vector.java | 9 +++++++++ src/main/java/com/sk89q/worldedit/Vector2D.java | 9 +++++++++ 2 files changed, 18 insertions(+) diff --git a/src/main/java/com/sk89q/worldedit/Vector.java b/src/main/java/com/sk89q/worldedit/Vector.java index 1edcd1fbf..b1563e657 100644 --- a/src/main/java/com/sk89q/worldedit/Vector.java +++ b/src/main/java/com/sk89q/worldedit/Vector.java @@ -575,6 +575,15 @@ public class Vector { return new Vector(Math.floor(x + 0.5), Math.floor(y + 0.5), Math.floor(z + 0.5)); } + /** + * Returns a vector with the absolute values of the components of this vector. + * + * @return + */ + public Vector positive() { + return new Vector(Math.abs(x), Math.abs(y), Math.abs(z)); + } + /** * 2D transformation. * diff --git a/src/main/java/com/sk89q/worldedit/Vector2D.java b/src/main/java/com/sk89q/worldedit/Vector2D.java index f481ce3b8..bf3835255 100644 --- a/src/main/java/com/sk89q/worldedit/Vector2D.java +++ b/src/main/java/com/sk89q/worldedit/Vector2D.java @@ -501,6 +501,15 @@ public class Vector2D { return new Vector2D(Math.floor(x + 0.5), Math.floor(z + 0.5)); } + /** + * Returns a vector with the absolute values of the components of this vector. + * + * @return + */ + public Vector2D positive() { + return new Vector2D(Math.abs(x), Math.abs(z)); + } + /** * 2D transformation. *