From 6e5ce7eb6da754bda830669e382e4dae1941690f Mon Sep 17 00:00:00 2001 From: Michael Date: Sun, 3 Feb 2019 16:23:30 +1100 Subject: [PATCH 1/7] Fix parentheses in sgp4init See the original Python implementation for reference: https://github.com/brandon-rhodes/python-sgp4/blob/a1e19/sgp4/propagation.py#L1391 --- src/propagation/sgp4init.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/propagation/sgp4init.js b/src/propagation/sgp4init.js index b0bbc7b..e8bced9 100644 --- a/src/propagation/sgp4init.js +++ b/src/propagation/sgp4init.js @@ -275,7 +275,7 @@ export default function sgp4init(satrec, options) { if (omeosq >= 0.0 || satrec.no >= 0.0) { satrec.isimp = 0; - if ((rp < 220.0 / earthRadius) + 1.0) { + if (rp < (220.0 / earthRadius + 1.0)) { satrec.isimp = 1; } sfour = ss; From d97e427ef640919d19dea77d8ae6afb8ae564775 Mon Sep 17 00:00:00 2001 From: Michael Date: Sun, 3 Feb 2019 16:27:18 +1100 Subject: [PATCH 2/7] Fix "operationmod" typo in sgp4 --- src/propagation/sgp4.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/propagation/sgp4.js b/src/propagation/sgp4.js index 3ef71c8..4fa4061 100644 --- a/src/propagation/sgp4.js +++ b/src/propagation/sgp4.js @@ -277,7 +277,7 @@ export default function sgp4(satrec, tsince) { nodep, argpp, mp, - opsmode: satrec.operationmod, + opsmode: satrec.operationmode, }; const dpperResult = dpper(satrec, dpperParameters); From 5753e39a9352503804f6c42ef9025add93d9c548 Mon Sep 17 00:00:00 2001 From: Dmitriy Pushkov Date: Tue, 12 Mar 2019 11:21:50 +0300 Subject: [PATCH 3/7] degreesToRadians function is used instead of deg2rad constant to convert degrees to radians in examples. --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 98560ec..7e7b3fd 100644 --- a/README.md +++ b/README.md @@ -156,8 +156,8 @@ var positionEci = positionAndVelocity.position, // Set the Observer at 122.03 West by 36.96 North, in RADIANS var observerGd = { - longitude: -122.0308 * deg2rad, - latitude: 36.9613422 * deg2rad, + longitude: satellite.degreesToRadians(-122.0308), + latitude: satellite.degreesToRadians(36.9613422), height: 0.370 }; From 9d04b6aa0052ac38e1de758a35d1e805c1ece6d7 Mon Sep 17 00:00:00 2001 From: Dmitriy Pushkov Date: Thu, 14 Mar 2019 10:50:47 +0300 Subject: [PATCH 4/7] vkmpersec is moved to constants. --- src/constants.js | 1 + src/propagation/sgp4.js | 3 +-- test/index.spec.js | 3 +++ 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/constants.js b/src/constants.js index 6a7bf1f..7bea0b8 100644 --- a/src/constants.js +++ b/src/constants.js @@ -6,6 +6,7 @@ export const minutesPerDay = 1440.0; export const mu = 398600.5; // in km3 / s2 export const earthRadius = 6378.137; // in km export const xke = 60.0 / Math.sqrt((earthRadius * earthRadius * earthRadius) / mu); +export const vkmpersec = (earthRadius * xke) / 60.0; export const tumin = 1.0 / xke; export const j2 = 0.00108262998905; export const j3 = -0.00000253215306; diff --git a/src/propagation/sgp4.js b/src/propagation/sgp4.js index 4fa4061..a77f270 100644 --- a/src/propagation/sgp4.js +++ b/src/propagation/sgp4.js @@ -3,6 +3,7 @@ import { twoPi, earthRadius, xke, + vkmpersec, j2, j3oj2, x2o3, @@ -135,8 +136,6 @@ export default function sgp4(satrec, tsince) { const temp4 = 1.5e-12; - const vkmpersec = (earthRadius * xke) / 60.0; - // --------------------- clear sgp4 error flag ----------------- satrec.t = tsince; satrec.error = 0; diff --git a/test/index.spec.js b/test/index.spec.js index 9b50e69..fc4135e 100644 --- a/test/index.spec.js +++ b/test/index.spec.js @@ -9,6 +9,7 @@ import { mu, earthRadius, xke, + vkmpersec, tumin, j2, j3, @@ -74,6 +75,7 @@ describe('Library export', () => { constantsEs.mu.should.equal(mu); constantsEs.earthRadius.should.equal(earthRadius); constantsEs.xke.should.equal(xke); + constantsEs.vkmpersec.should.equal(vkmpersec); constantsEs.tumin.should.equal(tumin); constantsEs.j2.should.equal(j2); constantsEs.j3.should.equal(j3); @@ -116,6 +118,7 @@ describe('Library export', () => { constants.mu.should.equal(mu); constants.earthRadius.should.equal(earthRadius); constants.xke.should.equal(xke); + constants.vkmpersec.should.equal(vkmpersec); constants.tumin.should.equal(tumin); constants.j2.should.equal(j2); constants.j3.should.equal(j3); From 75787378b004444877eeeb36631f07bae354447a Mon Sep 17 00:00:00 2001 From: Dmitriy Pushkov Date: Thu, 14 Mar 2019 11:03:40 +0300 Subject: [PATCH 5/7] Reduce unnecessary calculations in sgp4. --- src/propagation/sgp4.js | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/src/propagation/sgp4.js b/src/propagation/sgp4.js index a77f270..4ed64b7 100644 --- a/src/propagation/sgp4.js +++ b/src/propagation/sgp4.js @@ -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); @@ -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, From 382cb1f5f15ebdb5369c5ec88719e663e3c5eb89 Mon Sep 17 00:00:00 2001 From: Dmitriy Pushkov Date: Thu, 14 Mar 2019 11:11:53 +0300 Subject: [PATCH 6/7] Changelog is updated. --- CHANGELOG.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index b7204c0..429d224 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,10 @@ ## Changelog +- Unnecessary calculations in `sgp4` function are reduced (#47). +- `vkmpersec` calculation is moved to constants (#50). +- `degreesToRadians` function is used in docs instead of `deg2rad` constant (#53). +- Typos' fixes (#54). + ### 3.0.0 (2018-11-26) - Node.js 4 support is dropped (breaking change). From 708d8dbb3a1dde28843e7aa89bf6d639e7b8c8c2 Mon Sep 17 00:00:00 2001 From: Dmitriy Pushkov Date: Thu, 14 Mar 2019 11:12:29 +0300 Subject: [PATCH 7/7] Version bump. --- CHANGELOG.md | 2 ++ package.json | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 429d224..fa721fd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,7 @@ ## Changelog +### 3.0.1 (2019-03-14) + - Unnecessary calculations in `sgp4` function are reduced (#47). - `vkmpersec` calculation is moved to constants (#50). - `degreesToRadians` function is used in docs instead of `deg2rad` constant (#53). diff --git a/package.json b/package.json index 03a41c9..c2bd6ff 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "satellite.js", - "version": "3.0.0", + "version": "3.0.1", "description": "SGP4/SDP4 calculation library", "main": "lib/index.js", "jsnext:main": "dist/satellite.es.js",