2bf8478639
- 新增日月食中心带、偏食带、阴影足迹、等时线、食分线及升落边界计算,支持极区与混合食拓扑 - 新增日食单时刻阴影求解器、站心状态查询、批量采样和 ΔT 覆盖接口 - 重构恒星与行星月掩路径,补充有限盘面接触、站心修正、掩带宽度、极区投影及升落边界 - 扩展 SVG 与 GeoJSON 输出,支持详细面板、全球/极区/地球投影、边界闭合、时间标记和拓扑签名 - 扩展日月食候选搜索、局地搜索、沙罗序列预计算与范围外推,补充系列锚点和成员一致性校验 - 补齐古历纪年、儒略历独有闰日、多公历候选、历法改革跨日及精确日期运算接口 - 优化 ΔT、章动、恒星时、月球地平线、事件根搜索和本地星历缓存,降低重复计算开销并提升边界稳定
284 lines
7.9 KiB
Go
284 lines
7.9 KiB
Go
package basic
|
|
|
|
import (
|
|
"math"
|
|
|
|
. "b612.me/astro/tools"
|
|
)
|
|
|
|
// Pos
|
|
|
|
const (
|
|
NEPTUNE_S_PERIOD = 1 / ((1 / 365.256363004) - (1 / 60190.03))
|
|
neptuneEventSearchN = 16
|
|
neptunePhaseCoarseTolerance = 30.0 / 86400.0
|
|
)
|
|
|
|
func neptuneSunLongitudeDelta(jde, degree float64, filter bool) float64 {
|
|
sub := Limit360(Limit360(NeptuneApparentLo(jde)-HSunApparentLo(jde)) - degree)
|
|
if filter {
|
|
if sub > 180 {
|
|
sub -= 360
|
|
}
|
|
if sub < -180 {
|
|
sub += 360
|
|
}
|
|
}
|
|
return sub
|
|
}
|
|
|
|
func neptuneSunLongitudeDeltaN(jde, degree float64, filter bool, n int) float64 {
|
|
sub := Limit360(Limit360(NeptuneApparentLoN(jde, n)-HSunApparentLoN(jde, n)) - degree)
|
|
if filter {
|
|
if sub > 180 {
|
|
sub -= 360
|
|
}
|
|
if sub < -180 {
|
|
sub += 360
|
|
}
|
|
}
|
|
return sub
|
|
}
|
|
|
|
func neptuneRADerivative(jde, delta float64) float64 {
|
|
sub := NeptuneApparentRa(jde+delta) - NeptuneApparentRa(jde-delta)
|
|
if sub > 180 {
|
|
sub -= 360
|
|
}
|
|
if sub < -180 {
|
|
sub += 360
|
|
}
|
|
return sub / (2 * delta)
|
|
}
|
|
|
|
func neptuneRADerivativeN(jde, delta float64, n int) float64 {
|
|
sub := NeptuneApparentRaN(jde+delta, n) - NeptuneApparentRaN(jde-delta, n)
|
|
if sub > 180 {
|
|
sub -= 360
|
|
}
|
|
if sub < -180 {
|
|
sub += 360
|
|
}
|
|
return sub / (2 * delta)
|
|
}
|
|
|
|
func neptuneConjunctionFull(jde, degree float64, next uint8) float64 {
|
|
//0=last 1=next
|
|
if !isFiniteFloat(jde) || !isFiniteFloat(degree) {
|
|
return math.NaN()
|
|
}
|
|
daysPerDegree := NEPTUNE_S_PERIOD / 360
|
|
currentDelta := neptuneSunLongitudeDelta(jde, degree, false)
|
|
if next == 0 {
|
|
jde -= (360 - currentDelta) * daysPerDegree
|
|
} else {
|
|
jde += daysPerDegree * currentDelta
|
|
}
|
|
estimateJD := jde
|
|
converged := false
|
|
for i := 0; i < eventNewtonMaxIterations; i++ {
|
|
prevJD := estimateJD
|
|
longitudeDelta := neptuneSunLongitudeDelta(prevJD, degree, true)
|
|
longitudeSlope := (neptuneSunLongitudeDelta(prevJD+0.000005, degree, true) - neptuneSunLongitudeDelta(prevJD-0.000005, degree, true)) / 0.00001
|
|
nextJD := prevJD - longitudeDelta/longitudeSlope
|
|
estimateJD = nextJD
|
|
if math.Abs(nextJD-prevJD) <= 0.00001 {
|
|
converged = true
|
|
break
|
|
}
|
|
}
|
|
if !converged {
|
|
return math.NaN()
|
|
}
|
|
return TD2UT(estimateJD, false)
|
|
}
|
|
|
|
func neptuneConjunction(jde, degree float64, next uint8) float64 {
|
|
//0=last 1=next
|
|
if !isFiniteFloat(jde) || !isFiniteFloat(degree) {
|
|
return math.NaN()
|
|
}
|
|
daysPerDegree := NEPTUNE_S_PERIOD / 360
|
|
currentDelta := neptuneSunLongitudeDelta(jde, degree, false)
|
|
if next == 0 {
|
|
jde -= (360 - currentDelta) * daysPerDegree
|
|
} else {
|
|
jde += daysPerDegree * currentDelta
|
|
}
|
|
estimateJD := jde
|
|
converged := false
|
|
for i := 0; i < eventNewtonMaxIterations; i++ {
|
|
prevJD := estimateJD
|
|
longitudeDelta := neptuneSunLongitudeDeltaN(prevJD, degree, true, neptuneEventSearchN)
|
|
longitudeSlope := (neptuneSunLongitudeDeltaN(prevJD+0.000005, degree, true, neptuneEventSearchN) - neptuneSunLongitudeDeltaN(prevJD-0.000005, degree, true, neptuneEventSearchN)) / 0.00001
|
|
nextJD := prevJD - longitudeDelta/longitudeSlope
|
|
estimateJD = nextJD
|
|
if math.Abs(nextJD-prevJD) <= neptunePhaseCoarseTolerance {
|
|
converged = true
|
|
break
|
|
}
|
|
}
|
|
if !converged {
|
|
return math.NaN()
|
|
}
|
|
converged = false
|
|
for i := 0; i < eventNewtonMaxIterations; i++ {
|
|
prevJD := estimateJD
|
|
longitudeDelta := neptuneSunLongitudeDelta(prevJD, degree, true)
|
|
longitudeSlope := (neptuneSunLongitudeDelta(prevJD+0.000005, degree, true) - neptuneSunLongitudeDelta(prevJD-0.000005, degree, true)) / 0.00001
|
|
nextJD := prevJD - longitudeDelta/longitudeSlope
|
|
estimateJD = nextJD
|
|
if math.Abs(nextJD-prevJD) <= 0.00001 {
|
|
converged = true
|
|
break
|
|
}
|
|
}
|
|
if !converged {
|
|
return math.NaN()
|
|
}
|
|
return TD2UT(estimateJD, false)
|
|
}
|
|
|
|
func LastNeptuneConjunction(jde float64) float64 {
|
|
return inclusiveLastPhaseEvent(jde, 0, neptuneConjunction)
|
|
}
|
|
|
|
func NextNeptuneConjunction(jde float64) float64 {
|
|
return inclusiveNextPhaseEvent(jde, 0, neptuneConjunction)
|
|
}
|
|
|
|
func LastNeptuneOpposition(jde float64) float64 {
|
|
return inclusiveLastPhaseEvent(jde, 180, neptuneConjunction)
|
|
}
|
|
|
|
func NextNeptuneOpposition(jde float64) float64 {
|
|
return inclusiveNextPhaseEvent(jde, 180, neptuneConjunction)
|
|
}
|
|
|
|
func NextNeptuneEasternQuadrature(jde float64) float64 {
|
|
return inclusiveNextPhaseEvent(jde, 90, neptuneConjunction)
|
|
}
|
|
|
|
func LastNeptuneEasternQuadrature(jde float64) float64 {
|
|
return inclusiveLastPhaseEvent(jde, 90, neptuneConjunction)
|
|
}
|
|
|
|
func NextNeptuneWesternQuadrature(jde float64) float64 {
|
|
return inclusiveNextPhaseEvent(jde, 270, neptuneConjunction)
|
|
}
|
|
|
|
func LastNeptuneWesternQuadrature(jde float64) float64 {
|
|
return inclusiveLastPhaseEvent(jde, 270, neptuneConjunction)
|
|
}
|
|
|
|
func neptuneRetrogradeAroundOpposition(oppositionJD float64, searchBeforeOpposition bool) float64 {
|
|
if !isFiniteFloat(oppositionJD) {
|
|
return math.NaN()
|
|
}
|
|
oppositionTT := TD2UT(oppositionJD, true)
|
|
startTT := oppositionTT
|
|
endTT := oppositionTT
|
|
if searchBeforeOpposition {
|
|
easternQuadratureUT := neptuneConjunction(oppositionTT, 90, 0)
|
|
startTT = TD2UT(easternQuadratureUT, true)
|
|
} else {
|
|
westernQuadratureUT := neptuneConjunction(oppositionTT, 270, 1)
|
|
endTT = TD2UT(westernQuadratureUT, true)
|
|
}
|
|
bestJD := zeroEventInWindow(startTT, endTT, 2.0, 2.0, 30.0/86400.0, func(jd float64) float64 {
|
|
return neptuneRADerivativeN(jd, stationDerivativeStepDay, neptuneEventSearchN)
|
|
}, func(jd float64) float64 {
|
|
return neptuneRADerivative(jd, stationDerivativeStepDay)
|
|
})
|
|
return TD2UT(bestJD, false)
|
|
}
|
|
|
|
func NextNeptuneRetrogradeToPrograde(jde float64) float64 {
|
|
if !isFiniteFloat(jde) {
|
|
return math.NaN()
|
|
}
|
|
lastOppositionJD := neptuneConjunctionFull(jde, 180, 0)
|
|
date := neptuneRetrogradeAroundOpposition(lastOppositionJD, false)
|
|
if isFiniteFloat(date) && stationUTQueryAfterOrEqual(date, jde) {
|
|
return date
|
|
}
|
|
nextOppositionJD := neptuneConjunctionFull(jde, 180, 1)
|
|
if !isFiniteFloat(nextOppositionJD) {
|
|
return math.NaN()
|
|
}
|
|
date = neptuneRetrogradeAroundOpposition(nextOppositionJD, false)
|
|
if !isFiniteFloat(date) || !stationUTQueryAfterOrEqual(date, jde) {
|
|
return math.NaN()
|
|
}
|
|
return date
|
|
}
|
|
|
|
func LastNeptuneRetrogradeToPrograde(jde float64) float64 {
|
|
if !isFiniteFloat(jde) {
|
|
return math.NaN()
|
|
}
|
|
lastOppositionJD := neptuneConjunctionFull(jde, 180, 0)
|
|
date := neptuneRetrogradeAroundOpposition(lastOppositionJD, false)
|
|
if isFiniteFloat(date) && stationUTQueryBeforeOrEqual(date, jde) {
|
|
return date
|
|
}
|
|
if !isFiniteFloat(lastOppositionJD) {
|
|
return math.NaN()
|
|
}
|
|
previousOppositionJD := neptuneConjunctionFull(eventUTLastQueryTT(lastOppositionJD), 180, 0)
|
|
if !isFiniteFloat(previousOppositionJD) {
|
|
return math.NaN()
|
|
}
|
|
date = neptuneRetrogradeAroundOpposition(previousOppositionJD, false)
|
|
if !isFiniteFloat(date) || !stationUTQueryBeforeOrEqual(date, jde) {
|
|
return math.NaN()
|
|
}
|
|
return date
|
|
}
|
|
|
|
func NextNeptuneProgradeToRetrograde(jde float64) float64 {
|
|
if !isFiniteFloat(jde) {
|
|
return math.NaN()
|
|
}
|
|
nextOppositionJD := neptuneConjunctionFull(jde, 180, 1)
|
|
date := neptuneRetrogradeAroundOpposition(nextOppositionJD, true)
|
|
if isFiniteFloat(date) && stationUTQueryAfterOrEqual(date, jde) {
|
|
return date
|
|
}
|
|
if !isFiniteFloat(nextOppositionJD) {
|
|
return math.NaN()
|
|
}
|
|
followingOppositionJD := neptuneConjunctionFull(eventUTNextQueryTT(nextOppositionJD), 180, 1)
|
|
if !isFiniteFloat(followingOppositionJD) {
|
|
return math.NaN()
|
|
}
|
|
date = neptuneRetrogradeAroundOpposition(followingOppositionJD, true)
|
|
if !isFiniteFloat(date) || !stationUTQueryAfterOrEqual(date, jde) {
|
|
return math.NaN()
|
|
}
|
|
return date
|
|
}
|
|
|
|
func LastNeptuneProgradeToRetrograde(jde float64) float64 {
|
|
if !isFiniteFloat(jde) {
|
|
return math.NaN()
|
|
}
|
|
nextOppositionJD := neptuneConjunctionFull(jde, 180, 1)
|
|
date := neptuneRetrogradeAroundOpposition(nextOppositionJD, true)
|
|
if isFiniteFloat(date) && stationUTQueryBeforeOrEqual(date, jde) {
|
|
return date
|
|
}
|
|
if !isFiniteFloat(nextOppositionJD) {
|
|
return math.NaN()
|
|
}
|
|
lastOppositionJD := neptuneConjunctionFull(jde, 180, 0)
|
|
if !isFiniteFloat(lastOppositionJD) {
|
|
return math.NaN()
|
|
}
|
|
date = neptuneRetrogradeAroundOpposition(lastOppositionJD, true)
|
|
if !isFiniteFloat(date) || !stationUTQueryBeforeOrEqual(date, jde) {
|
|
return math.NaN()
|
|
}
|
|
return date
|
|
}
|