protected float weight ( float distance ) { float findex = distance * 100f ; int index = ( int ) findex ; if ( index >= 99 ) return weightTable [ 99 ] ; float sample0 = weightTable [ index ] ; float sample1 = weightTable [ index + 1 ] ; float w = findex - index ; return sample0 * ( 1f - w ) + sample1 * w ; }
Returns the weight given the normalized distance . Instead of computing the kernel distance every time a lookup table with linear interpolation is used . The distance has a domain from 0 to 1 inclusive