double noise(double x,double y) { double floorx=(double)((int)x);//This is a cheap way to floor a double integer. double floory=(double)((int)y); double s,t,u,v;//Integer declaration s=findnoise2(floorx,floory); t=findnoise2(floorx+1,floory); u=findnoise2(floorx,floory+1);//Get the surrounding pixels to calculate the transition. v=findnoise2(floorx+1,floory+1); 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. return interpolate(int1,int2,y-floory);//Here we use y-floory, to get the 2nd dimension. }
double ProceduralTexture::noise2(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 s=findnoise2(floorx,floory); t=findnoise2(floorx+1,floory); u=findnoise2(floorx,floory+1);//Get the surrounding pixels to calculate the transition. v=findnoise2(floorx+1,floory+1); double int1=interpolate1(s,t,x-floorx);//Interpolate between the values. double int2=interpolate1(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 interpolate1(int1,int2,y-floory);//Here we use y-floory, to get the 2nd dimension. }