Skip to content

Instantly share code, notes, and snippets.

@lizard-isana
Last active August 29, 2015 14:13
Show Gist options
  • Save lizard-isana/83dbe9e5fc230c4fc389 to your computer and use it in GitHub Desktop.
Save lizard-isana/83dbe9e5fc230c4fc389 to your computer and use it in GitHub Desktop.
// Orb.js のご紹介
// https://github.com/lizard-isana/orb.js
// Orb.js は、Webサイトなどで手軽に天体の位置計算を行うことを目的としたJavaScriptライブラリです
// 5行で惑星の位置が取れたりします
var date = new Date();
var time = new Orb.Time(date);
var SS = new Orb.SolarSystem();
var mars = new SS.Mars();
var p1 = mars.position.ecliptic(time); // x, y, z
var p2 = mars.position.equatorial(time); // ra, dec, distance
// 小惑星なんかも簡単です
var asteroid = new SS.FromKeplarian({
"eccentricity":"0.08728849329001058",
"inclination":"6.812676631845272",
"longitude_of_ascending_node":"250.5660658100269",
"argument_of_periapsis":"95.63473165761138",
"time_of_periapsis":"2456918.756066796",
"semi_major_axis":"1.001911878091084"
});
var p3 = asteroid.position.ecliptic(time); // x, y, z
var p4 = asteroid.position.equatorial(time); // ra, dec, distance
// 人工衛星もこんな感じで
var tle = {
first_line:"1 25544U 98067A 15012.59173611 .00014829 00000-0 23845-3 0 7179",
second_line:"2 25544 051.6466 140.7335 0006107 243.2909 291.5211 15.53213268923827"
}
var satellite = new Orb.Satellite(tle);
var p5 = satellite.position.geographic(time); // latitude, longitude, altitude
var p6 = satellite.position.rectangular(time); // x, y, z
// 地平座標を出すならこう
var observer = {
"latitude":35.658,
"longitude":139.741,
"altitude":0
}
var obs1 = new Orb.Observation({"observer":observer,"target":mars});
var p7 = obs1.horizontal(time); // azimuth, elevation
// 人工衛星も同じです
var obs2 = new Orb.Observation({"observer":observer,"target":satellite});
var p8 = obs2.horizontal(time); // azimuth, elevation
// 赤道座標をそのまま投げても大丈夫
var obs3 = new Orb.Observation({
"observer":observer ,
"target":{"ra":0,"dec":0}
});
var p9 = obs3.horizontal(time); // azimuth, elevation
// な、ええやろこれ?(´・_・`)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment