public function multiply(mat4 $other) { $result = [[0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0]]; $otherArray = $other->toArray(); for ($i = 0; $i < 4; $i++) { for ($j = 0; $j < 4; $j++) { for ($k = 0; $k < 4; $k++) { $result[$i][$j] += $this->data[$i][$k] * $otherArray[$k][$j]; } } } return new mat4($result); }
public function testConstructorDefaultsToIdentityMatrix() { $matrix = new mat4(); $expectedArray = array(array(1, 0, 0, 0), array(0, 1, 0, 0), array(0, 0, 1, 0), array(0, 0, 0, 1)); $this->assertEquals($expectedArray, $matrix->toArray()); }