2026-05-01 22:38:44 +08:00
|
|
|
package basic
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
|
"math"
|
|
|
|
|
|
|
|
|
|
. "b612.me/astro/tools"
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
// Pos
|
|
|
|
|
|
|
|
|
|
const (
|
2026-08-06 12:00:56 +08:00
|
|
|
MARS_S_PERIOD = 1 / ((1 / 365.256363004) - (1 / 686.98))
|
|
|
|
|
marsEventSearchN = 16
|
|
|
|
|
marsPhaseCoarseTolerance = 30.0 / 86400.0
|
|
|
|
|
marsStationDerivativeStepDay = 0.01
|
|
|
|
|
marsStationCoarseStepDay = 6.0
|
|
|
|
|
marsStationHalfWindowDay = 6.0
|
2026-05-01 22:38:44 +08:00
|
|
|
)
|
|
|
|
|
|
2026-10-15 23:54:15 +08:00
|
|
|
func marsSunLongitudeDelta(jde, degree float64, filter bool, instances ...*Instance) float64 {
|
|
|
|
|
inst := instanceValue(instances)
|
|
|
|
|
|
|
|
|
|
sub := Limit360(Limit360(MarsApparentLoWithInstance(jde, inst)-HSunApparentLoWithInstance(jde, inst)) - degree)
|
2026-05-01 22:38:44 +08:00
|
|
|
if filter {
|
|
|
|
|
if sub > 180 {
|
|
|
|
|
sub -= 360
|
|
|
|
|
}
|
|
|
|
|
if sub < -180 {
|
|
|
|
|
sub += 360
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return sub
|
|
|
|
|
}
|
|
|
|
|
|
2026-10-15 23:54:15 +08:00
|
|
|
func marsSunLongitudeDeltaN(jde, degree float64, filter bool, n int, instances ...*Instance) float64 {
|
|
|
|
|
inst := instanceValue(instances)
|
|
|
|
|
|
|
|
|
|
sub := Limit360(Limit360(MarsApparentLoNWithInstance(jde, n, inst)-HSunApparentLoNWithInstance(jde, n, inst)) - degree)
|
2026-05-01 22:38:44 +08:00
|
|
|
if filter {
|
|
|
|
|
if sub > 180 {
|
|
|
|
|
sub -= 360
|
|
|
|
|
}
|
|
|
|
|
if sub < -180 {
|
|
|
|
|
sub += 360
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return sub
|
|
|
|
|
}
|
|
|
|
|
|
2026-10-15 23:54:15 +08:00
|
|
|
func marsRADerivative(jde, val float64, instances ...*Instance) float64 {
|
|
|
|
|
inst := instanceValue(instances)
|
|
|
|
|
|
|
|
|
|
sub := MarsApparentRaWithInstance(jde+val, inst) - MarsApparentRaWithInstance(jde-val, inst)
|
2026-05-01 22:38:44 +08:00
|
|
|
if sub > 180 {
|
|
|
|
|
sub -= 360
|
|
|
|
|
}
|
|
|
|
|
if sub < -180 {
|
|
|
|
|
sub += 360
|
|
|
|
|
}
|
|
|
|
|
return sub / (2 * val)
|
|
|
|
|
}
|
|
|
|
|
|
2026-10-15 23:54:15 +08:00
|
|
|
func marsRADerivativeN(jde, val float64, n int, instances ...*Instance) float64 {
|
|
|
|
|
inst := instanceValue(instances)
|
|
|
|
|
|
|
|
|
|
sub := MarsApparentRaNWithInstance(jde+val, n, inst) - MarsApparentRaNWithInstance(jde-val, n, inst)
|
2026-05-01 22:38:44 +08:00
|
|
|
if sub > 180 {
|
|
|
|
|
sub -= 360
|
|
|
|
|
}
|
|
|
|
|
if sub < -180 {
|
|
|
|
|
sub += 360
|
|
|
|
|
}
|
|
|
|
|
return sub / (2 * val)
|
|
|
|
|
}
|
|
|
|
|
|
2026-10-15 23:54:15 +08:00
|
|
|
func marsConjunctionFull(jde, degree float64, next uint8, instances ...*Instance) float64 {
|
|
|
|
|
inst := instanceValue(instances)
|
|
|
|
|
|
2026-05-01 22:38:44 +08:00
|
|
|
//0=last 1=next
|
2026-08-06 12:00:56 +08:00
|
|
|
if !isFiniteFloat(jde) || !isFiniteFloat(degree) {
|
|
|
|
|
return math.NaN()
|
|
|
|
|
}
|
2026-05-01 22:38:44 +08:00
|
|
|
daysPerDegree := MARS_S_PERIOD / 360
|
2026-10-15 23:54:15 +08:00
|
|
|
currentDelta := marsSunLongitudeDelta(jde, degree, false, inst)
|
2026-05-01 22:38:44 +08:00
|
|
|
if next == 0 {
|
|
|
|
|
jde -= (360 - currentDelta) * daysPerDegree
|
|
|
|
|
} else {
|
|
|
|
|
jde += daysPerDegree * currentDelta
|
|
|
|
|
}
|
2026-09-23 18:55:12 +08:00
|
|
|
estimateJDE := jde
|
2026-08-06 12:00:56 +08:00
|
|
|
converged := false
|
|
|
|
|
for i := 0; i < eventNewtonMaxIterations; i++ {
|
2026-09-23 18:55:12 +08:00
|
|
|
prevJDE := estimateJDE
|
2026-10-15 23:54:15 +08:00
|
|
|
longitudeDelta := marsSunLongitudeDelta(prevJDE, degree, true, inst)
|
|
|
|
|
longitudeSlope := (marsSunLongitudeDelta(prevJDE+0.000005, degree, true, inst) - marsSunLongitudeDelta(prevJDE-0.000005, degree, true, inst)) / 0.00001
|
2026-09-23 18:55:12 +08:00
|
|
|
nextJD := prevJDE - longitudeDelta/longitudeSlope
|
|
|
|
|
estimateJDE = nextJD
|
|
|
|
|
if math.Abs(nextJD-prevJDE) <= 0.00001 {
|
2026-08-06 12:00:56 +08:00
|
|
|
converged = true
|
2026-05-01 22:38:44 +08:00
|
|
|
break
|
|
|
|
|
}
|
|
|
|
|
}
|
2026-08-06 12:00:56 +08:00
|
|
|
if !converged {
|
|
|
|
|
return math.NaN()
|
|
|
|
|
}
|
2026-09-23 18:55:12 +08:00
|
|
|
return TT2UTC(estimateJDE)
|
2026-05-01 22:38:44 +08:00
|
|
|
}
|
|
|
|
|
|
2026-10-15 23:54:15 +08:00
|
|
|
func marsConjunction(jde, degree float64, next uint8, instances ...*Instance) float64 {
|
|
|
|
|
inst := instanceValue(instances)
|
|
|
|
|
|
2026-05-01 22:38:44 +08:00
|
|
|
//0=last 1=next
|
2026-08-06 12:00:56 +08:00
|
|
|
if !isFiniteFloat(jde) || !isFiniteFloat(degree) {
|
|
|
|
|
return math.NaN()
|
|
|
|
|
}
|
2026-05-01 22:38:44 +08:00
|
|
|
daysPerDegree := MARS_S_PERIOD / 360
|
2026-10-15 23:54:15 +08:00
|
|
|
currentDelta := marsSunLongitudeDelta(jde, degree, false, inst)
|
2026-05-01 22:38:44 +08:00
|
|
|
if next == 0 {
|
|
|
|
|
jde -= (360 - currentDelta) * daysPerDegree
|
|
|
|
|
} else {
|
|
|
|
|
jde += daysPerDegree * currentDelta
|
|
|
|
|
}
|
2026-09-23 18:55:12 +08:00
|
|
|
estimateJDE := jde
|
2026-08-06 12:00:56 +08:00
|
|
|
converged := false
|
|
|
|
|
for i := 0; i < eventNewtonMaxIterations; i++ {
|
2026-09-23 18:55:12 +08:00
|
|
|
prevJDE := estimateJDE
|
2026-10-15 23:54:15 +08:00
|
|
|
longitudeDelta := marsSunLongitudeDeltaN(prevJDE, degree, true, marsEventSearchN, inst)
|
|
|
|
|
longitudeSlope := (marsSunLongitudeDeltaN(prevJDE+0.000005, degree, true, marsEventSearchN, inst) - marsSunLongitudeDeltaN(prevJDE-0.000005, degree, true, marsEventSearchN, inst)) / 0.00001
|
2026-09-23 18:55:12 +08:00
|
|
|
nextJD := prevJDE - longitudeDelta/longitudeSlope
|
|
|
|
|
estimateJDE = nextJD
|
|
|
|
|
if math.Abs(nextJD-prevJDE) <= marsPhaseCoarseTolerance {
|
2026-08-06 12:00:56 +08:00
|
|
|
converged = true
|
2026-05-01 22:38:44 +08:00
|
|
|
break
|
|
|
|
|
}
|
|
|
|
|
}
|
2026-08-06 12:00:56 +08:00
|
|
|
if !converged {
|
|
|
|
|
return math.NaN()
|
|
|
|
|
}
|
|
|
|
|
converged = false
|
|
|
|
|
for i := 0; i < eventNewtonMaxIterations; i++ {
|
2026-09-23 18:55:12 +08:00
|
|
|
prevJDE := estimateJDE
|
2026-10-15 23:54:15 +08:00
|
|
|
longitudeDelta := marsSunLongitudeDelta(prevJDE, degree, true, inst)
|
|
|
|
|
longitudeSlope := (marsSunLongitudeDelta(prevJDE+0.000005, degree, true, inst) - marsSunLongitudeDelta(prevJDE-0.000005, degree, true, inst)) / 0.00001
|
2026-09-23 18:55:12 +08:00
|
|
|
nextJD := prevJDE - longitudeDelta/longitudeSlope
|
|
|
|
|
estimateJDE = nextJD
|
|
|
|
|
if math.Abs(nextJD-prevJDE) <= 0.00001 {
|
2026-08-06 12:00:56 +08:00
|
|
|
converged = true
|
2026-05-01 22:38:44 +08:00
|
|
|
break
|
|
|
|
|
}
|
|
|
|
|
}
|
2026-08-06 12:00:56 +08:00
|
|
|
if !converged {
|
|
|
|
|
return math.NaN()
|
|
|
|
|
}
|
2026-09-23 18:55:12 +08:00
|
|
|
return TT2UTC(estimateJDE)
|
2026-05-01 22:38:44 +08:00
|
|
|
}
|
|
|
|
|
|
2026-10-15 23:54:15 +08:00
|
|
|
// LastMarsConjunctionWithInstance 用指定星历实例求值;inst 为 nil 时用进程当前模型 / evaluation with an explicit instance; nil uses the process model.
|
|
|
|
|
func LastMarsConjunctionWithInstance(jde float64, inst *Instance) float64 {
|
|
|
|
|
return inclusiveLastPhaseEvent(jde, 0, func(jde, degree float64, next uint8) float64 {
|
|
|
|
|
return marsConjunction(jde, degree, next, inst)
|
|
|
|
|
})
|
2026-05-01 22:38:44 +08:00
|
|
|
}
|
|
|
|
|
|
2026-10-15 23:54:15 +08:00
|
|
|
// NextMarsConjunctionWithInstance 用指定星历实例求值;inst 为 nil 时用进程当前模型 / evaluation with an explicit instance; nil uses the process model.
|
|
|
|
|
func NextMarsConjunctionWithInstance(jde float64, inst *Instance) float64 {
|
|
|
|
|
return inclusiveNextPhaseEvent(jde, 0, func(jde, degree float64, next uint8) float64 {
|
|
|
|
|
return marsConjunction(jde, degree, next, inst)
|
|
|
|
|
})
|
2026-05-01 22:38:44 +08:00
|
|
|
}
|
|
|
|
|
|
2026-10-15 23:54:15 +08:00
|
|
|
// LastMarsOppositionWithInstance 用指定星历实例求值;inst 为 nil 时用进程当前模型 / evaluation with an explicit instance; nil uses the process model.
|
|
|
|
|
func LastMarsOppositionWithInstance(jde float64, inst *Instance) float64 {
|
|
|
|
|
return inclusiveLastPhaseEvent(jde, 180, func(jde, degree float64, next uint8) float64 {
|
|
|
|
|
return marsConjunction(jde, degree, next, inst)
|
|
|
|
|
})
|
2026-05-01 22:38:44 +08:00
|
|
|
}
|
|
|
|
|
|
2026-10-15 23:54:15 +08:00
|
|
|
// NextMarsOppositionWithInstance 用指定星历实例求值;inst 为 nil 时用进程当前模型 / evaluation with an explicit instance; nil uses the process model.
|
|
|
|
|
func NextMarsOppositionWithInstance(jde float64, inst *Instance) float64 {
|
|
|
|
|
return inclusiveNextPhaseEvent(jde, 180, func(jde, degree float64, next uint8) float64 {
|
|
|
|
|
return marsConjunction(jde, degree, next, inst)
|
|
|
|
|
})
|
2026-05-01 22:38:44 +08:00
|
|
|
}
|
|
|
|
|
|
2026-10-15 23:54:15 +08:00
|
|
|
// NextMarsEasternQuadratureWithInstance 用指定星历实例求值;inst 为 nil 时用进程当前模型 / evaluation with an explicit instance; nil uses the process model.
|
|
|
|
|
func NextMarsEasternQuadratureWithInstance(jde float64, inst *Instance) float64 {
|
|
|
|
|
return inclusiveNextPhaseEvent(jde, 90, func(jde, degree float64, next uint8) float64 {
|
|
|
|
|
return marsConjunction(jde, degree, next, inst)
|
|
|
|
|
})
|
2026-05-01 22:38:44 +08:00
|
|
|
}
|
|
|
|
|
|
2026-10-15 23:54:15 +08:00
|
|
|
// LastMarsEasternQuadratureWithInstance 用指定星历实例求值;inst 为 nil 时用进程当前模型 / evaluation with an explicit instance; nil uses the process model.
|
|
|
|
|
func LastMarsEasternQuadratureWithInstance(jde float64, inst *Instance) float64 {
|
|
|
|
|
return inclusiveLastPhaseEvent(jde, 90, func(jde, degree float64, next uint8) float64 {
|
|
|
|
|
return marsConjunction(jde, degree, next, inst)
|
|
|
|
|
})
|
2026-05-01 22:38:44 +08:00
|
|
|
}
|
|
|
|
|
|
2026-10-15 23:54:15 +08:00
|
|
|
// NextMarsWesternQuadratureWithInstance 用指定星历实例求值;inst 为 nil 时用进程当前模型 / evaluation with an explicit instance; nil uses the process model.
|
|
|
|
|
func NextMarsWesternQuadratureWithInstance(jde float64, inst *Instance) float64 {
|
|
|
|
|
return inclusiveNextPhaseEvent(jde, 270, func(jde, degree float64, next uint8) float64 {
|
|
|
|
|
return marsConjunction(jde, degree, next, inst)
|
|
|
|
|
})
|
2026-05-01 22:38:44 +08:00
|
|
|
}
|
|
|
|
|
|
2026-10-15 23:54:15 +08:00
|
|
|
// LastMarsWesternQuadratureWithInstance 用指定星历实例求值;inst 为 nil 时用进程当前模型 / evaluation with an explicit instance; nil uses the process model.
|
|
|
|
|
func LastMarsWesternQuadratureWithInstance(jde float64, inst *Instance) float64 {
|
|
|
|
|
return inclusiveLastPhaseEvent(jde, 270, func(jde, degree float64, next uint8) float64 {
|
|
|
|
|
return marsConjunction(jde, degree, next, inst)
|
|
|
|
|
})
|
2026-05-01 22:38:44 +08:00
|
|
|
}
|
|
|
|
|
|
2026-10-15 23:54:15 +08:00
|
|
|
func marsRetrogradeAroundOpposition(oppositionJD float64, searchBeforeOpposition bool, instances ...*Instance) float64 {
|
|
|
|
|
inst := instanceValue(instances)
|
|
|
|
|
|
2026-09-17 12:27:40 +08:00
|
|
|
if !isFiniteFloat(oppositionJD) {
|
|
|
|
|
return math.NaN()
|
|
|
|
|
}
|
2026-09-23 18:55:12 +08:00
|
|
|
oppositionTT := UTC2TT(oppositionJD)
|
2026-08-06 12:00:56 +08:00
|
|
|
startTT := oppositionTT
|
|
|
|
|
endTT := oppositionTT
|
2026-05-01 22:38:44 +08:00
|
|
|
if searchBeforeOpposition {
|
2026-10-15 23:54:15 +08:00
|
|
|
easternQuadratureUT := marsConjunction(oppositionTT, 90, 0, inst)
|
2026-09-23 18:55:12 +08:00
|
|
|
startTT = UTC2TT(easternQuadratureUT)
|
2026-05-01 22:38:44 +08:00
|
|
|
} else {
|
2026-10-15 23:54:15 +08:00
|
|
|
westernQuadratureUT := marsConjunction(oppositionTT, 270, 1, inst)
|
2026-09-23 18:55:12 +08:00
|
|
|
endTT = UTC2TT(westernQuadratureUT)
|
2026-05-01 22:38:44 +08:00
|
|
|
}
|
2026-09-23 18:55:12 +08:00
|
|
|
bestJDE := zeroEventInWindow(startTT, endTT, marsStationCoarseStepDay, marsStationHalfWindowDay, 30.0/86400.0, func(jd float64) float64 {
|
2026-10-15 23:54:15 +08:00
|
|
|
return marsRADerivativeN(jd, marsStationDerivativeStepDay, marsEventSearchN, inst)
|
2026-08-06 12:00:56 +08:00
|
|
|
}, func(jd float64) float64 {
|
2026-10-15 23:54:15 +08:00
|
|
|
return marsRADerivative(jd, marsStationDerivativeStepDay, inst)
|
2026-05-01 22:38:44 +08:00
|
|
|
})
|
2026-09-23 18:55:12 +08:00
|
|
|
return TT2UTC(bestJDE)
|
2026-05-01 22:38:44 +08:00
|
|
|
}
|
|
|
|
|
|
2026-10-15 23:54:15 +08:00
|
|
|
// NextMarsRetrogradeToProgradeWithInstance 用指定星历实例求值;inst 为 nil 时用进程当前模型 / evaluation with an explicit instance; nil uses the process model.
|
|
|
|
|
func NextMarsRetrogradeToProgradeWithInstance(jde float64, inst *Instance) float64 {
|
2026-09-17 12:27:40 +08:00
|
|
|
if !isFiniteFloat(jde) {
|
|
|
|
|
return math.NaN()
|
|
|
|
|
}
|
2026-10-15 23:54:15 +08:00
|
|
|
lastOppositionJD := marsConjunctionFull(jde, 180, 0, inst)
|
|
|
|
|
date := marsRetrogradeAroundOpposition(lastOppositionJD, false, inst)
|
2026-09-17 12:27:40 +08:00
|
|
|
if isFiniteFloat(date) && stationUTQueryAfterOrEqual(date, jde) {
|
2026-08-06 12:00:56 +08:00
|
|
|
return date
|
2026-05-01 22:38:44 +08:00
|
|
|
}
|
2026-10-15 23:54:15 +08:00
|
|
|
nextOppositionJD := marsConjunctionFull(jde, 180, 1, inst)
|
2026-09-17 12:27:40 +08:00
|
|
|
if !isFiniteFloat(nextOppositionJD) {
|
|
|
|
|
return math.NaN()
|
|
|
|
|
}
|
2026-10-15 23:54:15 +08:00
|
|
|
date = marsRetrogradeAroundOpposition(nextOppositionJD, false, inst)
|
2026-09-17 12:27:40 +08:00
|
|
|
if !isFiniteFloat(date) || !stationUTQueryAfterOrEqual(date, jde) {
|
|
|
|
|
return math.NaN()
|
|
|
|
|
}
|
|
|
|
|
return date
|
2026-05-01 22:38:44 +08:00
|
|
|
}
|
|
|
|
|
|
2026-10-15 23:54:15 +08:00
|
|
|
// LastMarsRetrogradeToProgradeWithInstance 用指定星历实例求值;inst 为 nil 时用进程当前模型 / evaluation with an explicit instance; nil uses the process model.
|
|
|
|
|
func LastMarsRetrogradeToProgradeWithInstance(jde float64, inst *Instance) float64 {
|
2026-09-17 12:27:40 +08:00
|
|
|
if !isFiniteFloat(jde) {
|
|
|
|
|
return math.NaN()
|
|
|
|
|
}
|
2026-10-15 23:54:15 +08:00
|
|
|
lastOppositionJD := marsConjunctionFull(jde, 180, 0, inst)
|
|
|
|
|
date := marsRetrogradeAroundOpposition(lastOppositionJD, false, inst)
|
2026-09-17 12:27:40 +08:00
|
|
|
if isFiniteFloat(date) && stationUTQueryBeforeOrEqual(date, jde) {
|
2026-08-06 12:00:56 +08:00
|
|
|
return date
|
2026-05-01 22:38:44 +08:00
|
|
|
}
|
2026-09-17 12:27:40 +08:00
|
|
|
if !isFiniteFloat(lastOppositionJD) {
|
|
|
|
|
return math.NaN()
|
|
|
|
|
}
|
2026-10-15 23:54:15 +08:00
|
|
|
previousOppositionJD := marsConjunctionFull(eventUTLastQueryTT(lastOppositionJD), 180, 0, inst)
|
2026-09-17 12:27:40 +08:00
|
|
|
if !isFiniteFloat(previousOppositionJD) {
|
|
|
|
|
return math.NaN()
|
|
|
|
|
}
|
2026-10-15 23:54:15 +08:00
|
|
|
date = marsRetrogradeAroundOpposition(previousOppositionJD, false, inst)
|
2026-09-17 12:27:40 +08:00
|
|
|
if !isFiniteFloat(date) || !stationUTQueryBeforeOrEqual(date, jde) {
|
|
|
|
|
return math.NaN()
|
|
|
|
|
}
|
|
|
|
|
return date
|
2026-05-01 22:38:44 +08:00
|
|
|
}
|
|
|
|
|
|
2026-10-15 23:54:15 +08:00
|
|
|
// NextMarsProgradeToRetrogradeWithInstance 用指定星历实例求值;inst 为 nil 时用进程当前模型 / evaluation with an explicit instance; nil uses the process model.
|
|
|
|
|
func NextMarsProgradeToRetrogradeWithInstance(jde float64, inst *Instance) float64 {
|
2026-09-17 12:27:40 +08:00
|
|
|
if !isFiniteFloat(jde) {
|
|
|
|
|
return math.NaN()
|
|
|
|
|
}
|
2026-10-15 23:54:15 +08:00
|
|
|
nextOppositionJD := marsConjunctionFull(jde, 180, 1, inst)
|
|
|
|
|
date := marsRetrogradeAroundOpposition(nextOppositionJD, true, inst)
|
2026-09-17 12:27:40 +08:00
|
|
|
if isFiniteFloat(date) && stationUTQueryAfterOrEqual(date, jde) {
|
2026-08-06 12:00:56 +08:00
|
|
|
return date
|
2026-05-01 22:38:44 +08:00
|
|
|
}
|
2026-09-17 12:27:40 +08:00
|
|
|
if !isFiniteFloat(nextOppositionJD) {
|
|
|
|
|
return math.NaN()
|
|
|
|
|
}
|
2026-10-15 23:54:15 +08:00
|
|
|
followingOppositionJD := marsConjunctionFull(eventUTNextQueryTT(nextOppositionJD), 180, 1, inst)
|
2026-09-17 12:27:40 +08:00
|
|
|
if !isFiniteFloat(followingOppositionJD) {
|
|
|
|
|
return math.NaN()
|
|
|
|
|
}
|
2026-10-15 23:54:15 +08:00
|
|
|
date = marsRetrogradeAroundOpposition(followingOppositionJD, true, inst)
|
2026-09-17 12:27:40 +08:00
|
|
|
if !isFiniteFloat(date) || !stationUTQueryAfterOrEqual(date, jde) {
|
|
|
|
|
return math.NaN()
|
|
|
|
|
}
|
|
|
|
|
return date
|
2026-05-01 22:38:44 +08:00
|
|
|
}
|
|
|
|
|
|
2026-10-15 23:54:15 +08:00
|
|
|
// LastMarsProgradeToRetrogradeWithInstance 用指定星历实例求值;inst 为 nil 时用进程当前模型 / evaluation with an explicit instance; nil uses the process model.
|
|
|
|
|
func LastMarsProgradeToRetrogradeWithInstance(jde float64, inst *Instance) float64 {
|
2026-09-17 12:27:40 +08:00
|
|
|
if !isFiniteFloat(jde) {
|
|
|
|
|
return math.NaN()
|
|
|
|
|
}
|
2026-10-15 23:54:15 +08:00
|
|
|
nextOppositionJD := marsConjunctionFull(jde, 180, 1, inst)
|
|
|
|
|
date := marsRetrogradeAroundOpposition(nextOppositionJD, true, inst)
|
2026-09-17 12:27:40 +08:00
|
|
|
if isFiniteFloat(date) && stationUTQueryBeforeOrEqual(date, jde) {
|
2026-08-06 12:00:56 +08:00
|
|
|
return date
|
2026-05-01 22:38:44 +08:00
|
|
|
}
|
2026-09-17 12:27:40 +08:00
|
|
|
if !isFiniteFloat(nextOppositionJD) {
|
|
|
|
|
return math.NaN()
|
|
|
|
|
}
|
2026-10-15 23:54:15 +08:00
|
|
|
lastOppositionJD := marsConjunctionFull(jde, 180, 0, inst)
|
2026-09-17 12:27:40 +08:00
|
|
|
if !isFiniteFloat(lastOppositionJD) {
|
|
|
|
|
return math.NaN()
|
|
|
|
|
}
|
2026-10-15 23:54:15 +08:00
|
|
|
date = marsRetrogradeAroundOpposition(lastOppositionJD, true, inst)
|
2026-09-17 12:27:40 +08:00
|
|
|
if !isFiniteFloat(date) || !stationUTQueryBeforeOrEqual(date, jde) {
|
|
|
|
|
return math.NaN()
|
|
|
|
|
}
|
|
|
|
|
return date
|
2026-05-01 22:38:44 +08:00
|
|
|
}
|