/** * 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 ) ) }; }
/** * calculates the solar altitude for given latitude, year, month, date, hour and minute * * @param latitude * latitude of the the viewers position * @return the solar altitude in radians for the given latitude */ public double getVerticalSunposition( double latitude ) { // Hour Angle (H), // Solar Declination (D), // Latitude (L) // solar altitude (A). // sin(A) = sin(D)*sin(L) + cos(D)*cos(L)*cos(H) double rad23_5 = 0.41015237421866745057706; // double days = getDaySinceVernalEquinox( year, month, date ); double sinD = Math.sin( rad23_5 ) * Math.sin( Math.toRadians( daysSinceVernalEquinox * 360.0 / 365.0 ) ); double cosD = Math.cos( Math.asin( sinD ) ); // the sun hour angle is zero when the object is on the meridian double h = getHorizontalSunPosition() - Math.toRadians( 180 ); double radL = Math.toRadians( latitude ); double sinA = sinD * Math.sin( radL ) + cosD * Math.cos( radL ) * Math.cos( h ); return Math.asin( sinA ); }