public function placeOnField(Field $field)
 {
     $iterations = 0;
     while (true) {
         $field->placeCursor($this->cursor);
         $this->cursor->moveLinear($this->vector, $this->factor);
         if ($this->endPoint->equal($this->cursor->getZeroPoint())) {
             $field->placeCursor($this->cursor);
             break;
         }
         //just debug issue
         if ($iterations++ > 5000) {
             var_dump("Max iterations!");
             break;
         }
     }
 }
 /**
  * @param IPointConverted $zeroPoint
  * @param LinearVector $vector
  * @param IFieldConfiguration $config
  * @param float $width cursor width in meters
  */
 public function __construct(IPointConverted $zeroPoint, LinearVector $vector, IFieldConfiguration $config, $width)
 {
     $this->initialPoints = [$zeroPoint->moveLinear($vector, 0)];
     $this->currentPoints = [$zeroPoint->moveLinear($vector, 0)];
     $i = 1;
     while (true) {
         $point = $zeroPoint->moveLinear($vector, $i);
         if ($point->distance($zeroPoint, $config) > $width / 2 || $vector->getLatFactor() == 0 && $vector->getLonFactor() == 0) {
             break;
         } else {
             $this->initialPoints[] = $point;
             $this->currentPoints[] = clone $point;
             $negative = $zeroPoint->moveLinear($vector, -1 * $i);
             if ($negative->distance($point, $config) < $width) {
                 $this->initialPoints[] = $negative;
                 $this->currentPoints[] = clone $negative;
                 $i++;
             } else {
                 break;
             }
         }
     }
 }
 /**
  * Create new PointConverted as a subtraction of the current one and the given
  * @param IPointConverted $point
  * @param IFieldConfiguration $config
  * @return PointConverted
  */
 public function subtract(IPointConverted $point, IFieldConfiguration $config)
 {
     return new PointConverted($this->latitude - $point->getLatitude(), $this->longitude - $point->getLongitude(), $config);
 }
Exemple #4
0
 /**
  * Fill the cell
  * @param IPointConverted $point
  * @throws OutOfFieldException
  */
 private function fillCell(IPointConverted $point)
 {
     if (!isset($this->field[$point->getOffset()])) {
         throw new OutOfFieldException("Point outside of the field");
     }
     $item =& $this->field[$point->getOffset()];
     if ($item & $this->bitMask[$point->getBitOffset()]) {
         $this->duplicateCells++;
     } else {
         $this->filledCells++;
     }
     $item |= $this->bitMask[$point->getBitOffset()];
 }