FACT++  1.0
void BasicGlCamera::updateNeighbors ( int  currentPixel)
protected

Definition at line 895 of file BasicGlCamera.cc.

References hexRadius, hexTolerance, i, neighbors, and pixelsCoords.

Referenced by assignPixelMap(), and calculatePixelsCoords().

896  {
897  float squaredDistance = 0;
898  for (int i=0;i<currentPixel;i++)
899  {
900  squaredDistance = (pixelsCoords[i][0] - pixelsCoords[currentPixel][0])*
901  (pixelsCoords[i][0] - pixelsCoords[currentPixel][0]) +
902  (pixelsCoords[i][1] - pixelsCoords[currentPixel][1])*
903  (pixelsCoords[i][1] - pixelsCoords[currentPixel][1]);
904  if (squaredDistance < 4*hexRadius*hexRadius*(1.0f+hexTolerance))//neighbor !
905  {//ok, but which one ?
906  if (fabs(pixelsCoords[i][0] - pixelsCoords[currentPixel][0]) < hexTolerance &&
907  pixelsCoords[i][1] < pixelsCoords[currentPixel][1]){//top
908  neighbors[i][0] = currentPixel;
909  neighbors[currentPixel][3] = i;
910  continue;}
911  if (fabs(pixelsCoords[i][0] - pixelsCoords[currentPixel][0]) < hexTolerance &&
912  pixelsCoords[i][1] > pixelsCoords[currentPixel][1]){//bottom
913  neighbors[i][3] = currentPixel;
914  neighbors[currentPixel][0] = i;
915  continue;}
916  if (pixelsCoords[i][0] > pixelsCoords[currentPixel][0] &&
917  pixelsCoords[i][1] > pixelsCoords[currentPixel][1]){//top right
918  neighbors[i][4] = currentPixel;
919  neighbors[currentPixel][1] = i;
920  continue;}
921  if (pixelsCoords[i][0] > pixelsCoords[currentPixel][0] &&
922  pixelsCoords[i][1] < pixelsCoords[currentPixel][1]){//bottom right
923  neighbors[i][5] = currentPixel;
924  neighbors[currentPixel][2] = i;
925  continue;}
926  if (pixelsCoords[i][0] < pixelsCoords[currentPixel][0] &&
927  pixelsCoords[i][1] > pixelsCoords[currentPixel][1]){//top left
928  neighbors[i][2] = currentPixel;
929  neighbors[currentPixel][5] = i;
930  continue;}
931  if (pixelsCoords[i][0] < pixelsCoords[currentPixel][0] &&
932  pixelsCoords[i][1] < pixelsCoords[currentPixel][1]){//bottom left
933  neighbors[i][1] = currentPixel;
934  neighbors[currentPixel][4] = i;
935  continue;}
936  }
937  }
938  }
int i
Definition: db_dim_client.c:21
static PixelsNeighbors neighbors[MAX_NUM_PIXELS]
static GLfloat pixelsCoords[MAX_NUM_PIXELS][3]

+ Here is the caller graph for this function: