feat: 引入可切换星历模型并扩展天象观测链路

- 新增半解析、旧模型、自定义与多源堆叠星历实例,提供 Context、Instance、SPK 读取及状态与视位置计算
- 统一太阳、月球和行星实例接口,扩展黄经穿越、留、相位、最近角距、偕日可见、任意高度升落、轨道节点及凌日等天象查询
- 完善日月食、月掩与凌日的月缘剖面、有限盘面接触、站心修正、局地可见性、全球路径和地图输出
- 新增 SVG、GeoJSON、KML 天象输出及凌日、月掩和月缘地形相关缓存与几何求解
- 新增恒星星表导入与查询,支持 CSV、Hipparcos、BSC5、Stellarium 等格式及名称、交叉标识、锥面检索和星等过滤
- 补充 IAU 2006、地球定向、折射消光、大气观测、轨道传播及半解析行星/月球数据支持
- 将默认未来民用时标切换为 TimeScaleLeapHour,更新 2027–2400 农历速查表、中文日期解析和时区边界处理
- 增加事件基线、跨模型回归、几何边界、月缘地形和输出契约测试,完善中英文手册、示例资源、NOTICE 与忽略规则
This commit is contained in:
2026-10-15 23:54:15 +08:00
parent 16c62a97d5
commit 044f2f4381
674 changed files with 62983 additions and 8396 deletions
+82
View File
@@ -0,0 +1,82 @@
package formula
import "math"
const arcsecToRadian = math.Pi / 180 / 3600
// TIOLocatorArcsec 地球自转原点定位角 s′,单位角秒 / TIO locator s′ in arcseconds.
//
// jdeTT 为 TT 儒略日。采用 IERS 2010 的线性近似 s′ = −47 µas·t,t 为 J2000 起的儒略世纪数。
// jdeTT is a TT Julian date. Uses the IERS 2010 linear model s′ = −47 µas·t,
// with t in Julian centuries since J2000.
func TIOLocatorArcsec(jdeTT float64) float64 {
if !isFinitePhotometry(jdeTT) {
return math.NaN()
}
return -47e-6 * (jdeTT - 2451545.0) / 36525
}
// PolarMotionMatrix 极移矩阵 W,把地球中间参考系 (TIRS) 矢量转到 ITRS / polar-motion matrix from TIRS to ITRS.
//
// xp、yp 为 IERS 公布的极坐标,sPrime 为 TIOLocatorArcsec 的结果,单位都是角秒。
// 返回 W = R1(−yp)·R2(−xp)·R3(s′),按 v_ITRS = W·v_TIRS 使用。
// xp and yp are IERS pole coordinates and sPrime is the TIO locator, all in
// arcseconds. Returns W = R1(−yp)·R2(−xp)·R3(s′) for v_ITRS = W·v_TIRS.
func PolarMotionMatrix(xp, yp, sPrime float64) [3][3]float64 {
if !isFinitePhotometry(xp) || !isFinitePhotometry(yp) || !isFinitePhotometry(sPrime) {
return nanMatrix()
}
return multiplyMatrix(rotationX(-yp*arcsecToRadian),
multiplyMatrix(rotationY(-xp*arcsecToRadian), rotationZ(sPrime*arcsecToRadian)))
}
// CelestialPoleOffsetMatrix 天球极偏差修正矩阵 / celestial pole offset correction matrix.
//
// dX、dY 为 IERS 公布的 CIP 坐标改正,单位毫角秒。返回一阶小角矩阵 Δ,
// 左乘模型给出的 GCRS→CIRS(或 GCRS→真赤道)矩阵即得改正后的矩阵:C′ = Δ·C。
// dX and dY are IERS CIP corrections in milliarcseconds. Returns the
// first-order matrix Δ; left-multiply a model GCRS→CIRS (or GCRS→true-equator)
// matrix to apply the offsets: C′ = Δ·C.
func CelestialPoleOffsetMatrix(dX, dY float64) [3][3]float64 {
if !isFinitePhotometry(dX) || !isFinitePhotometry(dY) {
return nanMatrix()
}
x := dX * arcsecToRadian / 1000
y := dY * arcsecToRadian / 1000
return [3][3]float64{
{1, 0, -x},
{0, 1, -y},
{x, y, 1},
}
}
// rotationX 等为被动旋转:把矢量所在坐标轴绕 x/y/z 轴转 angle 弧度。
func rotationX(angle float64) [3][3]float64 {
s, c := math.Sincos(angle)
return [3][3]float64{{1, 0, 0}, {0, c, s}, {0, -s, c}}
}
func rotationY(angle float64) [3][3]float64 {
s, c := math.Sincos(angle)
return [3][3]float64{{c, 0, -s}, {0, 1, 0}, {s, 0, c}}
}
func rotationZ(angle float64) [3][3]float64 {
s, c := math.Sincos(angle)
return [3][3]float64{{c, s, 0}, {-s, c, 0}, {0, 0, 1}}
}
func multiplyMatrix(a, b [3][3]float64) [3][3]float64 {
var out [3][3]float64
for i := 0; i < 3; i++ {
for j := 0; j < 3; j++ {
out[i][j] = a[i][0]*b[0][j] + a[i][1]*b[1][j] + a[i][2]*b[2][j]
}
}
return out
}
func nanMatrix() [3][3]float64 {
n := math.NaN()
return [3][3]float64{{n, n, n}, {n, n, n}, {n, n, n}}
}