فهرست منبع

add missed `negate` methods

Avin Grape 5 سال پیش
والد
کامیت
e051c8fbb9
1فایلهای تغییر یافته به همراه40 افزوده شده و 0 حذف شده
  1. 40 0
      src/Maths/math.vector.ts

+ 40 - 0
src/Maths/math.vector.ts

@@ -257,6 +257,25 @@ export class Vector2 {
     }
 
     /**
+     * Negate this vector in place
+     * @returns this
+     */
+    public negateInPlace(): Vector2 {
+        this.x *= -1;
+        this.y *= -1;
+        return this;
+    }
+
+    /**
+     * Negate the current Vector2 and stores the result in the given vector "result" coordinates
+     * @param result defines the Vector3 object where to store the result
+     * @returns the current Vector2
+     */
+    public negateToRef(result: Vector2): Vector2 {
+        return result.copyFromFloats(this.x * -1, this.y * -1);
+    }
+
+    /**
      * Multiply the Vector2 coordinates by scale
      * @param scale defines the scaling factor
      * @returns the current updated Vector2
@@ -2110,6 +2129,27 @@ export class Vector4 {
     }
 
     /**
+     * Negate this vector in place
+     * @returns this
+     */
+    public negateInPlace(): Vector4 {
+        this.x *= -1;
+        this.y *= -1;
+        this.z *= -1;
+        this.w *= -1;
+        return this;
+    }
+
+    /**
+     * Negate the current Vector4 and stores the result in the given vector "result" coordinates
+     * @param result defines the Vector3 object where to store the result
+     * @returns the current Vector4
+     */
+    public negateToRef(result: Vector4): Vector4 {
+        return result.copyFromFloats(this.x * -1, this.y * -1, this.z * -1, this.w * -1);
+    }
+
+    /**
      * Multiplies the current Vector4 coordinates by scale (float).
      * @param scale the number to scale with
      * @returns the updated Vector4.