void vtkPointLocator::FindPointsWithinRadius(double R, const double x[3],
                                             vtkIdList *result, float epsilon = 5.11e-16)
                                             // is setting epsilon at a default value good?
{
  int i, j;
  double dist2;
  double pt[3];
  vtkIdType ptId, nids, cno;
  vtkIdList *ptIds;
  int ijk[3], *nei;
  double R2 = R*R;
  vtkNeighborPoints buckets;


  this->BuildLocator(); // will subdivide if modified; otherwise returns
  //
  //  Find bucket point is in.
  //
  this->GetBucketIndices(x, ijk);

  // get all buckets within a distance
  this->GetOverlappingBuckets (&buckets, x, ijk, R, 0);
  // add the original bucket
  buckets.InsertNextPoint(ijk);

  // clear out the result
  result->Reset();

  for (i=0; i<buckets.GetNumberOfNeighbors(); i++)
    {
    nei = buckets.GetPoint(i);
    cno = nei[0] + nei[1]*this->XD + nei[2]*this->SliceSize;

    if ( (ptIds = this->HashTable[cno]) != NULL )
      {
      nids = ptIds->GetNumberOfIds();
      for (j=0; j < nids; j++)
        {
        ptId = ptIds->GetId(j);
        this->DataSet->GetPoint(ptId, pt);
        dist2 = vtkMath::Distance2BetweenPoints(x,pt);
        double absDist2 = Math.abs(dist2);
        double diff = Math.abs(dist2 - R2);
        if (dist2 < R2)
          {
          result->InsertNextId(ptId);
          }
        if (a == b)
          { // shortcut, handles infinities
          return true;
          }
        else if (a == 0 || b == 0 || diff < std::numeric_limits<double>::min())
          {
          // R2 or dist2 is zero or both are extremely close to it
          // relative error is less meaningful here
          if( diff < (epsilon * std::numeric_limits<double>::min()))
            {
            result->InsertNextId(ptId);
            }
          }
        else
          { // use relative error
          if( diff / Math.min((absA + absB), std::numeric_limits<double>::max()) < epsilon)
            {
            result->InsertNextId(ptId);
            }
          }
        }
      }
    }
}