- 使用压缩表加速查找日月食沙罗周期信息 - 优化日月食搜索跳步,减少非食季朔望月扫描 - 新增本地日全食、日环食、月全食搜索接口,返回 ok 区分未找到结果 - 新增水星、金星地心凌日查询及测试
37 lines
1.0 KiB
Go
37 lines
1.0 KiB
Go
package eclipse
|
|
|
|
import (
|
|
"math"
|
|
|
|
"b612.me/astro/basic"
|
|
)
|
|
|
|
const (
|
|
eclipseSeasonNodeDistanceLimitDeg = 35.0
|
|
eclipseSeasonMaxSearchStep = 4
|
|
)
|
|
|
|
func nextEclipseSearchCandidateTT(candidateTT float64, phaseType, direction int, synodicMonthDays float64) float64 {
|
|
step := eclipseSearchStep(candidateTT, direction, synodicMonthDays)
|
|
return basic.CalcMoonSHByJDE(candidateTT+float64(direction*step)*synodicMonthDays, phaseType)
|
|
}
|
|
|
|
func eclipseSearchStep(candidateTT float64, direction int, synodicMonthDays float64) int {
|
|
step := 1
|
|
for nextStep := 2; nextStep <= eclipseSeasonMaxSearchStep; nextStep++ {
|
|
skippedTT := candidateTT + float64(direction*(nextStep-1))*synodicMonthDays
|
|
if eclipseNodeDistance(skippedTT) < eclipseSeasonNodeDistanceLimitDeg {
|
|
break
|
|
}
|
|
step = nextStep
|
|
}
|
|
return step
|
|
}
|
|
|
|
func eclipseNodeDistance(ttJDE float64) float64 {
|
|
argument := normalizeDegree360(basic.MoonLonX(ttJDE))
|
|
toAscending := math.Min(argument, 360-argument)
|
|
toDescending := math.Abs(argument - 180)
|
|
return math.Min(toAscending, toDescending)
|
|
}
|