Ejemplo n.º 1
double perlinNoise(double x,double y)
  double floorx=(double)((int)x);//This is kinda a cheap way to floor a double integer.
  double floory=(double)((int)y);
  double s,t,u,v;//Integer declaration
  u=findnoise(floorx,floory+1);//Get the surrounding pixels to calculate the transition.
  double int1=interpolate(s,t,x-floorx);//Interpolate between the values.
  double int2=interpolate(u,v,x-floorx);//Here we use x-floorx, to get 1st dimension. Don't mind the x-floorx thingie, it's part of the cosine formula.
  return interpolate(int1,int2,y-floory);//Here we use y-floory, to get the 2nd dimension.
Ejemplo n.º 2
double PerlinNoise::noise(const double x, const double y, const int z)
	double floorx=(double)((int)x);
	double floory=(double)((int)y);
	double s,t,u,v;
	s=findnoise(floorx, floory, z); 
	t=findnoise(floorx+1, floory, z);
	u=findnoise(floorx, floory+1, z);
	v=findnoise(floorx+1, floory+1, z);
	double int1=interpolate(s, t, x-floorx);
	double int2=interpolate(u, v, x-floorx);
	return interpolate(int1, int2, y-floory);