public static int PhiDiff_index( double _PhiDiff, out double _Interpolant )
{
// Because of reciprocity, the BRDF is unchanged under
// _PhiDiff -> _PhiDiff + PI
if ( _PhiDiff < 0.0 )
_PhiDiff += Math.PI;
// In: _PhiDiff in [0 .. PI]
// Out: tmp in [0 .. 179]
double fIndex = 2*_PhiDiff / Math.PI * BRDF_SAMPLING_RES_PHI_D;
int Index = (int) Math.Floor( fIndex );
_Interpolant = fIndex - Index;
Index = Math.Max( 0, Math.Min( Index, BRDF_SAMPLING_RES_PHI_D/2-1 ) );
return Index;
}