Browse Source

Added multiply and divide functions to Vector2.

Daniel Eriksson 11 years ago
parent
commit
b8a09be204
1 changed files with 27 additions and 0 deletions
  1. 27 0
      Babylon/Math/babylon.math.ts

+ 27 - 0
Babylon/Math/babylon.math.ts

@@ -272,6 +272,33 @@
             return otherVector && this.x === otherVector.x && this.y === otherVector.y;
         }
 
+        public multiplyInPlace(otherVector: Vector2): void {
+            this.x *= otherVector.x;
+            this.y *= otherVector.y;
+        }
+
+        public multiply(otherVector: Vector2): Vector2 {
+            return new Vector2(this.x * otherVector.x, this.y * otherVector.y);
+        }
+
+        public multiplyToRef(otherVector: Vector2, result: Vector2): void {
+            result.x = this.x * otherVector.x;
+            result.y = this.y * otherVector.y;
+        }
+
+        public multiplyByFloats(x: number, y: number): Vector2 {
+            return new Vector2(this.x * x, this.y * y);
+        }
+
+        public divide(otherVector: Vector2): Vector2 {
+            return new Vector2(this.x / otherVector.x, this.y / otherVector.y);
+        }
+
+        public divideToRef(otherVector: Vector2, result: Vector2): void {
+            result.x = this.x / otherVector.x;
+            result.y = this.y / otherVector.y;
+        }
+		
         // Properties
         public length(): number {
             return Math.sqrt(this.x * this.x + this.y * this.y);