Astronomical Calculations
Prague Astronomical Clock
Solar System Calculator - by Don Cross
");
doc.close(); // otherwise browser will keep spinning like the document is still loading
} else {
alert ("Error creating new browser window.");
}
} else {
alert ("No celestial body is selected.");
}
}
function OnRadioButton_Cartesian (id)
{
switch (id) {
case "rb_Cartesian_Heliocentric":
CartesianCoordinateType = "heliocentric";
break;
case "rb_Cartesian_Geocentric":
CartesianCoordinateType = "geocentric";
break;
case "rb_Cartesian_None":
CartesianCoordinateType = "none";
break;
default:
throw ("Internal error - unknown radio button '" + id + "'");
break;
}
WriteCookie ("CartesianCoordinateType", id.substring("rb_Cartesian_".length), COOKIE_EXPIRATION_DAYS);
CalculateSolarSystem();
}
function OnRadioButton_Angular (id)
{
var toolTip1 = null;
var toolTip2 = null;
var header1 = null;
var header2 = null;
switch (id) {
case "rb_Angular_Ecliptic":
AngularCoordinateType = "ecliptic";
toolTip1 = "Ecliptic longitude.";
toolTip2 = "Ecliptic latitude.";
header1 = '
Ecl. Long. ';
header2 = '
Ecl. Lat. ';
break;
case "rb_Angular_Equatorial":
AngularCoordinateType = "equatorial";
toolTip1 = "Right Ascension in sidereal hours.";
toolTip2 = "Declination in angular degrees.";
header1 = '
RA ';
header2 = '
DEC ';
break;
case "rb_Angular_Horizontal":
AngularCoordinateType = "horizontal";
toolTip1 = "Compass direction clockwise from North.";
toolTip2 = "Angle above the horizon.";
header1 = '
Azimuth ';
header2 = '
Altitude ';
break;
default:
throw ("Internal error - unknown radio button '" + id + "'");
}
$('th_Angle1').title = toolTip1;
$('th_Angle2').title = toolTip2;
$('th_Angle1').innerHTML = header1;
$('th_Angle2').innerHTML = header2;
WriteCookie ("AngularCoordinateType", id.substring("rb_Angular_".length), COOKIE_EXPIRATION_DAYS);
CalculateSolarSystem();
}
function LoadOption_Cartesian()
{
var radioButtonId = "rb_Cartesian_" + ReadCookie ("CartesianCoordinateType", "Heliocentric");
switch (radioButtonId) {
case "rb_Cartesian_Heliocentric":
case "rb_Cartesian_Geocentric":
case "rb_Cartesian_None":
break; // cookie value is OK; leave it alone.
default:
radioButtonId = "rb_Cartesian_Heliocentric"; // force bad cookie value to be valid (avoid crashing)
break;
}
$(radioButtonId).checked = true;
OnRadioButton_Cartesian (radioButtonId);
}
function LoadOption_Angular()
{
var radioButtonId = "rb_Angular_" + ReadCookie ("AngularCoordinateType", "Equatorial");
switch (radioButtonId) {
case "rb_Angular_Equatorial":
case "rb_Angular_Horizontal":
case "rb_Angular_Ecliptic":
break; // cookie value is OK; leave it alone.
default:
radioButtonId = "rb_Angular_Equatorial"; // force bad cookie value to be valid (avoid crashing)
break;
}
$(radioButtonId).checked = true;
OnRadioButton_Angular (radioButtonId);
}
function LoadOption_AngleMode()
{
var angleDisplayMode = ReadCookie ("AngleDisplayMode", "dms");
switch (angleDisplayMode) {
case "dmm":
case "dms":
case "decimal":
break; // cookie value is OK; leave it alone.
default:
angleDisplayMode = "dms"; // force bad cookie value to be valid (avoid crashing)
break;
}
var radioButtonId = "rb_AngleMode_" + angleDisplayMode;
$(radioButtonId).checked = true;
SetAngleMode (angleDisplayMode);
}
function LoadOption_RealTime()
{
// Load realtime check box state.
var realTimeEnabled = (ReadCookie ("RealTimeMode", "true") == "true");
// If realtime check box is unchecked, load saved date/time.
if (!realTimeEnabled) {
AstroDateTime = LoadDateTime();
ReflectDateTime (AstroDateTime);
}
$('checkbox_RealTime').checked = realTimeEnabled;
OnCheckBoxRealTime();
}
function LoadOption_BrightObjectsOnly()
{
var brightOnly = (ReadCookie ("BrightObjectsOnly", "false") == "true");
$('checkbox_BrightObjectsOnly').checked = brightOnly;
}
function LoadOption_RisenObjectsOnly()
{
var risenOnly = (ReadCookie ("RisenObjectsOnly", "false") == "true");
$('checkbox_RisenObjectsOnly').checked = risenOnly;
}
function SelectObjectForExtraInfo (name)
{
var body = Astronomy[name];
if (body == null || body.Name == null || body.Name != name) {
throw "Internal error: invalid object selected: '" + name + "'";
} else {
WriteCookie ("SelectedCelestialBody", name, COOKIE_EXPIRATION_DAYS);
SelectedBody = { 'Body': body };
CalculateSolarSystem();
}
}
function LoadOption_SelectedObject()
{
var name = ReadCookie ("SelectedCelestialBody", "Sun");
if (!Astronomy.IsBodyName(name) || (name == "Earth")) {
name = "Sun";
}
var select = $('selectBody');
for (var i=0; i < select.options.length; ++i) {
if (select.options[i].value == name) {
select.selectedIndex = i;
SelectObjectForExtraInfo (name);
return;
}
}
alert ("LoadOption_SelectedObject(): could not find option for '" + name + "'");
}
function InitPage()
{
LoadOption_Cartesian();
LoadOption_Angular();
LoadOption_AngleMode();
LoadOption_RealTime();
LoadGeographicCoordinates();
LoadOption_SelectedObject();
LoadOption_BrightObjectsOnly();
LoadOption_RisenObjectsOnly();
OnVisibilityChange(); // do this AFTER loading all options that can affect the display
Timer(); // prime the pump for the self-perpetuating every-1-second timer event
}
Solar System Calculator - by Don Cross
See also: [
Astronomy Calendar
| Sky View
]
This is a demo page for my Javascript astronomy engine, astronomy.js .
The algorithms here are based on formulas mostly from Paul Schlyter's
web page
How to compute planetary positions .
I also used information from the following books:
I obtained orbital elements for the four major asteroids using the JPL Small-Body Database Browser:
1 Ceres ,
2 Pallas ,
3 Juno ,
4 Vesta .
The sky coordinates calculated here will generally be within 2 or 3 arcminutes of accuracy
(about one-tenth the apparent angular diameter of the moon), although results will be
worse for the asteroids (Ceres, Pallas, Vesta, and Juno) for years before 2005 or after 2015.
This is because I calculate asteroid orbits as perfect ellipses that closely approximate their behavior in 2010, but
I do not correct for how these orbits drift over time.
I intend to update this page every year or two to use the latest orbital elements for these asteroids,
so that calculations for nearby dates will always be reasonably accurate.
If you need really accurate data for a planet or asteroid, try the
JPL HORIZONS System .
(These guys were navigating spacecraft through the solar system when I was still playing with GI Joe!)
Other useful astronomy calculation resources: