You are here

function pSurface::getNearestNeighbor in Visitors 7

Same name and namespace in other branches
  1. 7.2 pChart/class/pSurface.class.php \pSurface::getNearestNeighbor()
1 call to pSurface::getNearestNeighbor()
pSurface::computeMissing in pChart/class/pSurface.class.php

File

pChart/class/pSurface.class.php, line 296

Class

pSurface

Code

function getNearestNeighbor($Xp, $Yp) {
  $Nearest = UNKNOWN;
  for ($X = 0; $X <= $this->GridSizeX; $X++) {
    for ($Y = 0; $Y <= $this->GridSizeY; $Y++) {
      if ($this->Points[$X][$Y] != UNKNOWN && $this->Points[$X][$Y] != IGNORED) {
        $DistanceX = max($Xp, $X) - min($Xp, $X);
        $DistanceY = max($Yp, $Y) - min($Yp, $Y);
        $Distance = max($DistanceX, $DistanceY);
        if ($Distance < $Nearest || $Nearest == UNKNOWN) {
          $Nearest = $Distance;
        }
      }
    }
  }
  return $Nearest;
}