From f79c6cf2e9f72ba316e53d848de2b4131fa8cb3c Mon Sep 17 00:00:00 2001 From: Shoghi Cervantes Pueyo Date: Tue, 15 Jan 2013 17:18:05 +0100 Subject: [PATCH] getSide() Vector3 method --- src/classes/math/Vector3.php | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/src/classes/math/Vector3.php b/src/classes/math/Vector3.php index 4e6d5eca..7bbcdbfa 100644 --- a/src/classes/math/Vector3.php +++ b/src/classes/math/Vector3.php @@ -116,6 +116,25 @@ class Vector3{ public function abs(){ return new Vector3(abs($this->x), abs($this->y), abs($this->z)); } + + public function getSide($side){ + switch((int) $side){ + case 0: + return new Vector3($this->x, $this->y - 1, $this->z); + case 1: + return new Vector3($this->x, $this->y + 1, $this->z); + case 2: + return new Vector3($this->x, $this->y, $this->z - 1); + case 3: + return new Vector3($this->x, $this->y, $this->z + 1); + case 4: + return new Vector3($this->x - 1, $this->y, $this->z); + case 5: + return new Vector3($this->x + 1, $this->y, $this->z); + default: + return $this; + } + } public function distance($x = 0, $y = 0, $z = 0){ if(($x instanceof Vector3) === true){