// -----------------------------------------------------------------------------
//
// -----------------------------------------------------------------------------
void ModifiedLambertProjection::createStereographicProjection(int dim, DoubleArrayType* stereoIntensity)
{
  int xpoints = dim;
  int ypoints = dim;

  int xpointshalf = xpoints / 2;
  int ypointshalf = ypoints / 2;

  float xres = 2.0 / (float)(xpoints);
  float yres = 2.0 / (float)(ypoints);
  float xtmp, ytmp;
  float sqCoord[2];
  float xyz[3];
  bool nhCheck = false;

  stereoIntensity->initializeWithZeros();
  double* intensity = stereoIntensity->GetPointer(0);


  for (int64_t y = 0; y < ypoints; y++)
  {
    for (int64_t x = 0; x < xpoints; x++)
    {
      //get (x,y) for stereographic projection pixel
      xtmp = float(x - xpointshalf) * xres + (xres * 0.5);
      ytmp = float(y - ypointshalf) * yres + (yres * 0.5);
      int index = y * xpoints + x;
      if((xtmp * xtmp + ytmp * ytmp) <= 1.0)
      {
        //project xy from stereo projection to the unit spehere
        xyz[2] = -((xtmp * xtmp + ytmp * ytmp) - 1) / ((xtmp * xtmp + ytmp * ytmp) + 1);
        xyz[0] = xtmp * (1 + xyz[2]);
        xyz[1] = ytmp * (1 + xyz[2]);


        for( int64_t m = 0; m < 2; m++)
        {
          if(m == 1) { MatrixMath::Multiply3x1withConstant(xyz, -1.0); }
          nhCheck = getSquareCoord(xyz, sqCoord);
          //sqIndex = getSquareIndex(sqCoord);
          if (nhCheck == true)
          {
            //get Value from North square
            intensity[index] += getInterpolatedValue(ModifiedLambertProjection::NorthSquare, sqCoord);
            //intensity[index] += getValue(ModifiedLambertProjection::NorthSquare, sqIndex);
          }
          else
          {
            //get Value from South square
            intensity[index] += getInterpolatedValue(ModifiedLambertProjection::SouthSquare, sqCoord);
            //intensity[index] += getValue(ModifiedLambertProjection::SouthSquare, sqIndex);
          }
        }
        intensity[index]  = intensity[index] * 0.5;
      }
    }
  }
}
std::vector<float> LinearTransferFunctionWidget::getInterpolatedValuesOverInterval(const unsigned int &numValues)
{
  std::vector<float> yValues;

  for(unsigned int i=0; i<numValues; i++)
    yValues.push_back(getInterpolatedValue(float(i) / float(numValues - 1)));

  return yValues;
}