BRDFSlices.DisplayForm.ThetaHalf_index C# (CSharp) Method

ThetaHalf_index() public static method

public static ThetaHalf_index ( double _ThetaHalf, double &_Interpolant ) : int
_ThetaHalf double
_Interpolant double
return int
        public static int ThetaHalf_index( double _ThetaHalf, out double _Interpolant )
        {
            if ( _ThetaHalf <= 0.0 )
            {
                _Interpolant = 0.0;
                return 0;
            }

            double	ThetaHalf_deg = ((_ThetaHalf / (0.5*Math.PI)) * BRDF_SAMPLING_RES_THETA_H);
            double	fIndex = ThetaHalf_deg*BRDF_SAMPLING_RES_THETA_H;
                    fIndex = Math.Sqrt( fIndex );

            int Index = (int) Math.Floor( fIndex );
            _Interpolant = fIndex - Index;	// This is wrong but I suppose it won't be noticeable! (the interpolant should increase with sqrt as well)
                Index = Math.Max( 0, Math.Min( Index, BRDF_SAMPLING_RES_THETA_H-1 ) );
            return Index;
        }