Skip to content

Commit

Permalink
Reduce unnecessary calculations in sgp4.
Browse files Browse the repository at this point in the history
  • Loading branch information
ezze committed Mar 14, 2019
1 parent 9d04b6a commit 7578737
Showing 1 changed file with 11 additions and 10 deletions.
21 changes: 11 additions & 10 deletions src/propagation/sgp4.js
Original file line number Diff line number Diff line change
Expand Up @@ -382,6 +382,17 @@ export default function sgp4(satrec, tsince) {

const mrt = (rl * (1.0 - (1.5 * temp2 * betal * satrec.con41)))
+ (0.5 * temp1 * satrec.x1mth2 * cos2u);

// sgp4fix for decaying satellites
if (mrt < 1.0) {
// printf("// decay condition %11.6f \n",mrt);
satrec.error = 6;
return {
position: false,
velocity: false,
};
}

su -= 0.25 * temp2 * satrec.x7thm1 * sin2u;
const xnode = nodep + (1.5 * temp2 * cosip * sin2u);
const xinc = xincp + (1.5 * temp2 * cosip * sinip * cos2u);
Expand Down Expand Up @@ -416,16 +427,6 @@ export default function sgp4(satrec, tsince) {
z: ((mvt * uz) + (rvdot * vz)) * vkmpersec,
};

// sgp4fix for decaying satellites
if (mrt < 1.0) {
// printf("// decay condition %11.6f \n",mrt);
satrec.error = 6;
return {
position: false,
velocity: false,
};
}

return {
position: r,
velocity: v,
Expand Down

0 comments on commit 7578737

Please sign in to comment.