src/util/SunPosition.js
function (date) {
                if (date instanceof Date === false) {
                    throw new ArgumentError(
                        Logger.logMessage(Logger.LEVEL_SEVERE, "SunPosition", "getAsCelestialLocation",
                            "missingDate"));
                }

                var julianDate = this.computeJulianDate(date);

                //number of days (positive or negative) since Greenwich noon, Terrestrial Time, on 1 January 2000 (J2000.0)
                var numDays = julianDate - 2451545;

                var meanLongitude = WWMath.normalizeAngle360(280.460 + 0.9856474 * numDays);

                var meanAnomaly = WWMath.normalizeAngle360(357.528 + 0.9856003 * numDays) * Angle.DEGREES_TO_RADIANS;

                var eclipticLongitude = meanLongitude + 1.915 * Math.sin(meanAnomaly) + 0.02 * Math.sin(2 * meanAnomaly);
                var eclipticLongitudeRad = eclipticLongitude * Angle.DEGREES_TO_RADIANS;

                var obliquityOfTheEcliptic = (23.439 - 0.0000004 * numDays) * Angle.DEGREES_TO_RADIANS;

                var declination = Math.asin(Math.sin(obliquityOfTheEcliptic) * Math.sin(eclipticLongitudeRad)) *
                    Angle.RADIANS_TO_DEGREES;

                var rightAscension = Math.atan(Math.cos(obliquityOfTheEcliptic) * Math.tan(eclipticLongitudeRad)) *
                    Angle.RADIANS_TO_DEGREES;

                //compensate for atan result
                if (eclipticLongitude >= 90 && eclipticLongitude < 270) {
                    rightAscension += 180;
                }
                rightAscension = WWMath.normalizeAngle360(rightAscension);

                return {
                    declination: declination,
                    rightAscension: rightAscension
                };
            }
function (date) {
                if (date instanceof Date === false) {
                    throw new ArgumentError(
                        Logger.logMessage(Logger.LEVEL_SEVERE, "SunPosition", "getAsCelestialLocation",
                            "missingDate"));
                }

                var julianDate = this.computeJulianDate(date);

                //number of days (positive or negative) since Greenwich noon, Terrestrial Time, on 1 January 2000 (J2000.0)
                var numDays = julianDate - 2451545;

                var meanLongitude = WWMath.normalizeAngle360(280.460 + 0.9856474 * numDays);

                var meanAnomaly = WWMath.normalizeAngle360(357.528 + 0.9856003 * numDays) * Angle.DEGREES_TO_RADIANS;

                var eclipticLongitude = meanLongitude + 1.915 * Math.sin(meanAnomaly) + 0.02 * Math.sin(2 * meanAnomaly);
                var eclipticLongitudeRad = eclipticLongitude * Angle.DEGREES_TO_RADIANS;

                var obliquityOfTheEcliptic = (23.439 - 0.0000004 * numDays) * Angle.DEGREES_TO_RADIANS;

                var declination = Math.asin(Math.sin(obliquityOfTheEcliptic) * Math.sin(eclipticLongitudeRad)) *
                    Angle.RADIANS_TO_DEGREES;

                var rightAscension = Math.atan(Math.cos(obliquityOfTheEcliptic) * Math.tan(eclipticLongitudeRad)) *
                    Angle.RADIANS_TO_DEGREES;

                //compensate for atan result
                if (eclipticLongitude >= 90 && eclipticLongitude < 270) {
                    rightAscension += 180;
                }
                rightAscension = WWMath.normalizeAngle360(rightAscension);

                return {
                    declination: declination,
                    rightAscension: rightAscension
                };
            }
function ( date ) { if ( date instanceof Date === false ) { throw new ArgumentError ( Logger . logMessage ( Logger . LEVEL_SEVERE , "SunPosition" , "getAsCelestialLocation" , "missingDate" ) ) ; } var julianDate = this . computeJulianDate ( date ) ; //number of days (positive or negative) since Greenwich noon, Terrestrial Time, on 1 January 2000 (J2000.0) var numDays = julianDate - 2451545 ; var meanLongitude = WWMath . normalizeAngle360 ( 280.460 + 0.9856474 * numDays ) ; var meanAnomaly = WWMath . normalizeAngle360 ( 357.528 + 0.9856003 * numDays ) * Angle . DEGREES_TO_RADIANS ; var eclipticLongitude = meanLongitude + 1.915 * Math . sin ( meanAnomaly ) + 0.02 * Math . sin ( 2 * meanAnomaly ) ; var eclipticLongitudeRad = eclipticLongitude * Angle . DEGREES_TO_RADIANS ; var obliquityOfTheEcliptic = ( 23.439 - 0.0000004 * numDays ) * Angle . DEGREES_TO_RADIANS ; var declination = Math . asin ( Math . sin ( obliquityOfTheEcliptic ) * Math . sin ( eclipticLongitudeRad ) ) * Angle . RADIANS_TO_DEGREES ; var rightAscension = Math . atan ( Math . cos ( obliquityOfTheEcliptic ) * Math . tan ( eclipticLongitudeRad ) ) * Angle . RADIANS_TO_DEGREES ; //compensate for atan result if ( eclipticLongitude >= 90 && eclipticLongitude < 270 ) { rightAscension += 180 ; } rightAscension = WWMath . normalizeAngle360 ( rightAscension ) ; return { declination : declination , rightAscension : rightAscension } ; }
Computes the celestial location of the sun for a given julianDate
@param {Date} date
@throws {ArgumentError} if the date is missing
@return {{declination: Number, rightAscension: Number}} the celestial location
Computes the celestial location of the sun for a given julianDate