-
Notifications
You must be signed in to change notification settings - Fork 145
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
8 changed files
with
288 additions
and
41 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,6 +9,7 @@ test | |
.eslintrc.json | ||
.npmignore | ||
.npmrc | ||
.raiseverrc | ||
.travis.yml | ||
copyright-template.txt | ||
rollup.* | ||
|
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,20 @@ | ||
{ | ||
"changelog": { | ||
"enabled": true, | ||
"path": "CHANGELOG.md", | ||
"encoding": "utf-8", | ||
"prefix": "##", | ||
"bullet": "-" | ||
}, | ||
"git": { | ||
"enabled": true, | ||
"release": "master", | ||
"development": "develop", | ||
"remote": "origin", | ||
"commit": true, | ||
"merge": true, | ||
"all": false, | ||
"tag": true, | ||
"push": false | ||
} | ||
} |
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
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 |
---|---|---|
@@ -1,27 +1,25 @@ | ||
export default function dopplerFactor(location, position, velocity) { | ||
const currentRange = Math.sqrt( | ||
((position.x - location.x) ** 2) | ||
+ ((position.y - location.y) ** 2) | ||
+ ((position.z - location.z) ** 2)); | ||
const mfactor = 7.292115E-5; | ||
const c = 299792.458; // Speed of light in km/s | ||
|
||
const nextPos = { | ||
x: position.x + velocity.x, | ||
y: position.y + velocity.y, | ||
z: position.z + velocity.z, | ||
const range = { | ||
x: position.x - location.x, | ||
y: position.y - location.y, | ||
z: position.z - location.z, | ||
}; | ||
range.w = Math.sqrt(range.x ** 2 + range.y ** 2 + range.z ** 2); | ||
|
||
const nextRange = Math.sqrt( | ||
((nextPos.x - location.x) ** 2) | ||
+ ((nextPos.y - location.y) ** 2) | ||
+ ((nextPos.z - location.z) ** 2)); | ||
|
||
let rangeRate = nextRange - currentRange; | ||
const rangeVel = { | ||
x: velocity.x + mfactor * location.y, | ||
y: velocity.y - mfactor * location.x, | ||
z: velocity.z, | ||
}; | ||
|
||
function sign(value) { | ||
return value >= 0 ? 1 : -1; | ||
} | ||
|
||
rangeRate *= sign(rangeRate); | ||
const c = 299792.458; // Speed of light in km/s | ||
return (1 + (rangeRate / c)); | ||
const rangeRate = (range.x * rangeVel.x + range.y * rangeVel.y + range.z * rangeVel.z) / range.w; | ||
|
||
return (1 + (rangeRate / c) * sign(rangeRate)); | ||
} |
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 |
---|---|---|
@@ -1,7 +1,70 @@ | ||
import dopplerFactor from '../src/dopplerFactor'; // eslint-disable-line | ||
|
||
const numDigits = 8; | ||
|
||
const earthRadius = 6378.137; | ||
const sincos45deg = Math.sqrt(2) / 2; | ||
|
||
describe('Doppler factor', () => { | ||
it('doppler factor', () => { | ||
// TODO: | ||
it('without observer movement', () => { | ||
// North Pole | ||
const observerEcf = { | ||
x: 0, | ||
y: 0, | ||
z: earthRadius, | ||
}; | ||
const positionEcf = { | ||
x: 0, | ||
y: 0, | ||
z: earthRadius + 500, | ||
}; | ||
// Escape velocity | ||
const velocityEcf = { | ||
x: 7.91, | ||
y: 0, | ||
z: 0, | ||
}; | ||
const dopFactor = dopplerFactor(observerEcf, positionEcf, velocityEcf); | ||
expect(dopFactor).toBeCloseTo(1, numDigits); | ||
}); | ||
|
||
it('movement of observer is not affected', () => { | ||
const observerEcf = { | ||
x: earthRadius, | ||
y: 0, | ||
z: 0, | ||
}; | ||
const positionEcf = { | ||
x: earthRadius + 500, | ||
y: 0, | ||
z: 0, | ||
}; | ||
const velocityEcf = { | ||
x: 0, | ||
y: 7.91, | ||
z: 0, | ||
}; | ||
const dopFactor = dopplerFactor(observerEcf, positionEcf, velocityEcf); | ||
expect(dopFactor).toBeCloseTo(1, numDigits); | ||
}); | ||
|
||
it('special case', () => { | ||
const observerEcf = { | ||
x: earthRadius, | ||
y: 0, | ||
z: 0, | ||
}; | ||
const positionEcf = { | ||
x: (earthRadius + 500) * sincos45deg, // z*sin(45) | ||
y: (earthRadius + 500) * sincos45deg, // z*cos(45) | ||
z: 0, | ||
}; | ||
const velocityEcf = { | ||
x: 7.91 * sincos45deg, | ||
y: 7.91 * sincos45deg, | ||
z: 0, | ||
}; | ||
const dopFactor = dopplerFactor(observerEcf, positionEcf, velocityEcf); | ||
expect(dopFactor).toBeCloseTo(1.0000107847789212, numDigits); | ||
}); | ||
}); |
Oops, something went wrong.