From 808f5473d0e18999f3668620b31444e8a706702f Mon Sep 17 00:00:00 2001 From: Shoghi Cervantes Date: Mon, 10 Jun 2013 17:10:49 +0200 Subject: [PATCH] Added more Vector math --- src/math/Vector2.php | 8 ++++++++ src/math/Vector3.php | 8 ++++++++ src/math/VectorMath.php | 34 ++++++++++++++++++++++++++++++++++ 3 files changed, 50 insertions(+) create mode 100644 src/math/VectorMath.php diff --git a/src/math/Vector2.php b/src/math/Vector2.php index 20c17158..d575624f 100644 --- a/src/math/Vector2.php +++ b/src/math/Vector2.php @@ -86,6 +86,14 @@ class Vector2{ public function abs(){ return new Vector2(abs($this->x), abs($this->y)); } + + public function multiply($number){ + return new Vector2($this->x * $number, $this->y * $number); + } + + public function divide($number){ + return new Vector2($this->x / $number, $this->y / $number); + } public function distance($x = 0, $y = 0){ if(($x instanceof Vector2) === true){ diff --git a/src/math/Vector3.php b/src/math/Vector3.php index 91f425df..20f7d1d8 100644 --- a/src/math/Vector3.php +++ b/src/math/Vector3.php @@ -97,6 +97,14 @@ class Vector3{ return $this->add(-$x, -$y, -$z); } } + + public function multiply($number){ + return new Vector3($this->x * $number, $this->y * $number, $this->z * $number); + } + + public function divide($number){ + return new Vector3($this->x / $number, $this->y / $number, $this->z / $number); + } public function ceil(){ return new Vector3((int) ($this->x + 1), (int) ($this->y + 1), (int) ($this->z + 1)); diff --git a/src/math/VectorMath.php b/src/math/VectorMath.php new file mode 100644 index 00000000..64dc5b67 --- /dev/null +++ b/src/math/VectorMath.php @@ -0,0 +1,34 @@ +