예제 #1
0
파일: project.php 프로젝트: eXcomm/alive
 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');
 }
예제 #2
0
파일: vector.php 프로젝트: eXcomm/alive
 public function ToMatrix()
 {
     return ALiVE_Vectors_ToMatrix(array($this));
 }