Skip to content

Commit

Permalink
Longitude of eciToGeodetic result is in range [-PI; PI].
Browse files Browse the repository at this point in the history
  • Loading branch information
ezze committed Mar 1, 2018
1 parent 16aa139 commit f004150
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion src/transforms.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import {
pi,
twoPi,
rad2deg,
} from './constants';

Expand Down Expand Up @@ -52,7 +53,15 @@ export function eciToGeodetic(eciCoords, gmst) {
const R = Math.sqrt((eciCoords.x * eciCoords.x) + (eciCoords.y * eciCoords.y));
const f = (a - b) / a;
const e2 = ((2 * f) - (f * f));
const longitude = Math.atan2(eciCoords.y, eciCoords.x) - gmst;

let longitude = Math.atan2(eciCoords.y, eciCoords.x) - gmst;
while (longitude < -pi) {
longitude += twoPi;
}
while (longitude > pi) {
longitude -= twoPi;
}

const kmax = 20;
let k = 0;
let latitude = Math.atan2(
Expand Down

0 comments on commit f004150

Please sign in to comment.