Ejemplo n.º 1
0
 /**
  * Transform the Coordinate
  *
  * Use a transformationmatrix to transform (move) the point
  * 
  * @param Image_3D_Matrix $matrix Transformationmatrix
  * @param string          $id     Transformationid
  *
  * @return  void
  */
 public function transform(Image_3D_Matrix $matrix, $id = null)
 {
     // Point already transformed?
     if ($id !== null && $this->_lastTransformation === $id) {
         return false;
     }
     $this->_lastTransformation = $id;
     $point = clone $this;
     $this->_x = $point->getX() * $matrix->getValue(0, 0) + $point->getY() * $matrix->getValue(1, 0) + $point->getZ() * $matrix->getValue(2, 0) + $matrix->getValue(3, 0);
     $this->_y = $point->getX() * $matrix->getValue(0, 1) + $point->getY() * $matrix->getValue(1, 1) + $point->getZ() * $matrix->getValue(2, 1) + $matrix->getValue(3, 1);
     $this->_z = $point->getX() * $matrix->getValue(0, 2) + $point->getY() * $matrix->getValue(1, 2) + $point->getZ() * $matrix->getValue(2, 2) + $matrix->getValue(3, 2);
     $this->_screenCoordinates = null;
 }
Ejemplo n.º 2
0
 public function multiply(Image_3D_Matrix $matrix)
 {
     $new = clone $this;
     for ($i = 0; $i < 4; $i++) {
         for ($j = 0; $j < 4; $j++) {
             $sum = 0;
             for ($k = 0; $k < 4; $k++) {
                 $sum += $new->getValue($i, $k) * $matrix->getValue($k, $j);
             }
             $this->setValue($i, $j, $sum);
         }
     }
     return $this;
 }