diff --git a/jme3-core/src/main/java/com/jme3/math/Vector2f.java b/jme3-core/src/main/java/com/jme3/math/Vector2f.java
index e32871d75b..429f64828a 100644
--- a/jme3-core/src/main/java/com/jme3/math/Vector2f.java
+++ b/jme3-core/src/main/java/com/jme3/math/Vector2f.java
@@ -629,6 +629,28 @@ public Vector2f normalizeLocal() {
return divideLocal(1);
}
+ /**
+ * Computes the absolute value of each component and returns the result as a
+ * new instance. The current instance is unaffected.
+ *
+ * @return a new Vector2f with non-negative components
+ */
+ public Vector2f abs() {
+ return new Vector2f(Math.abs(x), Math.abs(y));
+ }
+
+ /**
+ * Computes the absolute value of each component and returns the (modified)
+ * current instance.
+ *
+ * @return the (modified) current instance (for chaining)
+ */
+ public Vector2f absLocal() {
+ x = Math.abs(x);
+ y = Math.abs(y);
+ return this;
+ }
+
/**
* Returns the unsigned angle between the current instance and the argument,
* provided both vectors have length=1. If {@code otherVector} is null, Pi/2
diff --git a/jme3-core/src/main/java/com/jme3/math/Vector3f.java b/jme3-core/src/main/java/com/jme3/math/Vector3f.java
index fa5a8539cd..240a5f4653 100644
--- a/jme3-core/src/main/java/com/jme3/math/Vector3f.java
+++ b/jme3-core/src/main/java/com/jme3/math/Vector3f.java
@@ -828,6 +828,29 @@ public Vector3f normalizeLocal() {
return this;
}
+ /**
+ * Computes the absolute value of each component and returns the result as a
+ * new instance. The current instance is unaffected.
+ *
+ * @return a new Vector3f with non-negative components
+ */
+ public Vector3f abs() {
+ return new Vector3f(Math.abs(x), Math.abs(y), Math.abs(z));
+ }
+
+ /**
+ * Computes the absolute value of each component and returns the (modified)
+ * current instance.
+ *
+ * @return the (modified) current instance (for chaining)
+ */
+ public Vector3f absLocal() {
+ x = Math.abs(x);
+ y = Math.abs(y);
+ z = Math.abs(z);
+ return this;
+ }
+
/**
* Compares this vector component-wise with the argument (keeping the most
* positive value for each component) and returns the (modified) current
diff --git a/jme3-core/src/main/java/com/jme3/math/Vector4f.java b/jme3-core/src/main/java/com/jme3/math/Vector4f.java
index cf18c4be50..d2173d02e5 100644
--- a/jme3-core/src/main/java/com/jme3/math/Vector4f.java
+++ b/jme3-core/src/main/java/com/jme3/math/Vector4f.java
@@ -782,6 +782,30 @@ public Vector4f normalizeLocal() {
return this;
}
+ /**
+ * Computes the absolute value of each component and returns the result as a
+ * new instance. The current instance is unaffected.
+ *
+ * @return a new Vector4f with non-negative components
+ */
+ public Vector4f abs() {
+ return new Vector4f(Math.abs(x), Math.abs(y), Math.abs(z), Math.abs(w));
+ }
+
+ /**
+ * Computes the absolute value of each component and returns the (modified)
+ * current instance.
+ *
+ * @return the (modified) current instance (for chaining)
+ */
+ public Vector4f absLocal() {
+ x = Math.abs(x);
+ y = Math.abs(y);
+ z = Math.abs(z);
+ w = Math.abs(w);
+ return this;
+ }
+
/**
* maxLocal computes the maximum value for each
* component in this and other vector. The result is stored