-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
166 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
import { EpochUTC, J2000, Kilometers, Matrix, RIC, Vector3D } from './../../src/main'; | ||
|
||
describe('RIC', () => { | ||
let stateVector: J2000; | ||
let origin: J2000; | ||
|
||
beforeEach(() => { | ||
stateVector = new J2000( | ||
EpochUTC.fromDateTime(new Date(1705109326817)), | ||
new Vector3D(1538.223335842895 as Kilometers, 5102.261204021967 as Kilometers, 4432.634965003577 as Kilometers), | ||
new Vector3D( | ||
-7.341518909379302 as Kilometers, | ||
0.6516718453998644 as Kilometers, | ||
1.7933882499861993 as Kilometers, | ||
), | ||
); | ||
|
||
origin = new J2000( | ||
EpochUTC.fromDateTime(new Date(1705109326817)), | ||
new Vector3D(1540.223335842895 as Kilometers, 5102.251204021967 as Kilometers, 4432.644965003577 as Kilometers), | ||
new Vector3D( | ||
-7.331518909379302 as Kilometers, | ||
0.6516718453998644 as Kilometers, | ||
1.7933882499861993 as Kilometers, | ||
), | ||
); | ||
}); | ||
|
||
// Create a new RIC coordinate from J2000 state vectors and origin | ||
it('should create a new RIC coordinate from J2000 state vectors and origin', () => { | ||
const transform = new Matrix([ | ||
[1, 0, 0], | ||
[0, 1, 0], | ||
[0, 0, 1], | ||
]); | ||
|
||
const ric = RIC.fromJ2000Matrix(stateVector, origin, transform); | ||
|
||
expect(ric).toMatchSnapshot(); | ||
}); | ||
|
||
// Create a RIC coordinate system from a J2000 state and origin | ||
it('should create a RIC coordinate system from a J2000 state and origin', () => { | ||
const ric = RIC.fromJ2000(stateVector, origin); | ||
|
||
expect(ric).toMatchSnapshot(); | ||
}); | ||
|
||
/* | ||
* Transform the current RIC coordinate to the J2000 coordinate system using | ||
* the provided origin | ||
*/ | ||
it('should transform the current RIC coordinate to the J2000 coordinate system using the provided origin', () => { | ||
const transform = new Matrix([ | ||
[1, 0, 0], | ||
[0, 1, 0], | ||
[0, 0, 1], | ||
]); | ||
const ric = new RIC(stateVector.position, stateVector.velocity); | ||
const j2000 = ric.toJ2000Matrix(origin, transform); | ||
|
||
expect(j2000).toMatchSnapshot(); | ||
}); | ||
|
||
/* | ||
* Transform the current RIC coordinate to the J2000 coordinate system using | ||
* the provided origin and transform matrix | ||
*/ | ||
it('should transform the current RIC coordinate to J2000 using the provided origin and transform matrix', () => { | ||
const ric = new RIC(stateVector.position, stateVector.velocity); | ||
const j2000 = ric.toJ2000(origin); | ||
|
||
expect(j2000).toMatchSnapshot(); | ||
}); | ||
|
||
// Get the name of the RIC coordinate system | ||
it('should get the name of the RIC coordinate system', () => { | ||
const ric = new RIC(stateVector.position, stateVector.velocity); | ||
const name = ric.name; | ||
|
||
expect(name).toMatchSnapshot(); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`RIC should create a RIC coordinate system from a J2000 state and origin 1`] = ` | ||
RIC { | ||
"position": Vector3D { | ||
"x": -0.4434101992280181, | ||
"y": 1.9338646031157782, | ||
"z": -0.25249770699242563, | ||
}, | ||
"velocity": Vector3D { | ||
"x": -0.002221880767217895, | ||
"y": 0.009676856714746954, | ||
"z": -0.001192346417169753, | ||
}, | ||
} | ||
`; | ||
|
||
exports[`RIC should create a new RIC coordinate from J2000 state vectors and origin 1`] = ` | ||
RIC { | ||
"position": Vector3D { | ||
"x": -2, | ||
"y": 0.010000000000218279, | ||
"z": -0.010000000000218279, | ||
}, | ||
"velocity": Vector3D { | ||
"x": -0.010000000000000675, | ||
"y": 0, | ||
"z": 0, | ||
}, | ||
} | ||
`; | ||
|
||
exports[`RIC should get the name of the RIC coordinate system 1`] = `"RIC"`; | ||
|
||
exports[`RIC should transform the current RIC coordinate to J2000 using the provided origin and transform matrix 1`] = ` | ||
J2000 { | ||
"epoch": EpochUTC { | ||
"posix": 1705109326.817, | ||
}, | ||
"position": Vector3D { | ||
"x": -2526.8631969362687, | ||
"y": 3698.432701341307, | ||
"z": 9867.307227222767, | ||
}, | ||
"velocity": Vector3D { | ||
"x": -9.379496377921184, | ||
"y": -5.899851460084735, | ||
"z": -1.4349469513344795, | ||
}, | ||
} | ||
`; | ||
|
||
exports[`RIC should transform the current RIC coordinate to the J2000 coordinate system using the provided origin 1`] = ` | ||
J2000 { | ||
"epoch": EpochUTC { | ||
"posix": 1705109326.817, | ||
}, | ||
"position": Vector3D { | ||
"x": 3078.44667168579, | ||
"y": 10204.512408043935, | ||
"z": 8865.279930007155, | ||
}, | ||
"velocity": Vector3D { | ||
"x": -14.673037818758605, | ||
"y": 1.303343690799729, | ||
"z": 3.5867764999723986, | ||
}, | ||
} | ||
`; |