2
* @author Patrick Schmiedel patrick.schmiedel@gmx.net
6
* @classDescription This class represents an image of the sun at a
7
* specific date and its characteristics.
9
var SunImage = new Class.create();
11
SunImage.prototype = {
22
// The radius of the sun relative to the complete image
29
* @param {Hash} options Available options: tileDir, tileSize, spacecraft, instrument, wavelength, resolution, maxZoomLevel, sunRadius, sunCenter, zoomLevelOffset, date
31
initialize: function(options) {
32
this.sunCenter = { x: 0.5, y: 0.5 };
33
this.date = new SunImgDate();
35
Object.extend(this, this.defaultOptions);
36
Object.extend(this, options);
41
* @classDescription Represents a date an image of the sun has been taken on.
43
SunImgDate = Class.create();
45
SunImgDate.prototype = {
57
* @param {Hash} options Available options: year, month, day, hour, min, sec
59
initialize: function(options) {
60
Object.extend(this, this.defaultOptions);
61
Object.extend(this, options);
65
* @method secsSinceMidnight Returns the number of seconds since 0:00.
66
* @return {Number} The number of seconds since 0:00.
68
secsSinceMidnight: function() {
69
Debug.output("secssincemidnight si");
70
return String.parseInt(this.hour) * 3600 + String.parseInt(this.min) * 60 + String.parseInt(this.sec);
74
* @method timeStr Returns the time of the image in a H:M:S format.
75
* @return {String} The time as a string.
78
return this.hour + ':' + this.min + ':' + this.sec;
82
* TODO: Change name to be more correct (e.g. getAngle or so).
83
* @method getObliquity Returns the angle of the earth towards the solar plane at this date.
84
* @return {Number} The angle at this date.
86
getObliquity: function() {
87
Debug.output("getob si");
88
var OBLIQUITY_DEGREES = (7.25).toRad();
89
var MILLISECONDS_PER_YEAR = 31536000000;
90
// Day the earth is at 0 degree to the sun (June 7th). Let's forget about leap years and higher-than-24-hours-precision for now.
91
var d0UnixTime = Date.UTC(this.year, 6, 7);
92
var dUnixTime = Date.UTC(this.year, this.month, this.day);
93
return OBLIQUITY_DEGREES * Math.sin( (dUnixTime - d0UnixTime) / MILLISECONDS_PER_YEAR * 2 * Math.PI );
97
* @method getRotationDeltaLongitude Returns the longitudal delta to the 0:00 value of a location
98
* on the surface of the sun due to rotation, which depends on the
100
* @param {Number} latitude The latitude of the location on the sun.
101
* @return {Number} The longitudal delta.
103
getRotationDeltaLongitude: function(latitude) {
104
Debug.output("getrotationdelta");
105
return ((this.secsSinceMidnight() / 86400) * (14.44 - 3 * Math.pow(Math.sin(latitude), 2))).toRad();