public static void ApplyBias( [NotNull] float[,] data, float c00, float c01, float c10, float c11, float midpoint )
{
if ( data == null )
throw new ArgumentNullException( "data" );
float maxX = 2f / data.GetLength( 0 );
float maxY = 2f / data.GetLength( 1 );
int offsetX = data.GetLength( 0 ) / 2;
int offsetY = data.GetLength( 1 ) / 2;
for ( int x = offsetX - 1; x >= 0; x-- ) {
for ( int y = offsetY - 1; y >= 0; y-- ) {
data[x, y] += InterpolateCosine( c00, ( c00 + c01 ) / 2, ( c00 + c10 ) / 2, midpoint, x * maxX, y * maxY );
data[x + offsetX, y] += InterpolateCosine( ( c00 + c10 ) / 2, midpoint, c10, ( c11 + c10 ) / 2, x * maxX, y * maxY );
data[x, y + offsetY] += InterpolateCosine( ( c00 + c01 ) / 2, c01, midpoint, ( c01 + c11 ) / 2, x * maxX, y * maxY );
data[x + offsetX, y + offsetY] += InterpolateCosine( midpoint, ( c01 + c11 ) / 2, ( c11 + c10 ) / 2, c11, x * maxX, y * maxY );
}
}
}