2026-05-01 22:38:44 +08:00
|
|
|
package basic
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
|
"math"
|
|
|
|
|
|
2026-10-15 23:54:15 +08:00
|
|
|
"b612.me/astro/internal/ephem"
|
|
|
|
|
"b612.me/astro/planet"
|
2026-05-01 22:38:44 +08:00
|
|
|
. "b612.me/astro/tools"
|
|
|
|
|
)
|
|
|
|
|
|
2026-10-15 23:54:15 +08:00
|
|
|
// GetMoonCir 返回旧月球级数系数的独立副本 / an independent copy of the legacy lunar-series coefficients.
|
|
|
|
|
func GetMoonCir() [][][]float64 { return planet.GetMoonCir() }
|
2026-05-01 22:38:44 +08:00
|
|
|
|
|
|
|
|
func MoonCalcNew(coordIndex int, jd float64) float64 {
|
|
|
|
|
return MoonCalcNewN(coordIndex, jd, -1)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func MoonCalcNewN(coordIndex int, jd float64, n int) float64 {
|
2026-10-15 23:54:15 +08:00
|
|
|
return planet.WhereMoonN(coordIndex, jd, n)
|
2026-09-17 12:27:40 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func moonCalcNewN(coordIndex int, jd float64, n int) float64 {
|
2026-10-15 23:54:15 +08:00
|
|
|
return planet.WhereMoonN(coordIndex, jd, n)
|
2026-09-17 12:27:40 +08:00
|
|
|
}
|
|
|
|
|
|
2026-09-23 18:55:12 +08:00
|
|
|
func HMoonTrueLo(jde float64) float64 { //计算月亮
|
|
|
|
|
return HMoonTrueLoN(jde, -1)
|
2026-05-01 22:38:44 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func HMoonTrueLoN(jd float64, n int) float64 { //计算月亮
|
2026-09-17 12:27:40 +08:00
|
|
|
v := moonCalcNewN(0, jd, n) * 180 / math.Pi
|
2026-05-01 22:38:44 +08:00
|
|
|
return Limit360(v)
|
|
|
|
|
}
|
|
|
|
|
|
2026-09-23 18:55:12 +08:00
|
|
|
func HMoonTrueBo(jde float64) float64 {
|
|
|
|
|
return HMoonTrueBoN(jde, -1)
|
2026-05-01 22:38:44 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func HMoonTrueBoN(jd float64, n int) float64 {
|
|
|
|
|
v := MoonCalcNewN(1, jd, n) * 180 / math.Pi
|
|
|
|
|
return v
|
|
|
|
|
}
|
|
|
|
|
|
2026-09-23 18:55:12 +08:00
|
|
|
func HMoonAway(jde float64) float64 { //'月地距离
|
|
|
|
|
return HMoonAwayN(jde, -1)
|
2026-05-01 22:38:44 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func HMoonAwayN(jd float64, n int) float64 { //'月地距离
|
|
|
|
|
return MoonCalcNewN(2, jd, n)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* @name 月球视黄经
|
|
|
|
|
*/
|
2026-09-23 18:55:12 +08:00
|
|
|
func HMoonApparentLo(jde float64) float64 {
|
|
|
|
|
return HMoonApparentLoN(jde, -1)
|
2026-05-01 22:38:44 +08:00
|
|
|
}
|
|
|
|
|
|
2026-09-23 18:55:12 +08:00
|
|
|
func HMoonApparentLoN(jde float64, n int) float64 {
|
2026-10-15 23:54:15 +08:00
|
|
|
if lo, _, _, _, ok := vectorApparent(ephem.Moon, jde, n); ok {
|
|
|
|
|
return lo
|
|
|
|
|
}
|
2026-09-23 18:55:12 +08:00
|
|
|
return HMoonTrueLoN(jde, n) + Nutation2000Bi(jde)
|
2026-05-01 22:38:44 +08:00
|
|
|
}
|
|
|
|
|
|
2026-10-15 23:54:15 +08:00
|
|
|
// HMoonGeocentricApparentRaWithInstance 用指定星历实例求值;inst 为 nil 时用进程当前模型 / evaluation with an explicit instance; nil uses the process model.
|
|
|
|
|
func HMoonGeocentricApparentRaWithInstance(jde float64, inst *Instance) float64 {
|
|
|
|
|
return HMoonGeocentricApparentRaNWithInstance(jde, -1, inst)
|
2026-05-23 19:00:53 +08:00
|
|
|
}
|
|
|
|
|
|
2026-10-15 23:54:15 +08:00
|
|
|
// HMoonGeocentricApparentRaNWithInstance 用指定星历实例求值;inst 为 nil 时用进程当前模型 / evaluation with an explicit instance; nil uses the process model.
|
|
|
|
|
func HMoonGeocentricApparentRaNWithInstance(jde float64, n int, inst *Instance) float64 {
|
|
|
|
|
return moonApparentRaN(jde, n, inst)
|
2026-05-23 19:00:53 +08:00
|
|
|
}
|
|
|
|
|
|
2026-10-15 23:54:15 +08:00
|
|
|
// HMoonGeocentricApparentDecWithInstance 用指定星历实例求值;inst 为 nil 时用进程当前模型 / evaluation with an explicit instance; nil uses the process model.
|
|
|
|
|
func HMoonGeocentricApparentDecWithInstance(jde float64, inst *Instance) float64 {
|
|
|
|
|
return HMoonGeocentricApparentDecNWithInstance(jde, -1, inst)
|
2026-05-23 19:00:53 +08:00
|
|
|
}
|
|
|
|
|
|
2026-10-15 23:54:15 +08:00
|
|
|
// HMoonGeocentricApparentDecNWithInstance 用指定星历实例求值;inst 为 nil 时用进程当前模型 / evaluation with an explicit instance; nil uses the process model.
|
|
|
|
|
func HMoonGeocentricApparentDecNWithInstance(jde float64, n int, inst *Instance) float64 {
|
|
|
|
|
_, dec := moonApparentRaDecN(jde, n, inst)
|
|
|
|
|
return dec
|
2026-05-23 19:00:53 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// HMoonGeocentricApparentRaDec 月亮地心视赤经、视赤纬 / apparent geocentric right ascension and declination of the Moon.
|
2026-09-23 18:55:12 +08:00
|
|
|
func HMoonGeocentricApparentRaDec(jde float64) (float64, float64) {
|
|
|
|
|
return HMoonGeocentricApparentRaDecN(jde, -1)
|
2026-05-23 19:00:53 +08:00
|
|
|
}
|
|
|
|
|
|
2026-10-15 23:54:15 +08:00
|
|
|
// HMoonGeocentricApparentRaDecN 月亮地心视赤经、视赤纬(n 变体) / n-parameterised apparent geocentric right ascension and declination of the Moon.
|
2026-09-23 18:55:12 +08:00
|
|
|
func HMoonGeocentricApparentRaDecN(jde float64, n int) (float64, float64) {
|
2026-10-15 23:54:15 +08:00
|
|
|
return moonApparentRaDecN(jde, n, nil)
|
2026-05-23 19:00:53 +08:00
|
|
|
}
|
|
|
|
|
|
2026-10-15 23:54:15 +08:00
|
|
|
// HMoonGeocentricTrueRaWithInstance 用指定星历实例求值;inst 为 nil 时用进程当前模型 / evaluation with an explicit instance; nil uses the process model.
|
|
|
|
|
func HMoonGeocentricTrueRaWithInstance(jde float64, inst *Instance) float64 {
|
|
|
|
|
return HMoonGeocentricTrueRaNWithInstance(jde, -1, inst)
|
2026-05-23 19:00:53 +08:00
|
|
|
}
|
|
|
|
|
|
2026-10-15 23:54:15 +08:00
|
|
|
// HMoonGeocentricTrueRaNWithInstance 用指定星历实例求值;inst 为 nil 时用进程当前模型 / evaluation with an explicit instance; nil uses the process model.
|
|
|
|
|
func HMoonGeocentricTrueRaNWithInstance(jde float64, n int, inst *Instance) float64 {
|
|
|
|
|
return LoToRa(jde, HMoonTrueLoNWithInstance(jde, n, inst), HMoonTrueBoNWithInstance(jde, n, inst))
|
2026-05-23 19:00:53 +08:00
|
|
|
}
|
|
|
|
|
|
2026-10-15 23:54:15 +08:00
|
|
|
// HMoonGeocentricTrueDecWithInstance 用指定星历实例求值;inst 为 nil 时用进程当前模型 / evaluation with an explicit instance; nil uses the process model.
|
|
|
|
|
func HMoonGeocentricTrueDecWithInstance(jde float64, inst *Instance) float64 {
|
|
|
|
|
return HMoonGeocentricTrueDecNWithInstance(jde, -1, inst)
|
2026-05-23 19:00:53 +08:00
|
|
|
}
|
|
|
|
|
|
2026-10-15 23:54:15 +08:00
|
|
|
// HMoonGeocentricTrueDecNWithInstance 用指定星历实例求值;inst 为 nil 时用进程当前模型 / evaluation with an explicit instance; nil uses the process model.
|
|
|
|
|
func HMoonGeocentricTrueDecNWithInstance(jde float64, n int, inst *Instance) float64 {
|
|
|
|
|
return ArcSin(Sin(HMoonTrueBoNWithInstance(jde, n, inst))*Cos(TrueObliquity(jde)) +
|
|
|
|
|
Cos(HMoonTrueBoNWithInstance(jde, n, inst))*Sin(TrueObliquity(jde))*Sin(HMoonTrueLoNWithInstance(jde, n, inst)))
|
2026-05-23 19:00:53 +08:00
|
|
|
}
|
|
|
|
|
|
2026-10-15 23:54:15 +08:00
|
|
|
// HMoonGeocentricTrueRaDecWithInstance 用指定星历实例求值;inst 为 nil 时用进程当前模型 / evaluation with an explicit instance; nil uses the process model.
|
|
|
|
|
func HMoonGeocentricTrueRaDecWithInstance(jde float64, inst *Instance) (float64, float64) {
|
|
|
|
|
return HMoonGeocentricTrueRaDecNWithInstance(jde, -1, inst)
|
2026-05-23 19:00:53 +08:00
|
|
|
}
|
|
|
|
|
|
2026-10-15 23:54:15 +08:00
|
|
|
// HMoonGeocentricTrueRaDecNWithInstance 用指定星历实例求值;inst 为 nil 时用进程当前模型 / evaluation with an explicit instance; nil uses the process model.
|
|
|
|
|
func HMoonGeocentricTrueRaDecNWithInstance(jde float64, n int, inst *Instance) (float64, float64) {
|
|
|
|
|
return LoBoToRaDec(jde, HMoonTrueLoNWithInstance(jde, n, inst), HMoonTrueBoNWithInstance(jde, n, inst))
|
2026-05-23 19:00:53 +08:00
|
|
|
}
|
|
|
|
|
|
2026-09-23 18:55:12 +08:00
|
|
|
func HMoonTrueRaDec(jde float64) (float64, float64) {
|
|
|
|
|
return HMoonTrueRaDecN(jde, -1)
|
2026-05-01 22:38:44 +08:00
|
|
|
}
|
|
|
|
|
|
2026-10-15 23:54:15 +08:00
|
|
|
// HMoonTrueRaDecNWithInstance 用指定星历实例求值;inst 为 nil 时用进程当前模型 / evaluation with an explicit instance; nil uses the process model.
|
|
|
|
|
func HMoonTrueRaDecNWithInstance(jde float64, n int, inst *Instance) (float64, float64) {
|
|
|
|
|
return moonApparentRaDecN(jde, n, inst)
|
2026-05-01 22:38:44 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* 月球真赤纬
|
|
|
|
|
*/
|
2026-09-23 18:55:12 +08:00
|
|
|
func HMoonTrueDec(jde float64) float64 {
|
|
|
|
|
return HMoonTrueDecN(jde, -1)
|
2026-05-01 22:38:44 +08:00
|
|
|
}
|
|
|
|
|
|
2026-10-15 23:54:15 +08:00
|
|
|
// HMoonTrueDecNWithInstance 用指定星历实例求值;inst 为 nil 时用进程当前模型 / evaluation with an explicit instance; nil uses the process model.
|
|
|
|
|
func HMoonTrueDecNWithInstance(jde float64, n int, inst *Instance) float64 {
|
|
|
|
|
_, dec := moonApparentRaDecN(jde, n, inst)
|
|
|
|
|
return dec
|
2026-05-01 22:38:44 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* 月球真赤经
|
|
|
|
|
*/
|
2026-09-23 18:55:12 +08:00
|
|
|
func HMoonTrueRa(jde float64) float64 {
|
|
|
|
|
return HMoonTrueRaN(jde, -1)
|
2026-05-01 22:38:44 +08:00
|
|
|
}
|
|
|
|
|
|
2026-10-15 23:54:15 +08:00
|
|
|
// HMoonTrueRaNWithInstance 用指定星历实例求值;inst 为 nil 时用进程当前模型 / evaluation with an explicit instance; nil uses the process model.
|
|
|
|
|
func HMoonTrueRaNWithInstance(jde float64, n int, inst *Instance) float64 {
|
|
|
|
|
return moonApparentRaN(jde, n, inst)
|
2026-05-01 22:38:44 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*
|
2026-09-17 12:27:40 +08:00
|
|
|
* HMoonApparentRaDec 本地民用时下的月球视赤道坐标;jd 是本地民用时(内部按 jd-tz/24 换算 UT),不是世界时
|
|
|
|
|
*/
|
2026-05-01 22:38:44 +08:00
|
|
|
func HMoonApparentRaDec(jd, lon, lat, tz float64) (float64, float64) {
|
|
|
|
|
return HMoonApparentRaDecN(jd, lon, lat, tz, -1)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func HMoonApparentRaDecN(jd, lon, lat, tz float64, n int) (float64, float64) {
|
2026-09-23 18:55:12 +08:00
|
|
|
jde := UTC2TT(jd)
|
2026-05-01 22:38:44 +08:00
|
|
|
ra := HMoonTrueRaN(jde-tz/24, n)
|
|
|
|
|
dec := HMoonTrueDecN(jde-tz/24, n)
|
|
|
|
|
away := HMoonAwayN(jde-tz/24, n) / 149597870.7
|
|
|
|
|
topoRA, topoDec := TopocentricRaDec(ra, dec, lat, lon, jd-tz/24, away, 0)
|
|
|
|
|
return topoRA, topoDec
|
|
|
|
|
}
|
|
|
|
|
|
2026-10-15 23:54:15 +08:00
|
|
|
// HMoonApparentRaWithInstance 用指定星历实例求值;inst 为 nil 时用进程当前模型 / evaluation with an explicit instance; nil uses the process model.
|
|
|
|
|
func HMoonApparentRaWithInstance(jd, lon, lat, tz float64, inst *Instance) float64 {
|
|
|
|
|
return HMoonApparentRaNWithInstance(jd, lon, lat, tz, -1, inst)
|
2026-05-01 22:38:44 +08:00
|
|
|
}
|
|
|
|
|
|
2026-10-15 23:54:15 +08:00
|
|
|
// HMoonApparentRaNWithInstance 用指定星历实例求值;inst 为 nil 时用进程当前模型 / evaluation with an explicit instance; nil uses the process model.
|
|
|
|
|
func HMoonApparentRaNWithInstance(jd, lon, lat, tz float64, n int, inst *Instance) float64 {
|
2026-09-23 18:55:12 +08:00
|
|
|
jde := UTC2TT(jd) - tz/24
|
2026-10-15 23:54:15 +08:00
|
|
|
ra := HMoonTrueRaNWithInstance(jde, n, inst)
|
|
|
|
|
dec := HMoonTrueDecNWithInstance(jde, n, inst)
|
|
|
|
|
away := HMoonAwayNWithInstance(jde, n, inst) / 149597870.7
|
2026-05-01 22:38:44 +08:00
|
|
|
topoRA := TopocentricRa(ra, dec, lat, lon, jd-tz/24, away, 0)
|
|
|
|
|
return topoRA
|
|
|
|
|
}
|
2026-10-15 23:54:15 +08:00
|
|
|
|
|
|
|
|
// HMoonApparentDecWithInstance 用指定星历实例求值;inst 为 nil 时用进程当前模型 / evaluation with an explicit instance; nil uses the process model.
|
|
|
|
|
func HMoonApparentDecWithInstance(jd, lon, lat, tz float64, inst *Instance) float64 {
|
|
|
|
|
return HMoonApparentDecNWithInstance(jd, lon, lat, tz, -1, inst)
|
2026-05-01 22:38:44 +08:00
|
|
|
}
|
|
|
|
|
|
2026-10-15 23:54:15 +08:00
|
|
|
// HMoonApparentDecNWithInstance 用指定星历实例求值;inst 为 nil 时用进程当前模型 / evaluation with an explicit instance; nil uses the process model.
|
|
|
|
|
func HMoonApparentDecNWithInstance(jd, lon, lat, tz float64, n int, inst *Instance) float64 {
|
2026-09-23 18:55:12 +08:00
|
|
|
jde := UTC2TT(jd) - tz/24
|
2026-10-15 23:54:15 +08:00
|
|
|
ra := HMoonTrueRaNWithInstance(jde, n, inst)
|
|
|
|
|
dec := HMoonTrueDecNWithInstance(jde, n, inst)
|
|
|
|
|
away := HMoonAwayNWithInstance(jde, n, inst) / 149597870.7
|
2026-05-01 22:38:44 +08:00
|
|
|
topoDec := TopocentricDec(ra, dec, lat, lon, jd-tz/24, away, 0)
|
|
|
|
|
return topoDec
|
|
|
|
|
}
|