Files
astro/moon/apsis.go
T

37 lines
1.1 KiB
Go
Raw Normal View History

2026-05-01 22:38:44 +08:00
package moon
import (
"time"
"b612.me/astro/basic"
)
// ApsisInfo 轨道极值事件 / orbital distance extremum event.
type ApsisInfo struct {
// Time 事件时刻,UTC / event time in UTC.
Time time.Time
// Distance 极值距离,单位 km / extremum distance in km.
Distance float64
}
// PerigeesInMonth 指定年月内的所有月球近地点 / all lunar perigees in the given Gregorian month.
func (module *Moon) PerigeesInMonth(year int, month time.Month) []ApsisInfo {
return convertMoonApsisInfos(basic.MoonPerigeesWithInstance(year, month, module.inst))
2026-05-01 22:38:44 +08:00
}
// ApogeesInMonth 指定年月内的所有月球远地点 / all lunar apogees in the given Gregorian month.
func (module *Moon) ApogeesInMonth(year int, month time.Month) []ApsisInfo {
return convertMoonApsisInfos(basic.MoonApogeesWithInstance(year, month, module.inst))
2026-05-01 22:38:44 +08:00
}
func convertMoonApsisInfos(events []basic.ApsisEvent) []ApsisInfo {
result := make([]ApsisInfo, 0, len(events))
for _, event := range events {
result = append(result, ApsisInfo{
Time: basic.JD2DateByZone(event.JD, time.UTC, false),
2026-05-01 22:38:44 +08:00
Distance: event.Distance,
})
}
return result
}