Esempio n. 1
0
 protected function _drawLine(Image_3D_Point $p1, Image_3D_Point $p2)
 {
     list($x1, $y1) = $p1->getScreenCoordinates();
     list($x2, $y2) = $p2->getScreenCoordinates();
     $z1 = $p1->getZ();
     $z2 = $p2->getZ();
     $steps = ceil(max(abs($x1 - $x2), abs($y1 - $y2)));
     $xdiff = ($x2 - $x1) / $steps;
     $ydiff = ($y2 - $y1) / $steps;
     $zdiff = ($z2 - $z1) / $steps;
     $points = array('height' => array(), 'coverage' => array());
     for ($i = 0; $i < $steps; $i++) {
         $x = $x1 + $i * $xdiff;
         $xFloor = floor($x);
         $xCeil = ceil($x);
         $xOffset = $x - $xFloor;
         $y = $y1 + $i * $ydiff;
         $yFloor = floor($y);
         $yCeil = ceil($y);
         $yOffset = $y - $yFloor;
         if (!isset($points['coverage'][(int) $xFloor][(int) $yCeil])) {
             $points['height'][(int) $xFloor][(int) $yCeil] = $z1 + $i * $zdiff;
             $points['coverage'][(int) $xFloor][(int) $yCeil] = (1 - $xOffset) * $yOffset;
         } else {
             $points['coverage'][(int) $xFloor][(int) $yCeil] += (1 - $xOffset) * $yOffset;
         }
         if (!isset($points['coverage'][(int) $xFloor][(int) $yFloor])) {
             $points['height'][(int) $xFloor][(int) $yFloor] = $z1 + $i * $zdiff;
             $points['coverage'][(int) $xFloor][(int) $yFloor] = (1 - $xOffset) * (1 - $yOffset);
         } else {
             $points['coverage'][(int) $xFloor][(int) $yFloor] += (1 - $xOffset) * (1 - $yOffset);
         }
         if (!isset($points['coverage'][(int) $xCeil][(int) $yCeil])) {
             $points['height'][(int) $xCeil][(int) $yCeil] = $z1 + $i * $zdiff;
             $points['coverage'][(int) $xCeil][(int) $yCeil] = $xOffset * $yOffset;
         } else {
             $points['coverage'][(int) $xCeil][(int) $yCeil] += $xOffset * $yOffset;
         }
         if (!isset($points['coverage'][(int) $xCeil][(int) $yFloor])) {
             $points['height'][(int) $xCeil][(int) $yFloor] = $z1 + $i * $zdiff;
             $points['coverage'][(int) $xCeil][(int) $yFloor] = $xOffset * (1 - $yOffset);
         } else {
             $points['coverage'][(int) $xCeil][(int) $yFloor] += $xOffset * (1 - $yOffset);
         }
     }
     return $points;
 }
Esempio n. 2
0
 /**
  * Caclulate Screen Coordinates
  *
  * Calculate isometric screen coordinates for a point 
  *
  * @param Image_3D_Point $point Point to process
  *
  * @return  void
  */
 protected function _calculateScreenCoordiantes(Image_3D_Point $point)
 {
     $point->setScreenCoordinates($point->getX() - $point->getZ() * 0.35 + $this->_size[0], $point->getY() + $point->getZ() * 0.35 + $this->_size[1]);
 }
Esempio n. 3
0
 /**
  * Caclulate Screen Coordinates
  *
  * Calculate perspectively screen coordinates for a point
  *
  * @param Image_3D_Point $point Point to process
  *
  * @return  void
  */
 protected function _calculateScreenCoordiantes(Image_3D_Point $point)
 {
     $viewpoint = 500.0;
     $distance = 500.0;
     $point->setScreenCoordinates($viewpoint * $point->getX() / ($point->getZ() + $distance) + $this->_size[0], $viewpoint * $point->getY() / ($point->getZ() + $distance) + $this->_size[1]);
 }
Esempio n. 4
0
 public function addPoint(Image_3D_Point $point)
 {
     $this->_points[] = $point;
     // Adjust bounding rectangle
     if (!isset($this->_boundingRect[0]) || $point->getX() < $this->_boundingRect[0]) {
         $this->_boundingRect[0] = $point->getX();
     }
     if (!isset($this->_boundingRect[1]) || $point->getY() < $this->_boundingRect[1]) {
         $this->_boundingRect[1] = $point->getY();
     }
     if (!isset($this->_boundingRect[2]) || $point->getZ() < $this->_boundingRect[2]) {
         $this->_boundingRect[2] = $point->getZ();
     }
     if (!isset($this->_boundingRect[3]) || $point->getX() > $this->_boundingRect[3]) {
         $this->_boundingRect[3] = $point->getX();
     }
     if (!isset($this->_boundingRect[4]) || $point->getY() > $this->_boundingRect[4]) {
         $this->_boundingRect[4] = $point->getY();
     }
     if (!isset($this->_boundingRect[5]) || $point->getZ() > $this->_boundingRect[5]) {
         $this->_boundingRect[5] = $point->getZ();
     }
 }