/** * This method calculates the color of the sunlight for the current time and the given latitude. This method is * taken from deegree2, the values are undocumented. * * @param latitude * * @return a the color of the sunlight for the given latitude. */ public float[] calculateSunlight( double latitude ) { double vDir = getVerticalSunposition( latitude ); // rb: 7.25 is? float c = 7.25f * ( (float) Math.sin( vDir ) ); float[] color = new float[3]; color[0] = min( 1, ( ( BASE_LIGHT_INTENSITY + ( c / 16f ) + 0.05f ) * 0.6f ) ); color[1] = min( 1, ( ( BASE_LIGHT_INTENSITY + ( c / 18.5f ) + 0.05f ) * 0.6f ) ); color[2] = min( 1, ( ( BASE_LIGHT_INTENSITY + ( c / 17f ) + 0.05f ) * 0.55f ) ); return color; }
/** * Get the euclidean position of the sun. * * @param latitude * @return the euclidean position of the sun. */ public float[] getEucledianPosition( double latitude ) { double vPos = getVerticalSunposition( latitude ); double hPos = getHorizontalSunPosition(); return new float[] { (float) Math.sin( hPos ), (float) Math.sin( vPos ), (float) -Math.abs( Math.cos( hPos ) ) }; }