Heap of bugfixes, cleanup and PHP 7 upgrades

This commit is contained in:
Dylan K. Taylor
2017-07-13 19:18:56 +01:00
parent c2a7c2c6cd
commit 2a7b736f18
49 changed files with 114 additions and 148 deletions

View File

@ -55,17 +55,17 @@ class Matrix implements \ArrayAccess{
for($r = 0; $r < $this->rows; ++$r){
$this->matrix[$r] = [];
for($c = 0; $c < $this->columns; ++$c){
$this->matrix[$r][$c] = isset($m[$r][$c]) ? $m[$r][$c] : 0;
$this->matrix[$r][$c] = $m[$r][$c] ?? 0;
}
}
}
public function getRows(){
return ($this->rows);
return $this->rows;
}
public function getColumns(){
return ($this->columns);
return $this->columns;
}
public function setElement($row, $column, $value){

View File

@ -100,7 +100,7 @@ class Vector2{
if($x instanceof Vector2){
return $this->distanceSquared($x->x, $x->y);
}else{
return pow($this->x - $x, 2) + pow($this->y - $y, 2);
return (($this->x - $x) ** 2) + (($this->y - $y) ** 2);
}
}

View File

@ -189,7 +189,7 @@ class Vector3{
}
public function distanceSquared(Vector3 $pos){
return pow($this->x - $pos->x, 2) + pow($this->y - $pos->y, 2) + pow($this->z - $pos->z, 2);
return (($this->x - $pos->x) ** 2) + (($this->y - $pos->y) ** 2) + (($this->z - $pos->z) ** 2);
}
public function maxPlainDistance($x = 0, $z = 0){