private void calchillshade ( WritableRaster pitWR , WritableRaster hillshadeWR , WritableRaster gradientWR , double dx ) { pAzimuth = Math . toRadians ( pAzimuth ) ; pElev = Math . toRadians ( pElev ) ; double [ ] sunVector = calcSunVector ( ) ; double [ ] normalSunVector = calcNormalSunVector ( sunVector ) ; double [ ] inverseSunVector = calcInverseSunVector ( sunVector ) ; int rows = pitWR . getHeight ( ) ; int cols = pitWR . getWidth ( ) ; WritableRaster sOmbraWR = calculateFactor ( rows , cols , sunVector , inverseSunVector , normalSunVector , pitWR , dx ) ; pm . beginTask ( msg . message ( "hillshade.calculating" ) , rows * cols ) ; for ( int j = 1 ; j < rows - 1 ; j ++ ) { for ( int i = 1 ; i < cols - 1 ; i ++ ) { double [ ] ng = gradientWR . getPixel ( i , j , new double [ 3 ] ) ; double cosinc = scalarProduct ( sunVector , ng ) ; if ( cosinc < 0 ) { sOmbraWR . setSample ( i , j , 0 , 0 ) ; } hillshadeWR . setSample ( i , j , 0 , ( int ) ( 212.5 * ( cosinc * sOmbraWR . getSample ( i , j , 0 ) + pMinDiffuse ) ) ) ; pm . worked ( 1 ) ; } } pm . done ( ) ; }
Evaluate the hillshade .