public function Apply($target) { if ($target instanceof ALiVE_Matrix) { return ALiVE_Matrices_Multiply($target, $this->ToMatrix()); } else { if ($target instanceof ALiVE_Vector) { return new ALiVE_2D_Vector($this->Apply($target->ToMatrix())); } else { if (is_array($target)) { foreach ($target as $vector) { w_assert($vector instanceof ALiVE_Vector); } $result = $this->Apply(ALiVE_Vectors_ToMatrix($target)); $ret = array(); for ($i = 0; $i < $result->M(); ++$i) { $thismatrix = new ALiVE_Matrix(1, 4); $thismatrix->Set(0, 0, $result->Get($i, 0)); $thismatrix->Set(0, 1, $result->Get($i, 1)); $thismatrix->Set(0, 2, $result->Get($i, 2)); $thismatrix->Set(0, 3, $result->Get($i, 3)); $ret[] = new ALiVE_2D_Vector($thismatrix); } return $ret; } } } throw new Exception('Invalid projection application argument'); }
public function ToMatrix() { return ALiVE_Vectors_ToMatrix(array($this)); }