Example #1
0
float CPerlinNoise::GetPoint(int x, int y) const
{
	float total = 0.0f;
	float amplitude = 1.0f;
	float frequency = m_fFrequency;

	// create octaves
	for(int i = 0; i < m_iOctaves; ++i)
	{
		// add octave value
		total += interpolate_noise((x + m_iRandom) * frequency,
			(y + m_iRandom) * frequency) * amplitude;

		// setup next octave
		frequency *= 2;
		amplitude *= m_fPersistance;
	}

	// resize total
	total = total * 0.5f + 0.5f;

	// crop total
	if(total < 0.0f) total = 0.0f;
	else if(total > 1.0f) total = 1.0f;

	// total
	return total;
}
Example #2
0
void set_quality(SPECTRUM *rms) {

  int i;

  if (rms == NULL || rms->data_format != TIGER_FORMAT) return;
  for (i=0; i< rms->npts; i++) {
    if (RD_spec(rms,i) == -1) {
      if (rms->quality == NULL)
        rms->quality = (long *)calloc(rms->npts,sizeof(long));
      rms->quality[i] = 1;
    }
  }
  interpolate_noise(rms);
}