Purpose: calculate the true anomaly of the sun *///* Arguments: *///* t : number of Julian centuries since J2000.0 *///* Return value: *///* sun's true anamoly in degrees *///***********************************************************************/ function calcSunTrueAnomaly(t) { var m = calcGeomMeanAnomalySun(t); var c = calcSunEqOfCenter(t); var v = m + c; return v; // in degrees }//***********************************************************************///* Name: calcSunRadVector *///* Type: Function *///* Purpose: calculate the distance to the sun in AU *///* Arguments: *///* t : number of Julian centuries since J2000.0 *///* Return value: *///* sun radius vector in AUs *///***********************************************************************/ function calcSunRadVector(t) { var v = calcSunTrueAnomaly(t); var e = calcEccentricityEarthOrbit(t); var R = (1.000001018 * (1 - e * e)) / (1 + e * Math.cos(degToRad(v))); return R; // in AUs }//***********************************************************************///* Name: calcSunApparentLong *///* Type: Function *///* Purpose: calculate the apparent longitude of the sun *///* Arguments: *///* t : number of Julian centuries since J2000.0 *///* Return value: *///* sun's apparent longitude in degrees *///***********************************************************************/ function calcSunApparentLong(t) { var o = calcSunTrueLong(t); var omega = 125.04 - 1934.136 * t; var lambda = o - 0.00569 - 0.00478 * Math.sin(degToRad(omega)); return lambda; // in degrees }//***********************************************************************///* Name: calcMeanObliquityOfEcliptic *///* Type: Function *///* Purpose: calculate the mean obliquity of the ecliptic *///* Arguments: *///* t : number of Julian centuries since J2000.0 *///* Return value: *///* mean obliquity in degrees *///***********************************************************************/ function calcMeanObliquityOfEcliptic(t) { var seconds = 21.448 - t*(46.8150 + t*(0.00059 - t*(0.001813))); var e0 = 23.0 + (26.0 + (seconds/60.0))/60.0; return e0; // in degrees }//***********************************************************************///* Name: calcObliquityCorrection *///* Type: Function *///* Purpose: calculate the corrected obliquity of the ecliptic *///* Arguments: *///* t : number of Julian centuries since J2000.0 *///* Return value: *///* corrected obliquity in degrees *///***********************************************************************/ function calcObliquityCorrection(t) { var e0 = calcMeanObliquityOfEcliptic(t); var omega = 125.04 - 1934.136 * t; var e = e0 + 0.00256 * Math.cos(degToRad(omega)); return e; // in degrees }//***********************************************************************///* Name: calcSunRtAscension *///* Type: Function *///* Purpose: calculate the right ascension of the sun *///* Arguments: *///* t : number of Julian centuries since J2000.0 *///* Return value: *///* sun's right ascension in degrees *///***********************************************************************/ function calcSunRtAscension(t) { var e = calcObliquityCorrection(t); var lambda = calcSunApparentLong(t); var tananum = (Math.cos(degToRad(e)) * Math.sin(degToRad(lambda))); var tanadenom = (Math.cos(degToRad(lambda))); var alpha = radToDeg(Math.atan2(tananum, tanadenom)); return alpha; // in degrees }//***********************************************************************///* Name: calcSunDeclination *///* Type: Function *///* Purpose: calculate the declination of the sun *///* Arguments: *///* t : number of Julian centuries since J2000.0 *///* Return value: *///* sun's declination in degrees *///***********************************************************************/ function calcSunDeclination(t) { var e = calcObliquityCorrection(t); var lambda = calcSunApparentLong(t); var sint = Math.sin(degToRad(e)) * Math.sin(degToRad(lambda)); var theta = radToDeg(Math.asin(sint)); return theta; // in degrees }//***********************************************************************///* Name: calcEquationOfTime *///* Type: Function *///* Purpose: calculate the difference between true solar time and mean *///* solar time *///* Arguments: *///* t : number of Julian centuries since J2000.0 *///* Return value: *///* equation of time in minutes of time *///***********************************************************************/ function calcEquationOfTime(t) { var epsilon = calcObliquityCorrection(t); var l0 = calcGeomMeanLongSun(t); var e = calcEccentricityEarthOrbit(t); var m = calcGeomMeanAnomalySun(t); var y = Math.tan(degToRad(epsilon)/2.0); y *= y; var sin2l0 = Math.sin(2.0 * degToRad(l0));