diff --git a/CHANGELOG.md b/CHANGELOG.md index 36de35d..939b026 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,10 +4,18 @@ All notable changes to this project will be documented in this file. Dates are d Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog). -#### [v1.0.0](https://github.com/thkruz/ootk-core/compare/v1.0.0-5...v1.0.0) +#### [v1.0.1](https://github.com/thkruz/ootk-core/compare/v1.0.0...v1.0.1) +- refactor: :label: add more typing for Seconds in Epoch calculations [`0419a86`](https://github.com/thkruz/ootk-core/commit/0419a86e4eaa8e29f2281bbee3b3b01f559ec7f4) +- refactor: :label: improve type support in Vector3D [`e3d3e3a`](https://github.com/thkruz/ootk-core/commit/e3d3e3a1abcd3fcb2832b1cce4d0e40e41db2d35) + +### [v1.0.0](https://github.com/thkruz/ootk-core/compare/v1.0.0-5...v1.0.0) + +> 15 January 2024 + + - refactor: :recycle: standardize rng az el syntax [`59f7f53`](https://github.com/thkruz/ootk-core/commit/59f7f53c497d75bda2bf049c20e67d5191d586d7) - build: :memo: add auto changelog [`8abc50c`](https://github.com/thkruz/ootk-core/commit/8abc50cd4eb4b437cbea0ccaad9df5853257c386) - docs: :memo: update examples [`f27b230`](https://github.com/thkruz/ootk-core/commit/f27b230dfa0fb7440a81859b4057ab8d21b97ed6) diff --git a/package-lock.json b/package-lock.json index 529b5bd..a0db7b0 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "ootk-core", - "version": "1.0.0", + "version": "1.0.1", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "ootk-core", - "version": "1.0.0", + "version": "1.0.1", "license": "MIT", "devDependencies": { "@babel/core": "^7.23.7", diff --git a/package.json b/package.json index 7a46538..4fea60c 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "ootk-core", - "version": "1.0.0", + "version": "1.0.1", "type": "module", "module": "dist/main.js", "description": "Orbital Object Toolkit. A modern typed replacement for satellite.js including SGP4 propagation, TLE parsing, Sun and Moon calculations, and more.", diff --git a/src/body/Sun.ts b/src/body/Sun.ts index 0eb4ed9..2324b21 100644 --- a/src/body/Sun.ts +++ b/src/body/Sun.ts @@ -51,6 +51,7 @@ import { RAD2DEG, RaDec, Radians, + Seconds, SunTime, TAU, Vector3D, @@ -522,7 +523,7 @@ export class Sun { const distance = Sun.position(epoch).magnitude(); const dSec = distance / cKmPerSec; - return Sun.position(epoch.roll(-dSec)); + return Sun.position(epoch.roll(-dSec as Seconds)); } /** diff --git a/src/coordinate/Tle.ts b/src/coordinate/Tle.ts index 578fb76..ac45a7a 100644 --- a/src/coordinate/Tle.ts +++ b/src/coordinate/Tle.ts @@ -222,7 +222,7 @@ export class Tle { } const days = parseFloat(epochStr.substring(2, 14)) - 1; - return EpochUTC.fromDateTimeString(`${year}-01-01T00:00:00.000Z`).roll(days * secondsPerDay); + return EpochUTC.fromDateTimeString(`${year}-01-01T00:00:00.000Z`).roll(days * secondsPerDay as Seconds); } /** diff --git a/src/operations/Vector3D.ts b/src/operations/Vector3D.ts index 5431b2e..16fbe61 100644 --- a/src/operations/Vector3D.ts +++ b/src/operations/Vector3D.ts @@ -21,7 +21,7 @@ * SOFTWARE. */ -import { Kilometers, Radians, linearDistance } from '../main'; +import { Radians, linearDistance } from '../main'; import { Matrix } from './Matrix'; import { Vector } from './Vector'; @@ -125,13 +125,13 @@ export class Vector3D { } // / Return a copy of this [Vector3D] scaled by [n]; - scale(n: number): Vector3D { - return new Vector3D(this.x * n, this.y * n, this.z * n); + scale(n: number): Vector3D { + return new Vector3D(this.x * n as T, this.y * n as T, this.z * n as T); } // / Return a copy of this [Vector3D] with the elements negated. - negate(): Vector3D { - return this.scale(-1) as Vector3D; + negate(): Vector3D { + return this.scale(-1); } /** @@ -139,7 +139,7 @@ export class Vector3D { * @param v The other Vector3D. * @returns The distance between this and the other Vector3D. */ - distance(v: Vector3D): number { + distance(v: Vector3D): T { return linearDistance(this, v); } @@ -147,14 +147,14 @@ export class Vector3D { * Convert this to a unit Vector3D. * @returns A unit Vector3D. */ - normalize(): Vector3D { + normalize(): Vector3D { const m = this.magnitude(); if (m === 0) { - return Vector3D.origin; + return Vector3D.origin as Vector3D; } - return new Vector3D(this.x / m, this.y / m, this.z / m); + return new Vector3D(this.x / m as T, this.y / m as T, this.z / m as T); } // Calculate the dot product of this and another [Vector3D]. @@ -259,7 +259,7 @@ export class Vector3D { } // / Return the unit vector that bisects this and another [Vector3D]. - bisect(v: Vector3D): Vector3D { + bisect(v: Vector3D): Vector3D { return this.scale(v.magnitude()).add(v.scale(this.magnitude())).normalize(); } diff --git a/src/time/EpochGPS.ts b/src/time/EpochGPS.ts index 2d33913..f18e2a0 100644 --- a/src/time/EpochGPS.ts +++ b/src/time/EpochGPS.ts @@ -21,6 +21,7 @@ * SOFTWARE. */ +import { Seconds } from '../main'; import { DataHandler } from '../data/DataHandler'; import { secondsPerWeek } from '../utils/constants'; import type { EpochUTC } from './EpochUTC'; @@ -49,7 +50,7 @@ export class EpochGPS { static reference: EpochUTC; // / GPS leap second difference from TAI/UTC offsets. - static offset = 19; + static offset = 19 as Seconds; // / Get GPS week accounting for 10-bit rollover. get week10Bit(): number { @@ -67,9 +68,9 @@ export class EpochGPS { // / Convert this to a UTC epoch. toUTC(): EpochUTC { - const init = EpochGPS.reference.roll(this.week * secondsPerWeek + this.seconds); + const init = EpochGPS.reference.roll((this.week * secondsPerWeek + this.seconds) as Seconds); const ls = DataHandler.getInstance().getLeapSeconds(init.toJulianDate()); - return init.roll(-(ls - EpochGPS.offset)); + return init.roll(-(ls - EpochGPS.offset) as Seconds); } } diff --git a/src/time/EpochUTC.ts b/src/time/EpochUTC.ts index d91e756..7e0b0d4 100644 --- a/src/time/EpochUTC.ts +++ b/src/time/EpochUTC.ts @@ -21,6 +21,7 @@ * SOFTWARE. */ +import { Seconds } from '../main'; import { DEG2RAD, MS_PER_DAY, RAD2DEG, secondsPerWeek, TAU } from '../utils/constants'; import { evalPoly } from '../utils/functions'; import { DataHandler } from './../data/DataHandler'; @@ -67,11 +68,11 @@ export class EpochUTC extends Epoch { return new EpochUTC(new Date(dts).getTime() / 1000); } - static fromJ2000TTSeconds(seconds: number): EpochUTC { + static fromJ2000TTSeconds(seconds: Seconds): EpochUTC { const tInit = new EpochUTC(seconds + 946728000); const ls = DataHandler.getInstance().getLeapSeconds(tInit.toJulianDate()); - return tInit.roll(-32.184 - ls); + return tInit.roll(-32.184 - ls as Seconds); } static fromDefinitiveString(definitiveString: string): EpochUTC { @@ -87,7 +88,7 @@ export class EpochUTC extends Epoch { return new EpochUTC(dts / 1000); } - roll(seconds: number): EpochUTC { + roll(seconds: Seconds): EpochUTC { return new EpochUTC(this.posix + seconds); } @@ -121,7 +122,7 @@ export class EpochUTC extends Epoch { toGPS(): EpochGPS { const referenceTime = EpochUTC.fromDateTimeString('1980-01-06T00:00:00.000Z'); const ls = DataHandler.getInstance().getLeapSeconds(this.toJulianDate()); - const delta = this.roll(ls - EpochGPS.offset).difference(referenceTime); + const delta = this.roll(ls - EpochGPS.offset as Seconds).difference(referenceTime); const week = delta / secondsPerWeek; const weekFloor = Math.floor(week); const seconds = (week - weekFloor) * secondsPerWeek; diff --git a/tsconfig.base.json b/tsconfig.base.json index 37b336f..42c59b8 100644 --- a/tsconfig.base.json +++ b/tsconfig.base.json @@ -7,8 +7,6 @@ "module": "es6", "lib": ["esnext"], "declaration": true, - // "noImplicitAny": true, - // "removeComments": true, "baseUrl": ".", "allowJs": true, "experimentalDecorators": true, @@ -17,7 +15,6 @@ "listFiles": true, "newLine": "LF", "skipLibCheck": true, - // "noEmitOnError": true, "types": ["jest", "node"], "moduleResolution": "Node", "esModuleInterop": true diff --git a/tsconfig.json b/tsconfig.json index a874b52..750919a 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -9,6 +9,4 @@ }, "include": ["./src/**/*.ts", "./test/**/*.ts"], "filesGlob": ["./src/**/*.ts", "./test/**/*.ts"], - "ignorePatterns": ["./src/sgp4/asc/**/*.ts"], - "exclude": ["./src/sgp4/asc/assembly/index.ts"] }