galactic
Version:
Celestial coordinate conversions and utilities
43 lines (32 loc) • 1.44 kB
HTML
<html>
<head>
<script src="dist/galactic.js"></script>
<script>
var rad = function(deg) { return deg/180 * Math.PI; };
var deg = function(rad) { return rad*180 / Math.PI; };
// Create coordinate in equatorial coordinate system
var centuri = galactic({latitude: rad(-42.587), longitude: rad(239.488)});
// Observer (Toronto, now)
var observer = {latitude: rad(43.7001100), longitude: rad(-79.4163000), utc: Date.now()};
// Convert to horizontal given observer place/time
var horizontal = centuri.horizontal( observer );
// Where is it?
console.log('Alpha Centuri - Altitude: ' + deg(horizontal.altitude()) + ', Azimuth: ' + deg(horizontal.azimuth()));
</script>
<script>
var rad = function(deg) { return deg/180 * Math.PI; };
var deg = function(rad) { return rad*180 / Math.PI; };
// Create coordinate in equatorial coordinate system
// Calculate sun's mean longitude (approx)
var n = galactic.dates.unixDateToJulian(Date.now()) - galactic.dates.J2000
var meanLongitude = 280.46 + 0.9856474*n
var sun = galactic({longitude: rad(meanLongitude), latitude: 0});
// Observer (Toronto, now)
var observer = {latitude: rad(43.7001100), longitude: rad(-79.4163000), utc: Date.now()};
// Convert to horizontal given observer place/time
var horizontal = sun.horizontal( observer );
// Where is it?
console.log('Sun - Altitude: ' + deg(horizontal.altitude()) + ', Azimuth: ' + deg(horizontal.azimuth()));
</script>
</head>
</html>