@behaver/diurnal-parallax
Advanced tools
Comparing version 1.0.3 to 1.1.0
53
index.js
@@ -15,3 +15,3 @@ 'use strict' | ||
* @author 董 三碗 <qianxing@yeah.net> | ||
* @version 1.0.0 | ||
* @version 1.1.0 | ||
*/ | ||
@@ -49,2 +49,3 @@ class DiurnalParallax { | ||
* @param {SiderealTime} options.siderealTime 观测位置的当地真恒星时对象 | ||
* @param {String} options.system 坐标系统 | ||
* | ||
@@ -59,2 +60,3 @@ * @return {DiurnalParallax} 返回 this 引用 | ||
siderealTime, | ||
system, | ||
}) { | ||
@@ -72,2 +74,6 @@ // 参数预处理 | ||
if (system === undefined) system = 'equinoctial'; | ||
else if (typeof(system) !== 'string') throw Error('The param system should be a String.'); | ||
else if (system !== 'equinoctial' && system !== 'horizontal') throw Error('The param system should be equinoctial or horizontal.'); | ||
this.private = { | ||
@@ -77,2 +83,3 @@ obGeoLat, | ||
siderealTime, | ||
system, | ||
} | ||
@@ -97,2 +104,5 @@ | ||
// 地球平均半径 | ||
const mER = 6371.393; | ||
// 地球极赤半径比 | ||
@@ -111,16 +121,29 @@ const PER = 0.99664719 | ||
// 真恒星时,单位:弧度 | ||
let TST = angle.setSeconds(this.private.siderealTime.trueVal).getRadian(); | ||
// 海拔高度,单位:千米 | ||
let obElevation = this.private.obElevation / 1000; | ||
// 站心与地心向径的赤道平面投影长度,单位:千米 | ||
let r = EAR * Math.cos(geocentricLat) + obElevation * Math.cos(geographicLat); | ||
// 空间直角坐标系下周日视差的各轴修正值结果,单位:千米 | ||
let corrections; | ||
// 空间直角坐标系下周日视差的各轴修正值结果,单位:千米 | ||
let corrections = { | ||
x: r * Math.cos(TST), | ||
y: r * Math.sin(TST), | ||
z: EAR * Math.sin(geocentricLat) * PER + obElevation * Math.sin(geographicLat), | ||
if (this.private.system === 'equinoctial') { | ||
// 真恒星时,单位:弧度 | ||
let TST = angle.setSeconds(this.private.siderealTime.trueVal).getRadian(); | ||
// 站心与地心向径的赤道平面投影长度,单位:千米 | ||
let r = mER * Math.cos(geocentricLat) + obElevation * Math.cos(geographicLat); | ||
corrections = { | ||
x: r * Math.cos(TST), | ||
y: r * Math.sin(TST), | ||
z: EAR * Math.sin(geocentricLat) * PER + obElevation * Math.sin(geographicLat), | ||
} | ||
} else if (this.private.system === 'horizontal') { | ||
// 地理纬度与地心纬度间的差角,单位:弧度 | ||
let theta = geographicLat - geocentricLat; | ||
corrections = { | ||
x: EAR * Math.sin(theta), | ||
y: 0, | ||
z: EAR * Math.cos(theta) + obElevation, | ||
} | ||
} | ||
@@ -163,3 +186,5 @@ | ||
return this.position.tc.equal(); | ||
let tc = this.position.tc.equal(); | ||
return new SphericalCoordinate3D(tc.r / this.consts.AU, tc.theta, tc.phi); | ||
} | ||
@@ -199,3 +224,5 @@ | ||
return this.position.gc.equal(); | ||
let gc = this.position.gc.equal(); | ||
return new SphericalCoordinate3D(gc.r / this.consts.AU, gc.theta, gc.phi); | ||
} | ||
@@ -202,0 +229,0 @@ } |
{ | ||
"name": "@behaver/diurnal-parallax", | ||
"version": "1.0.3", | ||
"version": "1.1.0", | ||
"description": "The package is for calculating diurnal parallax.", | ||
@@ -20,2 +20,3 @@ "main": "index.js", | ||
"devDependencies": { | ||
"@behaver/celestial-coordinate": "^1.1.0", | ||
"@behaver/jdate": "^2.1.0", | ||
@@ -27,5 +28,5 @@ "chai": "^4.2.0", | ||
"@behaver/angle": "^2.0.2", | ||
"@behaver/coordinate": "^3.2.3", | ||
"@behaver/coordinate": "^3.3.0", | ||
"@behaver/sidereal-time": "^1.0.1" | ||
} | ||
} |
@@ -6,2 +6,3 @@ const expect = require("chai").expect; | ||
const { SphericalCoordinate3D } = require('@behaver/coordinate/3d'); | ||
const { EquinoctialCoordinate } = require('@behaver/celestial-coordinate'); | ||
const Angle = require('@behaver/angle'); | ||
@@ -162,3 +163,3 @@ | ||
describe('#get TC()', () => { | ||
it('The return of method get TC() should have all keys r, theta and phi.', () => { | ||
it('The return of method get TC() should be a instance of SphericalCoordinate3D.', () => { | ||
let dp = new DiurnalParallax({ | ||
@@ -170,3 +171,3 @@ gc: new SphericalCoordinate3D(0.37276, 2, 2), | ||
expect(dp.TC).to.have.all.keys('r', 'theta', 'phi'); | ||
expect(dp.TC).to.be.a.instanceof(SphericalCoordinate3D); | ||
}); | ||
@@ -194,3 +195,3 @@ }); | ||
describe('#get GC()', () => { | ||
it('The return of method get GC() should have all keys r, theta and phi.', () => { | ||
it('The return of method get GC() should be a instance of SphericalCoordinate3D.', () => { | ||
let dp = new DiurnalParallax({ | ||
@@ -202,3 +203,3 @@ tc: new SphericalCoordinate3D(0.37276, 2, 2), | ||
expect(dp.GC).to.have.all.keys('r', 'theta', 'phi'); | ||
expect(dp.GC).to.be.a.instanceof(SphericalCoordinate3D); | ||
}); | ||
@@ -208,3 +209,3 @@ }); | ||
describe('#Verify', () => { | ||
it('#天文算法 例39.a', () => { | ||
it('#天文算法 例39.a,赤道坐标', () => { | ||
let date = new Date('2003/08/28 11:17:00'); | ||
@@ -230,2 +231,3 @@ let jdate = new JDateRepository(date, 'date'); | ||
obElevation: 1713, | ||
system: 'equinoctial', | ||
}); | ||
@@ -242,3 +244,3 @@ | ||
it('#天文算法 例39.a 反向计算,站心坐标 转 地心坐标', () => { | ||
it('#天文算法 例39.a 反向计算,赤道坐标,站心坐标 转 地心坐标', () => { | ||
let date = new Date('2003/08/28 11:17:00'); | ||
@@ -262,2 +264,3 @@ let jdate = new JDateRepository(date, 'date'); | ||
obElevation: 1713, | ||
system: 'equinoctial', | ||
}); | ||
@@ -272,4 +275,67 @@ | ||
expect(90 - angle.setRadian(gc.theta).getDegrees()).to.closeTo(DECt, 0.00002); | ||
}) | ||
}); | ||
it('#天文算法 例39.a 地平坐标转换', () => { | ||
let date = new Date('2003/08/28 11:17:00'); | ||
let jdate = new JDateRepository(date, 'date'); | ||
let obGeoLong = angle.parseDACString('116°51′50″').getDegrees(); | ||
let obGeoLat = angle.parseDACString('33°21′21″').getDegrees(); | ||
let obElevation = 1713; | ||
let siderealTime = new SiderealTime(jdate, obGeoLong); | ||
let r = 0.37276; | ||
let theta = angle.setDegrees(90 + 15.771083).getRadian(); | ||
let phi = angle.setDegrees(339.530208).getRadian(); | ||
let egc = new SphericalCoordinate3D(r, theta, phi); | ||
let dp = new DiurnalParallax({ | ||
gc: egc, | ||
siderealTime: siderealTime, | ||
obGeoLat: obGeoLat, | ||
obElevation: 1713, | ||
system: 'equinoctial', | ||
}); | ||
// 赤道站心坐标 | ||
let etc = dp.TC; | ||
let ec = new EquinoctialCoordinate({ | ||
sc: egc, | ||
epoch: jdate, | ||
withNutation: true, | ||
}); | ||
// 地平地心坐标 | ||
let hgc = ec.toHorizontal({ | ||
obGeoLong, | ||
obGeoLat, | ||
}).sc; | ||
let hdp = new DiurnalParallax({ | ||
gc: hgc, | ||
siderealTime: siderealTime, | ||
obGeoLat: obGeoLat, | ||
obElevation: 1713, | ||
system: 'horizontal', | ||
}); | ||
let htc = hdp.TC; | ||
let ec2 = new EquinoctialCoordinate({ | ||
sc: new SphericalCoordinate3D(etc.r, etc.theta, etc.phi), | ||
epoch: jdate, | ||
withNutation: true, | ||
}); | ||
let htc2 = ec2.toHorizontal({ | ||
obGeoLong, | ||
obGeoLat, | ||
}).sc; | ||
expect(htc.r).to.closeTo(htc2.r, 0.000001); | ||
expect(htc.theta).to.closeTo(htc2.theta, 0.00001); | ||
expect(htc.phi).to.closeTo(htc2.phi, 0.00001); | ||
}); | ||
}) | ||
}); |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
1386150
460
4
Updated@behaver/coordinate@^3.3.0