BRDFSlices.DisplayForm.WarpSlice C# (CSharp) Method

WarpSlice() protected method

protected WarpSlice ( int _ThetaHIndex, int _ThetaDIndex, double _Warp, Vector3 &_Result ) : void
_ThetaHIndex int
_ThetaDIndex int
_Warp double
_Result Vector3
return void
        protected void WarpSlice( int _ThetaHIndex, int _ThetaDIndex, double _Warp, ref Vector3 _Result )
        {
            double	ThetaH = Math.PI * _ThetaHIndex / 180.0;
            double	ThetaD = Math.PI * _ThetaDIndex / 180.0;
            double	PhiD = Math.PI * _Warp / 180.0;
            if ( PhiD > 0.5 * Math.PI )
                PhiD = Math.PI - PhiD;

            double	Scale = ComputeScaleFactor( ThetaH, ThetaD, PhiD );

            double	ScaledThetaH = ThetaH / Scale;
            double	ScaledThetaD = ThetaD / Scale;

            // 			int		ScaledThetaHIndex = (int) Math.Min( 89, 89 * Math.Sqrt( 2.0 * ScaledThetaH / Math.PI ) );
            // 			int		ScaledThetaDIndex = (int) Math.Min( 89, 180 * ScaledThetaD / Math.PI );
            int		ScaledThetaHIndex = (int) (89 * Math.Sqrt( 2.0 * ScaledThetaH / Math.PI ));
            int		ScaledThetaDIndex = (int) (180 * ScaledThetaD / Math.PI);
            if ( ScaledThetaHIndex > 89 || ScaledThetaDIndex > 89 )
            {	// Out of range!
                _Result.Set( 0, 0, 0 );
                return;
            }

            _Result = m_BRDF[ScaledThetaHIndex,ScaledThetaDIndex,90];

            // int	U = _ThetaHIndex * INTERSECTIONS_TABLE_SIZE / 90;
            // int	V = _ThetaDIndex * INTERSECTIONS_TABLE_SIZE / 90;
            // double	C = m_Intersections[U,V];
            // _Result.Set( C, C, C );
        }