首页 > 代码库 > 书中一段代码的注释

书中一段代码的注释

取自《Focus On 3D Terrain Programming》中的一段:
//--------------------------------------------------------------// Name:              CTERRAIN::FilterHeightBand - private// Description:       Apply the erosion filter to an individual//                          band of height values// Arguments:       -fpBand: the band to be filtered//                         -iStride: how far to advance per pass//                         -iCount: Number of passes to make//                         -fFilter: the filter strength// Return Value:     None//--------------------------------------------------------------void CTERRAIN::FilterHeightBand(float* fpBand, int iStride, int iCount, float fFilter ){  float v= fpBand[0];  int j  = iStride;  int i;  //go through(遍历) the height band and apply the erosion filter  for( i=0; i<iCount-1; i++ )  {    fpBand[j]= fFilter*v + ( 1-fFilter )*fpBand[j];       v = fpBand[j];    j+= iStride;  }}
滤波的一段代码,其中iStride就是步长,fFilter就是系数,为此,可以把函数参数名改为以下名称似乎更能说明函数功能:
void FilterHeightBand(float* fpBand,int iStep,int iCount,float fFilterFactor)

书中一段代码的注释