Beispiel #1
0
int main(){
	areEquals(4,add(2,2));
	areEquals(12, multiply(3,4));
	areEquals(1024, pow(2,10));
	std::cout<<"End of tests"<<std::endl;
	return 0;
}
Beispiel #2
0
template<typename PointInT, typename PointNT, typename PointOutT> void
pcl::BOARDLocalReferenceFrameEstimation<PointInT, PointNT, PointOutT>::randomOrthogonalAxis (
                                                                                             Eigen::Vector3f const &axis,
                                                                                             Eigen::Vector3f &rand_ortho_axis)
{
  if (!areEquals (axis.z (), 0.0f))
  {
    rand_ortho_axis.x () = (static_cast<float> (rand ()) / static_cast<float> (RAND_MAX)) * 2.0f - 1.0f;
    rand_ortho_axis.y () = (static_cast<float> (rand ()) / static_cast<float> (RAND_MAX)) * 2.0f - 1.0f;
    rand_ortho_axis.z () = -(axis.x () * rand_ortho_axis.x () + axis.y () * rand_ortho_axis.y ()) / axis.z ();
  }
  else if (!areEquals (axis.y (), 0.0f))
  {
    rand_ortho_axis.x () = (static_cast<float> (rand ()) / static_cast<float> (RAND_MAX)) * 2.0f - 1.0f;
    rand_ortho_axis.z () = (static_cast<float> (rand ()) / static_cast<float> (RAND_MAX)) * 2.0f - 1.0f;
    rand_ortho_axis.y () = -(axis.x () * rand_ortho_axis.x () + axis.z () * rand_ortho_axis.z ()) / axis.y ();
  }
  else if (!areEquals (axis.x (), 0.0f))
  {
    rand_ortho_axis.y () = (static_cast<float> (rand ()) / static_cast<float> (RAND_MAX)) * 2.0f - 1.0f;
    rand_ortho_axis.z () = (static_cast<float> (rand ()) / static_cast<float> (RAND_MAX)) * 2.0f - 1.0f;
    rand_ortho_axis.x () = -(axis.y () * rand_ortho_axis.y () + axis.z () * rand_ortho_axis.z ()) / axis.x ();
  }

  rand_ortho_axis.normalize ();

  // check if the computed x axis is orthogonal to the normal
  //assert(areEquals(rand_ortho_axis.dot(axis), 0.0f, 1E-6f));
}
Beispiel #3
0
int main() {
	areEquals(4, add(2,2));
	areEquals(8,multiply(2,4));
	areEquals(8, pow(2,3));
	std::cout << "End of testes!" << std::endl;
	return 0;
}
Beispiel #4
0
int main()
{
	areEquals(4, add(2, 2));
	areEquals(8, multiply(2, 4));
	areEquals(16, pow(2, 4));
	std::cin.get();
	return 0;
}
Beispiel #5
0
void applyRules(struct grid * Grid){
	struct grid g;
	do{
		g=copy(*Grid);
		fill_grid_boarder_line_by_spaces(Grid);
		fill_grid_boarder_column_by_spaces(Grid);
		fill_grid_by_spaces(Grid);
		joining(Grid);
	
		splitting(Grid);
	
	
		simple_box(Grid);
		fill_grid_by_spaces(Grid);
	}
	while(!areEquals(g,*Grid));	
}
Beispiel #6
0
template <typename PointInT, typename PointNT, typename PointOutT, typename PointRFT> void
pcl::SHOTEstimationBase<PointInT, PointNT, PointOutT, PointRFT>::interpolateSingleChannel (
    const std::vector<int> &indices,
    const std::vector<float> &sqr_dists,
    const int index,
    std::vector<double> &binDistance,
    const int nr_bins,
    Eigen::VectorXf &shot)
{
  const Eigen::Vector4f& central_point = (*input_)[(*indices_)[index]].getVector4fMap ();
  const PointRFT& current_frame = (*frames_)[index];

  Eigen::Vector4f current_frame_x (current_frame.x_axis[0], current_frame.x_axis[1], current_frame.x_axis[2], 0);
  Eigen::Vector4f current_frame_y (current_frame.y_axis[0], current_frame.y_axis[1], current_frame.y_axis[2], 0);
  Eigen::Vector4f current_frame_z (current_frame.z_axis[0], current_frame.z_axis[1], current_frame.z_axis[2], 0);

  for (size_t i_idx = 0; i_idx < indices.size (); ++i_idx)
  {
    if (!pcl_isfinite(binDistance[i_idx]))
      continue;

    Eigen::Vector4f delta = surface_->points[indices[i_idx]].getVector4fMap () - central_point;
    delta[3] = 0;

    // Compute the Euclidean norm
   double distance = sqrt (sqr_dists[i_idx]);

    if (areEquals (distance, 0.0))
      continue;

    double xInFeatRef = delta.dot (current_frame_x);
    double yInFeatRef = delta.dot (current_frame_y);
    double zInFeatRef = delta.dot (current_frame_z);

    // To avoid numerical problems afterwards
    if (fabs (yInFeatRef) < 1E-30)
      yInFeatRef  = 0;
    if (fabs (xInFeatRef) < 1E-30)
      xInFeatRef  = 0;
    if (fabs (zInFeatRef) < 1E-30)
      zInFeatRef  = 0;


    unsigned char bit4 = ((yInFeatRef > 0) || ((yInFeatRef == 0.0) && (xInFeatRef < 0))) ? 1 : 0;
    unsigned char bit3 = static_cast<unsigned char> (((xInFeatRef > 0) || ((xInFeatRef == 0.0) && (yInFeatRef > 0))) ? !bit4 : bit4);

    assert (bit3 == 0 || bit3 == 1);

    int desc_index = (bit4<<3) + (bit3<<2);

    desc_index = desc_index << 1;

    if ((xInFeatRef * yInFeatRef > 0) || (xInFeatRef == 0.0))
      desc_index += (fabs (xInFeatRef) >= fabs (yInFeatRef)) ? 0 : 4;
    else
      desc_index += (fabs (xInFeatRef) > fabs (yInFeatRef)) ? 4 : 0;

    desc_index += zInFeatRef > 0 ? 1 : 0;

    // 2 RADII
    desc_index += (distance > radius1_2_) ? 2 : 0;

    int step_index = static_cast<int>(floor (binDistance[i_idx] +0.5));
    int volume_index = desc_index * (nr_bins+1);

    //Interpolation on the cosine (adjacent bins in the histogram)
    binDistance[i_idx] -= step_index;
    double intWeight = (1- fabs (binDistance[i_idx]));

    if (binDistance[i_idx] > 0)
      shot[volume_index + ((step_index+1) % nr_bins)] += static_cast<float> (binDistance[i_idx]);
    else
      shot[volume_index + ((step_index - 1 + nr_bins) % nr_bins)] += - static_cast<float> (binDistance[i_idx]);

    //Interpolation on the distance (adjacent husks)

    if (distance > radius1_2_)   //external sphere
    {
      double radiusDistance = (distance - radius3_4_) / radius1_2_;

      if (distance > radius3_4_) //most external sector, votes only for itself
        intWeight += 1 - radiusDistance;  //peso=1-d
      else  //3/4 of radius, votes also for the internal sphere
      {
        intWeight += 1 + radiusDistance;
        shot[(desc_index - 2) * (nr_bins+1) + step_index] -= static_cast<float> (radiusDistance);
      }
    }
    else    //internal sphere
    {
      double radiusDistance = (distance - radius1_4_) / radius1_2_;

      if (distance < radius1_4_) //most internal sector, votes only for itself
        intWeight += 1 + radiusDistance;  //weight=1-d
      else  //3/4 of radius, votes also for the external sphere
      {
        intWeight += 1 - radiusDistance;
        shot[(desc_index + 2) * (nr_bins+1) + step_index] += static_cast<float> (radiusDistance);
      }
    }

    //Interpolation on the inclination (adjacent vertical volumes)
    double inclinationCos = zInFeatRef / distance;
    if (inclinationCos < - 1.0)
      inclinationCos = - 1.0;
    if (inclinationCos > 1.0)
      inclinationCos = 1.0;

    double inclination = acos (inclinationCos);

    assert (inclination >= 0.0 && inclination <= PST_RAD_180);

    if (inclination > PST_RAD_90 || (fabs (inclination - PST_RAD_90) < 1e-30 && zInFeatRef <= 0))
    {
      double inclinationDistance = (inclination - PST_RAD_135) / PST_RAD_90;
      if (inclination > PST_RAD_135)
        intWeight += 1 - inclinationDistance;
      else
      {
        intWeight += 1 + inclinationDistance;
        assert ((desc_index + 1) * (nr_bins+1) + step_index >= 0 && (desc_index + 1) * (nr_bins+1) + step_index < descLength_);
        shot[(desc_index + 1) * (nr_bins+1) + step_index] -= static_cast<float> (inclinationDistance);
      }
    }
    else
    {
      double inclinationDistance = (inclination - PST_RAD_45) / PST_RAD_90;
      if (inclination < PST_RAD_45)
        intWeight += 1 + inclinationDistance;
      else
      {
        intWeight += 1 - inclinationDistance;
        assert ((desc_index - 1) * (nr_bins+1) + step_index >= 0 && (desc_index - 1) * (nr_bins+1) + step_index < descLength_);
        shot[(desc_index - 1) * (nr_bins+1) + step_index] += static_cast<float> (inclinationDistance);
      }
    }

    if (yInFeatRef != 0.0 || xInFeatRef != 0.0)
    {
      //Interpolation on the azimuth (adjacent horizontal volumes)
      double azimuth = atan2 (yInFeatRef, xInFeatRef);

      int sel = desc_index >> 2;
      double angularSectorSpan = PST_RAD_45;
      double angularSectorStart = - PST_RAD_PI_7_8;

      double azimuthDistance = (azimuth - (angularSectorStart + angularSectorSpan*sel)) / angularSectorSpan;

      assert ((azimuthDistance < 0.5 || areEquals (azimuthDistance, 0.5)) && (azimuthDistance > - 0.5 || areEquals (azimuthDistance, - 0.5)));

      azimuthDistance = (std::max)(- 0.5, std::min (azimuthDistance, 0.5));

      if (azimuthDistance > 0)
      {
        intWeight += 1 - azimuthDistance;
        int interp_index = (desc_index + 4) % maxAngularSectors_;
        assert (interp_index * (nr_bins+1) + step_index >= 0 && interp_index * (nr_bins+1) + step_index < descLength_);
        shot[interp_index * (nr_bins+1) + step_index] += static_cast<float> (azimuthDistance);
      }
      else
      {
        int interp_index = (desc_index - 4 + maxAngularSectors_) % maxAngularSectors_;
        assert (interp_index * (nr_bins+1) + step_index >= 0 && interp_index * (nr_bins+1) + step_index < descLength_);
        intWeight += 1 + azimuthDistance;
        shot[interp_index * (nr_bins+1) + step_index] -= static_cast<float> (azimuthDistance);
      }

    }

    assert (volume_index + step_index >= 0 &&  volume_index + step_index < descLength_);
    shot[volume_index + step_index] += static_cast<float> (intWeight);
  }
int checkSquare(int fin) {
    int i,j,k,l,t,value,square;
    int I,J;
    int numbers;   //flag mask of completed numbers
    int unique;   //flag mask to find unique flags
    int unique_plus;   //flag mask to exclude not-unique flags
    int finished;   //counter of completed numbers in this square
    int *linCol=(int *) calloc(n,sizeof(int));   //to find allineated flags allineatios
    int *linRow=(int *) calloc(n,sizeof(int));   //to find allineated flags allineatios
    int *totCol=(int *) calloc(n,sizeof(int));   //to eliminate doubled flags
    int *totRow=(int *) calloc(n,sizeof(int));   //to eliminate doubled flags
    if(linCol==NULL || linRow==NULL || totCol==NULL || totRow==NULL)
    {
        fprintf(stderr,"Allocation error (3)\n");
        exit(ERR_ALLOC);
    }

    i=0;
    j=0;

    do {
        finished=0;
        square=(i/n)*n + (j/n);   //position of this square in array q and index in fin
        if((fin & (1<<square)) ==0)   //if this square is not completed
        {
            unique=0;
            unique_plus=0;
            //set the flag mask of completed numbers
            numbers=mask | (mask-1);   //numbers = 1....1 (n2+1 ones)

            I=i;   //coordinates of the 0 point of this square
            J=j;
            do {
                if((m[i][j] & mask) ==0)   //if it's a number
                    numbers=numbers & (numbers^(1<<m[i][j]));   //set to 0 its flag in numbers mask
                else {  //otherwise, if it's an int of flags
                    unique_plus=unique_plus | (unique & m[i][j]);  //detect duplicated flags
                    unique=unique^m[i][j];   //set to 0 flags that are not uniques
                }
            } while(getCoord(&i,&j)==0);

            unique=unique ^ (unique & unique_plus);
            if((unique & mask)==0)   //make sure it has flags's flag
                unique+=mask;

            i=I;   //restart from the beginning of this square
            j=J;
            do {
                if(m[i][j] & mask)   //if it's a flag
                {
                    m[i][j]= m[i][j] & numbers;   //use the mask

                    if((unique & m[i][j])>mask && chkEnabled[LV2])   //check if it has a unique flag
                    {
                        if(DEBUG1) printf("%d uniS: (%d,%d)=%d >>>>%d \n",cycleCounter,i,j,m[i][j],m[i][j] & unique);//////////////////
                        m[i][j]=unique & m[i][j];   //set the other flags to 0
                    }

                    value=checkOneValue(i,j);
                    if(value!=0)
                    {
                        if(value==-1)
                            return -1;  //error in the sudoku

                        if(DEBUG1) printf("NEW: (%d,%d)=%d >>>>%d \n",i,j,m[i][j],value);//////////////////
                        setNum(i,j,value);
                        finished++;
                        numbers=numbers | (1<<value);  //add new number to the mask
                    }
                } else {
                    finished++;
                }
            } while(getCoord(&i,&j)==0);


            if(cycleCounter>CHECK_START)   //Since it's an expensive check, it won't start at the beginning
            {
                if(chkEnabled[LV3])
                {
                    /* LV3: this part will check if there's a flags allineation
                        if a flags allineation if found for a number,
                        a function will set to 0 the number's flags in that line. */

                    //save the possible numbers of the rows and columns
                    for(k=0; k<n; k++)
                    {
                        linCol[k]=0;
                        linRow[k]=0;
                        for(l=0; l<n; l++)
                        {
                            if(m[I+l][J+k] & mask)
                                linCol[k]=linCol[k] | m[I+l][J+k];
                            if(m[I+k][J+l] & mask)
                                linRow[k]=linRow[k] | m[I+k][J+l];
                        }
                    }

                    //compare the flags to exclude common numbers
                    for(k=0; k<n; k++)
                    {
                        totCol[k]=0;
                        totRow[k]=0;
                        for(l=0; l<n; l++) {
                            if(l!=k)
                            {
                                totCol[k]= totCol[k] | linCol[l];
                                totRow[k]= totRow[k] | linRow[l];
                            }
                        }
                    }


                    //check of allineations
                    for(k=0; k<n; k++)
                    {
                        linCol[k]=linCol[k] & (linCol[k] ^ totCol[k]);
                        linRow[k]=linRow[k] & (linRow[k] ^ totRow[k]);

                        if((linCol[k] & mask))   //make sure it has NOT flags's flag
                            linCol[k]-=mask;
                        if((linRow[k] & mask))   //make sure it has NOT flags's flag
                            linRow[k]-=mask;


                        if(linCol[k]>1)
                        {
                            if(DEBUG2) printf("column allineation: %d*,%d, =%d [cycler=%d]\n",I,J+k,linCol[k],cycleCounter);////////

                            warnCol(I,J,k,linCol[k]);
                            if(DEBUG2) printMatrix(stdout,0);
                        }
                        if(linRow[k]>1)
                        {
                            if(DEBUG2) printf("row allineation: %d,%d*, =%d [cycler=%d]\n",I+k,J,linRow[k],cycleCounter);////////

                            warnRow(I,J,k,linRow[k]);
                            if(DEBUG2) printMatrix(stdout,0);
                        }
                    }
                }


                /*
                Cicla sulle caselle di uno square
                cerca un gruppo di celle con flag identici
                se lo trovo ed il numero di caselle è == al numero di numeri possibili
                semplifico quei numeri dal resto dello square
                */
                //LV4
                if(chkEnabled[LV4])
                {
                    i=I;   //restart from the beginning of this square
                    j=J;
                    do {
                        if(m[i][j] & mask)   //if it's a flag
                        {

                            //find groups of cells with identical flags
                            k=0;
                            t=i;
                            l=j;
                            do {
                                if(m[t][l] & mask)   //if it's a flag
                                    if(areEquals(m[i][j],m[t][l]))
                                        k++;
                            } while(getCoord(&t,&l)==0);

                            if(k==countValues(i,j)) {
                                //i found a group of identical flags,
                                //now i can semplify them from the cells that are not in the group

                                t=I;
                                l=J;
                                do {
                                    if(m[t][l] & mask)   //if it's a flag
                                        if(areEquals(m[i][j],m[t][l])==0) {
                                            square=(i/n)*n + (l/n);   //position of this square in array q
                                            m[t][l]=( (m[t][l] ^ m[i][j]) & m[t][l] ) | mask;
                                        }
                                } while(getCoord(&t,&l)==0);
                            }
                        }
                    } while(getCoord(&i,&j)==0);  //*/
                }
            }

            if(finished==n2)
                fin=fin | (1<<square);   //set the flag for this square as completed
        } else {
            while(getCoord(&i,&j)==0);   //select next square
        }
    } while(i<n2 && j<n2);

    free(linCol);
    free(linRow);
    free(totCol);
    free(totRow);

    return fin;
}
Beispiel #8
0
//////////////////////////////////////////////////////////////////////////////////////////////
// Quadrilinear interpolation; used when color and shape descriptions are NOT activated simultaneously
template <typename PointInT, typename PointNT, typename PointOutT> void
pcl::SHOTEstimationBase<PointInT, PointNT, PointOutT>::interpolateSingleChannel (
    const pcl::PointCloud<PointInT> &cloud,
    const std::vector<int> &indices,
    const std::vector<float> &dists,
    const Eigen::Vector4f &central_point,
    const std::vector<Eigen::Vector4f, Eigen::aligned_allocator<Eigen::Vector4f> > &rf,
    std::vector<double> &binDistance,
    const int nr_bins,
    Eigen::VectorXf &shot)
{
  if (rf.size () != 3)
  {
    PCL_ERROR ("[pcl::%s::interpolateSingleChannel] RF size different than 9! Aborting...\n");
    return;
  }

  for (size_t i_idx = 0; i_idx < indices.size (); ++i_idx)
  {
    Eigen::Vector4f delta = cloud.points[indices[i_idx]].getVector4fMap () - central_point;

    // Compute the Euclidean norm
    double distance_sqr = dists[i_idx]; //delta.squaredNorm ();

    if (areEquals (distance_sqr, 0.0))
      continue;

    double xInFeatRef = delta.dot (rf[0]); //(x * feat[i].rf[0] + y * feat[i].rf[1] + z * feat[i].rf[2]);
    double yInFeatRef = delta.dot (rf[1]); //(x * feat[i].rf[3] + y * feat[i].rf[4] + z * feat[i].rf[5]);
    double zInFeatRef = delta.dot (rf[2]); //(x * feat[i].rf[6] + y * feat[i].rf[7] + z * feat[i].rf[8]);

    // To avoid numerical problems afterwards
    if (fabs (yInFeatRef) < 1E-30)
      yInFeatRef  = 0;
    if (fabs (xInFeatRef) < 1E-30)
      xInFeatRef  = 0;
    if (fabs (zInFeatRef) < 1E-30)
      zInFeatRef  = 0;


    unsigned char bit4 = ((yInFeatRef > 0) || ((yInFeatRef == 0.0) && (xInFeatRef < 0))) ? 1 : 0;
    unsigned char bit3 = ((xInFeatRef > 0) || ((xInFeatRef == 0.0) && (yInFeatRef > 0))) ? !bit4 : bit4;

    assert (bit3 == 0 || bit3 == 1);

    int desc_index = (bit4<<3) + (bit3<<2);

    desc_index = desc_index << 1;

    if ((xInFeatRef * yInFeatRef > 0) || (xInFeatRef == 0.0))
      desc_index += (fabs (xInFeatRef) >= fabs (yInFeatRef)) ? 0 : 4;
    else
      desc_index += (fabs (xInFeatRef) > fabs (yInFeatRef)) ? 4 : 0;

    desc_index += zInFeatRef > 0 ? 1 : 0;

    // 2 RADII
    desc_index += (distance_sqr > sqradius4_) ? 2 : 0;

    int step_index = static_cast<int>(floor (binDistance[i_idx] +0.5));
    int volume_index = desc_index * (nr_bins+1);

    //Interpolation on the cosine (adjacent bins in the histogram)
    binDistance[i_idx] -= step_index;
    double intWeight = (1- fabs (binDistance[i_idx]));

    if (binDistance[i_idx] > 0)
      shot[volume_index + ((step_index+1) % nr_bins)] += binDistance[i_idx];
    else
      shot[volume_index + ((step_index - 1 + nr_bins) % nr_bins)] += - binDistance[i_idx];

    //Interpolation on the distance (adjacent husks)
    double distance = sqrt (dists[i_idx]); //sqrt(distance_sqr);

    if (distance > radius1_2_)   //external sphere
    {
      double radiusDistance = (distance - radius3_4_) / radius1_2_;

      if (distance > radius3_4_) //most external sector, votes only for itself
        intWeight += 1 - radiusDistance;  //peso=1-d
      else  //3/4 of radius, votes also for the internal sphere
      {
        intWeight += 1 + radiusDistance;
        shot[(desc_index - 2) * (nr_bins+1) + step_index] -= radiusDistance;
      }
    }
    else    //internal sphere
    {
      double radiusDistance = (distance - radius1_4_) / radius1_2_;

      if (distance < radius1_4_) //most internal sector, votes only for itself
        intWeight += 1 + radiusDistance;  //weight=1-d
      else  //3/4 of radius, votes also for the external sphere
      {
        intWeight += 1 - radiusDistance;
        shot[(desc_index + 2) * (nr_bins+1) + step_index] += radiusDistance;
      }
    }

    //Interpolation on the inclination (adjacent vertical volumes)
    double inclinationCos = zInFeatRef / distance;
    if (inclinationCos < - 1.0)
      inclinationCos = - 1.0;
    if (inclinationCos > 1.0)
      inclinationCos = 1.0;

    double inclination = acos (inclinationCos);

    assert (inclination >= 0.0 && inclination <= PST_RAD_180);

    if (inclination > PST_RAD_90 || (fabs (inclination - PST_RAD_90) < 1e-30 && zInFeatRef <= 0))
    {
      double inclinationDistance = (inclination - PST_RAD_135) / PST_RAD_90;
      if (inclination > PST_RAD_135)
        intWeight += 1 - inclinationDistance;
      else
      {
        intWeight += 1 + inclinationDistance;
        assert ((desc_index + 1) * (nr_bins+1) + step_index >= 0 && (desc_index + 1) * (nr_bins+1) + step_index < descLength_);
        shot[(desc_index + 1) * (nr_bins+1) + step_index] -= inclinationDistance;
      }
    }
    else
    {
      double inclinationDistance = (inclination - PST_RAD_45) / PST_RAD_90;
      if (inclination < PST_RAD_45)
        intWeight += 1 + inclinationDistance;
      else
      {
        intWeight += 1 - inclinationDistance;
        assert ((desc_index - 1) * (nr_bins+1) + step_index >= 0 && (desc_index - 1) * (nr_bins+1) + step_index < descLength_);
        shot[(desc_index - 1) * (nr_bins+1) + step_index] += inclinationDistance;
      }
    }

    if (yInFeatRef != 0.0 || xInFeatRef != 0.0)
    {
      //Interpolation on the azimuth (adjacent horizontal volumes)
      double azimuth = atan2 (yInFeatRef, xInFeatRef);

      int sel = desc_index >> 2;
      double angularSectorSpan = PST_RAD_45;
      double angularSectorStart = - PST_RAD_PI_7_8;

      double azimuthDistance = (azimuth - (angularSectorStart + angularSectorSpan*sel)) / angularSectorSpan;

      assert ((azimuthDistance < 0.5 || areEquals (azimuthDistance, 0.5)) && (azimuthDistance > - 0.5 || areEquals (azimuthDistance, - 0.5)));

      azimuthDistance = (std::max)(- 0.5, std::min (azimuthDistance, 0.5));

      if (azimuthDistance > 0)
      {
        intWeight += 1 - azimuthDistance;
        int interp_index = (desc_index + 4) % maxAngularSectors_;
        assert (interp_index * (nr_bins+1) + step_index >= 0 && interp_index * (nr_bins+1) + step_index < descLength_);
        shot[interp_index * (nr_bins+1) + step_index] += azimuthDistance;
      }
      else
      {
        int interp_index = (desc_index - 4 + maxAngularSectors_) % maxAngularSectors_;
        assert (interp_index * (nr_bins+1) + step_index >= 0 && interp_index * (nr_bins+1) + step_index < descLength_);
        intWeight += 1 + azimuthDistance;
        shot[interp_index * (nr_bins+1) + step_index] -= azimuthDistance;
      }

    }

    assert (volume_index + step_index >= 0 &&  volume_index + step_index < descLength_);
    shot[volume_index + step_index] += intWeight;
  }
int checkColumn(int fin)
{
    int i,j,k,l,value,square;
    int numbers;   //flag mask of completed numbers
    int unique;   //flag mask to find unique flags
    int unique_plus;   //flag mask to exclude not-unique flags
    int finished;   //counter of completed columns
    int *line=(int *) calloc(n,sizeof(int));   //to eliminate doubled flags
    int *totLine=(int *) calloc(n,sizeof(int));   //to eliminate doubled flags

    if(line==NULL || totLine==NULL)
    {
        fprintf(stderr,"Allocation error (5)\n");
        exit(ERR_ALLOC);
    }


    for(j=0; j<n2; j++)
        if( (fin & (1<<j))==0)   //if this column is not completed
        {
            finished=0;
            unique=0;
            unique_plus=0;
            //set the flag mask of completed numbers
            numbers=mask | (mask-1);   //numbers = 1....1 (n2+1 ones)
            for(i=0; i<n2; i++){
                if((m[i][j] & mask) ==0)   //if it's a number
                        numbers=numbers & (numbers^(1<<m[i][j]));   //set to 0 its flag in numbers mask
                else{   //otherwise, if it's an int of flags
                    unique_plus=unique_plus | (unique & m[i][j]);  //detect duplicated flags
                    unique=unique^m[i][j];   //set to 0 flags that are not uniques
                }
			}
            unique=unique ^ (unique & unique_plus);
            if((unique & mask)==0)   //make sure it has flags's flag
                unique+=mask;


            for(i=0; i<n2; i++)
            {
                square=(i/n)*n + (j/n);   //position of this square in array q

                if(m[i][j] & mask)   //if it's a flag
                {
                    m[i][j]= m[i][j] & numbers;   //use the mask

                    if((unique & m[i][j])>mask && chkEnabled[LV2])   //check if it has a unique flag
                    {
                        if(DEBUG1) printf("%d uniC: (%d,%d)=%d >>>>%d \n",cycleCounter,i,j,m[i][j],m[i][j] & unique);//////////////////
                        m[i][j]=unique & m[i][j];   //set the other flags to 0
                    }

                    value=0;
                    value=checkOneValue(i,j);
                    if(value!=0)
                    {
                        if(value==-1)
                            return -1;  //error in the sudoku

                        if(DEBUG1) printf("NEW: (%d,%d)=%d >>>>%d \n",i,j,m[i][j],value);//////////////////
                        setNum(i,j,value);
                        finished++;
                        numbers=numbers | (1<<value);  //add new number to the mask
                    }
                }else{
                        finished++;
                }
            }

            if(cycleCounter>CHECK_START)   //Since it's an expensive check, it won't start at the beginning
            {
                if(chkEnabled[LV3])
                {
                    /* LV3 :this part will check if there's a flags allineation
                    if a flags allineation if found for a number,
                    a function will set to 0 the number's flags in that line. */

                    for(k=0; k<n; k++)
                    {
                        line[k]=0;
                        for(l=0; l<n; l++)
                        {
                            //save the possible numbers of the lines
                            if(m[k*n+l][j] & mask)
                                line[k]=line[k] | m[k*n+l][j];
                        }
                    }

                    //compare the flags to exclude common numbers
                    for(k=0; k<n; k++)
                    {
                        totLine[k]=0;
                        for(l=0; l<n; l++)
                            if(k!=l)
                                totLine[k]= totLine[k] | line[l];
                    }


                    //check of allineations
                    for(k=0; k<n; k++)
                    {
                        line[k]=line[k] & (line[k] ^ totLine[k]);
                        if((line[k] & mask))   //make sure it has NOT flags's flag
                            line[k]-=mask;
                        if(line[k]>1)
                        {
                            if(DEBUG2) printf("square (col) allineation: n*%d,%d, =%d [cycler=%d]\n",k,j,line[k],cycleCounter);

                            columnWarnSquare(j,k,line[k]);
                        }
                    }
                }


                //LV4
                for(i=1; i<n2-1 && chkEnabled[LV4]; i++)
                    if(m[i][j] & mask)   //if it's a flag
                    {
                        //find groups of cells with identical flags
                        k=1;
                        value=0;
                        for(l=i+1; l<n2; l++){
                            if(m[l][j] & mask)   //if it's a flag
                                if(areEquals(m[l][j],m[i][j]))
                                    k++;
                        }
                        if(k==countValues(i,j)){
                            //i found a group of identical flags,
                            //now i can semplify them from the cells that are not in the group
                            value=m[i][j];

                            for(l=0; l<n2; l++)
                            {
                                if(m[l][j] & mask)   //if it's a flag
                                    if(areEquals(value,m[l][j])==0){
                                        square=(i/n)*n + (l/n);   //position of this square in array q
                                        m[l][j]=( (m[i][j] ^ m[l][j]) & m[l][j] ) | mask;
                                    }
                            }
                        }
                    }
            }

            if(finished==n2)
                fin=fin | (1<<j);   //set the flag for this column as completed
        }

    free(line);
    free(totLine);
    return fin;
}