ootk 6.0.2 → 6.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/dist/main.cjs +32 -17
  2. package/dist/main.js +32 -17
  3. package/package.json +1 -1
package/dist/main.cjs CHANGED
@@ -9849,7 +9849,7 @@ var FormatTle = class _FormatTle {
9849
9849
  const { inc, meanmo, rasc, argPe, meana, ecen, epochyr, epochday, intl } = tleParams;
9850
9850
  const scc = Tle.convert6DigitToA5(tleParams.scc);
9851
9851
  const epochYrStr = String(epochyr).padStart(2, "0");
9852
- const epochdayStr = parseFloat(String(epochday)).toFixed(8).padStart(12, "0");
9852
+ const epochdayStr = Number(epochday).toFixed(8).padStart(12, "0");
9853
9853
  const incStr = _FormatTle.inclination(inc);
9854
9854
  const meanmoStr = _FormatTle.meanMotion(meanmo);
9855
9855
  const rascStr = _FormatTle.rightAscension(rasc);
@@ -9870,9 +9870,6 @@ var FormatTle = class _FormatTle {
9870
9870
  const bstarStr = _FormatTle.formatTleExponential(tleParams.bstar ?? 0);
9871
9871
  TLE1Ending = ` ${mmDot} ${mmDdot} ${bstarStr} ${ephemerisType} ${elementSetNo}0`;
9872
9872
  }
9873
- TLE1Ending = TLE1Ending[1] === " " ? _FormatTle.setCharAt(TLE1Ending, 1, "+") : TLE1Ending;
9874
- TLE1Ending = TLE1Ending[12] === " " ? _FormatTle.setCharAt(TLE1Ending, 12, "+") : TLE1Ending;
9875
- TLE1Ending = TLE1Ending[21] === " " ? _FormatTle.setCharAt(TLE1Ending, 21, "+") : TLE1Ending;
9876
9873
  const tle1Pre = `1 ${scc}${classification} ${intlStr} ${epochYrStr}${epochdayStr}${TLE1Ending}`;
9877
9874
  const tle1 = _FormatTle.setCharAt(tle1Pre, 68, _FormatTle.tleChecksum(tle1Pre).toString());
9878
9875
  const tle2Pre = `2 ${scc} ${incStr} ${rascStr} ${ecenStr} ${argPeStr} ${meanaStr} ${meanmoStr}${revAtEpoch}0`;
@@ -9890,7 +9887,7 @@ var FormatTle = class _FormatTle {
9890
9887
  argPe = argPe.toString();
9891
9888
  }
9892
9889
  const argPeNum = parseFloat(argPe).toFixed(4);
9893
- const argPe0 = argPeNum.padStart(8, "0");
9890
+ const argPe0 = argPeNum.padStart(8, " ");
9894
9891
  if (argPe0.length !== 8) {
9895
9892
  throw new ValidationError("Argument of perigee must be 8 characters", "argPe", argPe0);
9896
9893
  }
@@ -9904,7 +9901,10 @@ var FormatTle = class _FormatTle {
9904
9901
  */
9905
9902
  static eccentricity(ecen) {
9906
9903
  if (typeof ecen === "number") {
9907
- ecen = ecen.toFixed(7);
9904
+ const ecenStr = ecen.toString();
9905
+ const dotIdx = ecenStr.indexOf(".");
9906
+ const afterDot = dotIdx >= 0 ? ecenStr.substring(dotIdx + 1) : "";
9907
+ ecen = `0.${afterDot.substring(0, 7).padEnd(7, "0")}`;
9908
9908
  }
9909
9909
  let ecen0 = ecen.padEnd(9, "0");
9910
9910
  if (ecen0[1] === ".") {
@@ -9928,7 +9928,7 @@ var FormatTle = class _FormatTle {
9928
9928
  inc = inc.toString();
9929
9929
  }
9930
9930
  const incNum = parseFloat(inc).toFixed(4);
9931
- const inc0 = incNum.padStart(8, "0");
9931
+ const inc0 = incNum.padStart(8, " ");
9932
9932
  if (inc0.length !== 8) {
9933
9933
  throw new ValidationError("Inclination must be 8 characters", "inclination", inc0);
9934
9934
  }
@@ -9945,7 +9945,7 @@ var FormatTle = class _FormatTle {
9945
9945
  meana = meana.toString();
9946
9946
  }
9947
9947
  const meanaNum = parseFloat(meana).toFixed(4);
9948
- const meana0 = meanaNum.padStart(8, "0");
9948
+ const meana0 = meanaNum.padStart(8, " ");
9949
9949
  if (meana0.length !== 8) {
9950
9950
  throw new ValidationError("Mean anomaly must be 8 characters", "meanAnomaly", meana0);
9951
9951
  }
@@ -9986,7 +9986,7 @@ var FormatTle = class _FormatTle {
9986
9986
  rasc = rasc.toString();
9987
9987
  }
9988
9988
  const rascNum = parseFloat(rasc).toFixed(4);
9989
- const rasc0 = rascNum.padStart(8, "0");
9989
+ const rasc0 = rascNum.padStart(8, " ");
9990
9990
  if (rasc0.length !== 8) {
9991
9991
  throw new ValidationError("Right ascension must be 8 characters", "rightAscension", rasc0);
9992
9992
  }
@@ -10024,7 +10024,7 @@ var FormatTle = class _FormatTle {
10024
10024
  */
10025
10025
  static formatTleExponential(value) {
10026
10026
  if (value === 0) {
10027
- return " 00000-0";
10027
+ return " 00000+0";
10028
10028
  }
10029
10029
  const sign2 = value >= 0 ? " " : "-";
10030
10030
  const absVal = Math.abs(value);
@@ -13255,13 +13255,28 @@ var ClassicalElements = class _ClassicalElements {
13255
13255
  const h = pos.cross(vel);
13256
13256
  const i = Math.acos(clamp(h.z / h.magnitude(), -1, 1));
13257
13257
  const n = Vector3D.zAxis.cross(h);
13258
- let o = Math.acos(clamp(n.x / n.magnitude(), -1, 1));
13259
- if (n.y < 0) {
13260
- o = TAU - o;
13261
- }
13262
- let w = n.angle(eVec);
13263
- if (eVec.z < 0) {
13264
- w = TAU - w;
13258
+ const nMag = n.magnitude();
13259
+ let o;
13260
+ let w;
13261
+ if (nMag < 1e-12) {
13262
+ o = 0;
13263
+ if (e > 1e-12) {
13264
+ w = Math.atan2(eVec.y, eVec.x);
13265
+ if (w < 0) {
13266
+ w = w + TAU;
13267
+ }
13268
+ } else {
13269
+ w = 0;
13270
+ }
13271
+ } else {
13272
+ o = Math.acos(clamp(n.x / nMag, -1, 1));
13273
+ if (n.y < 0) {
13274
+ o = TAU - o;
13275
+ }
13276
+ w = n.angle(eVec);
13277
+ if (eVec.z < 0) {
13278
+ w = TAU - w;
13279
+ }
13265
13280
  }
13266
13281
  let v = eVec.angle(pos);
13267
13282
  if (pos.dot(vel) < 0) {
package/dist/main.js CHANGED
@@ -9847,7 +9847,7 @@ var FormatTle = class _FormatTle {
9847
9847
  const { inc, meanmo, rasc, argPe, meana, ecen, epochyr, epochday, intl } = tleParams;
9848
9848
  const scc = Tle.convert6DigitToA5(tleParams.scc);
9849
9849
  const epochYrStr = String(epochyr).padStart(2, "0");
9850
- const epochdayStr = parseFloat(String(epochday)).toFixed(8).padStart(12, "0");
9850
+ const epochdayStr = Number(epochday).toFixed(8).padStart(12, "0");
9851
9851
  const incStr = _FormatTle.inclination(inc);
9852
9852
  const meanmoStr = _FormatTle.meanMotion(meanmo);
9853
9853
  const rascStr = _FormatTle.rightAscension(rasc);
@@ -9868,9 +9868,6 @@ var FormatTle = class _FormatTle {
9868
9868
  const bstarStr = _FormatTle.formatTleExponential(tleParams.bstar ?? 0);
9869
9869
  TLE1Ending = ` ${mmDot} ${mmDdot} ${bstarStr} ${ephemerisType} ${elementSetNo}0`;
9870
9870
  }
9871
- TLE1Ending = TLE1Ending[1] === " " ? _FormatTle.setCharAt(TLE1Ending, 1, "+") : TLE1Ending;
9872
- TLE1Ending = TLE1Ending[12] === " " ? _FormatTle.setCharAt(TLE1Ending, 12, "+") : TLE1Ending;
9873
- TLE1Ending = TLE1Ending[21] === " " ? _FormatTle.setCharAt(TLE1Ending, 21, "+") : TLE1Ending;
9874
9871
  const tle1Pre = `1 ${scc}${classification} ${intlStr} ${epochYrStr}${epochdayStr}${TLE1Ending}`;
9875
9872
  const tle1 = _FormatTle.setCharAt(tle1Pre, 68, _FormatTle.tleChecksum(tle1Pre).toString());
9876
9873
  const tle2Pre = `2 ${scc} ${incStr} ${rascStr} ${ecenStr} ${argPeStr} ${meanaStr} ${meanmoStr}${revAtEpoch}0`;
@@ -9888,7 +9885,7 @@ var FormatTle = class _FormatTle {
9888
9885
  argPe = argPe.toString();
9889
9886
  }
9890
9887
  const argPeNum = parseFloat(argPe).toFixed(4);
9891
- const argPe0 = argPeNum.padStart(8, "0");
9888
+ const argPe0 = argPeNum.padStart(8, " ");
9892
9889
  if (argPe0.length !== 8) {
9893
9890
  throw new ValidationError("Argument of perigee must be 8 characters", "argPe", argPe0);
9894
9891
  }
@@ -9902,7 +9899,10 @@ var FormatTle = class _FormatTle {
9902
9899
  */
9903
9900
  static eccentricity(ecen) {
9904
9901
  if (typeof ecen === "number") {
9905
- ecen = ecen.toFixed(7);
9902
+ const ecenStr = ecen.toString();
9903
+ const dotIdx = ecenStr.indexOf(".");
9904
+ const afterDot = dotIdx >= 0 ? ecenStr.substring(dotIdx + 1) : "";
9905
+ ecen = `0.${afterDot.substring(0, 7).padEnd(7, "0")}`;
9906
9906
  }
9907
9907
  let ecen0 = ecen.padEnd(9, "0");
9908
9908
  if (ecen0[1] === ".") {
@@ -9926,7 +9926,7 @@ var FormatTle = class _FormatTle {
9926
9926
  inc = inc.toString();
9927
9927
  }
9928
9928
  const incNum = parseFloat(inc).toFixed(4);
9929
- const inc0 = incNum.padStart(8, "0");
9929
+ const inc0 = incNum.padStart(8, " ");
9930
9930
  if (inc0.length !== 8) {
9931
9931
  throw new ValidationError("Inclination must be 8 characters", "inclination", inc0);
9932
9932
  }
@@ -9943,7 +9943,7 @@ var FormatTle = class _FormatTle {
9943
9943
  meana = meana.toString();
9944
9944
  }
9945
9945
  const meanaNum = parseFloat(meana).toFixed(4);
9946
- const meana0 = meanaNum.padStart(8, "0");
9946
+ const meana0 = meanaNum.padStart(8, " ");
9947
9947
  if (meana0.length !== 8) {
9948
9948
  throw new ValidationError("Mean anomaly must be 8 characters", "meanAnomaly", meana0);
9949
9949
  }
@@ -9984,7 +9984,7 @@ var FormatTle = class _FormatTle {
9984
9984
  rasc = rasc.toString();
9985
9985
  }
9986
9986
  const rascNum = parseFloat(rasc).toFixed(4);
9987
- const rasc0 = rascNum.padStart(8, "0");
9987
+ const rasc0 = rascNum.padStart(8, " ");
9988
9988
  if (rasc0.length !== 8) {
9989
9989
  throw new ValidationError("Right ascension must be 8 characters", "rightAscension", rasc0);
9990
9990
  }
@@ -10022,7 +10022,7 @@ var FormatTle = class _FormatTle {
10022
10022
  */
10023
10023
  static formatTleExponential(value) {
10024
10024
  if (value === 0) {
10025
- return " 00000-0";
10025
+ return " 00000+0";
10026
10026
  }
10027
10027
  const sign2 = value >= 0 ? " " : "-";
10028
10028
  const absVal = Math.abs(value);
@@ -13253,13 +13253,28 @@ var ClassicalElements = class _ClassicalElements {
13253
13253
  const h = pos.cross(vel);
13254
13254
  const i = Math.acos(clamp(h.z / h.magnitude(), -1, 1));
13255
13255
  const n = Vector3D.zAxis.cross(h);
13256
- let o = Math.acos(clamp(n.x / n.magnitude(), -1, 1));
13257
- if (n.y < 0) {
13258
- o = TAU - o;
13259
- }
13260
- let w = n.angle(eVec);
13261
- if (eVec.z < 0) {
13262
- w = TAU - w;
13256
+ const nMag = n.magnitude();
13257
+ let o;
13258
+ let w;
13259
+ if (nMag < 1e-12) {
13260
+ o = 0;
13261
+ if (e > 1e-12) {
13262
+ w = Math.atan2(eVec.y, eVec.x);
13263
+ if (w < 0) {
13264
+ w = w + TAU;
13265
+ }
13266
+ } else {
13267
+ w = 0;
13268
+ }
13269
+ } else {
13270
+ o = Math.acos(clamp(n.x / nMag, -1, 1));
13271
+ if (n.y < 0) {
13272
+ o = TAU - o;
13273
+ }
13274
+ w = n.angle(eVec);
13275
+ if (eVec.z < 0) {
13276
+ w = TAU - w;
13277
+ }
13263
13278
  }
13264
13279
  let v = eVec.angle(pos);
13265
13280
  if (pos.dot(vel) < 0) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ootk",
3
- "version": "6.0.2",
3
+ "version": "6.0.3",
4
4
  "type": "module",
5
5
  "description": "Orbital Object Toolkit including Multiple Propagators, Initial Orbit Determination, and Maneuver Calculations.",
6
6
  "exports": {