BRDFSlices.DisplayForm.ComputeScaleFactor C# (CSharp) Method

ComputeScaleFactor() protected method

protected ComputeScaleFactor ( double _ThetaH, double _ThetaD, double _PhiD ) : double
_ThetaH double
_ThetaD double
_PhiD double
return double
        protected double ComputeScaleFactor( double _ThetaH, double _ThetaD, double _PhiD )
        {
            double	SlopeAngle = Math.Atan( Math.Max( 1e-10, _ThetaD ) / _ThetaH );	// This is one dimension of the table
            //			double	CosPhiD = Math.Cos( _PhiD );					// This is the other dimension

            double	U = INTERSECTIONS_TABLE_SIZE * SlopeAngle * 2.0 / Math.PI;
            int		U0 = (int) Math.Floor( U );
            double	u = U - U0;
                    U0 = Math.Min( INTERSECTIONS_TABLE_SIZE-1, U0 );
            int		U1 = Math.Min( INTERSECTIONS_TABLE_SIZE-1, U0+1 );

            //			double	V = INTERSECTIONS_TABLE_SIZE * CosPhiD;
            double	V = INTERSECTIONS_TABLE_SIZE * _PhiD * 2.0 / Math.PI;
            int		V0 = (int) Math.Floor( V );
            double	v = V - V0;
                    V0 = Math.Min( INTERSECTIONS_TABLE_SIZE-1, V0 );
            int		V1 = Math.Min( INTERSECTIONS_TABLE_SIZE-1, V0+1 );

            double	I00 = m_Intersections[U0,V0];
            double	I01 = m_Intersections[U1,V0];
            double	I10 = m_Intersections[U0,V1];
            double	I11 = m_Intersections[U1,V1];

            double	I0 = (1.0-u) * I00 + u * I01;
            double	I1 = (1.0-u) * I10 + u * I11;

            double	I = (1.0-v) * I0 + v * I1;
            return I;
        }