Skip to content

Instantly share code, notes, and snippets.

@lizard-isana
Created May 14, 2012 23:46
Show Gist options
  • Save lizard-isana/2698126 to your computer and use it in GitHub Desktop.
Save lizard-isana/2698126 to your computer and use it in GitHub Desktop.
How to calc the position of satellites with Orb.js
// orb.js tips 2012.04.19
// How to calc the position of satellites
// https://github.com/lizard-isana/orb.js
// You should include core.js and satellite.js in your script.
// https://github.com/lizard-isana/orb.js/blob/master/core.js
// https://github.com/lizard-isana/orb.js/blob/master/satellite.js
// Define your TLE.
var tle = {
"first_line": "1 25544U 98067A   11318.51274148  .00016717  00000-0  10270-3 0  9003",
"second_line": "2 25544  51.6365 124.1685 0021724  56.2169 304.1052 15.60123650 24381"
}
// Initialize Orb.Satellite object with the TLE.
var satellite = new Orb.Satellite(tle);
// Initialize Orb.Time object with a Date object.
var date = new Date();
var time = new Orb.Time(date);
//Now you can calculate the position.
//geographic coordinates:
var geo = satellite.position.geographic(time);
// return value
geo = {
longitude:[number in degree],
latitude:[number in degree],
altitude[number in km]
}
//rectangular coordinates:
var rect = satellite.position.rectangular(time);
// return value
rect = {
x:[number in km],
y:[number in km],
z:[number in km]
}
// You can reuse the Orb.Satellite object with newer dates.
var date2 = new Date();
var time2 = new Orb.Time(date2);
var geo2 = satellite.position.geographic(time2);
// Have fun!
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment