16c62a97d5
- 新增时标、ΔT 模型、质心时间与 UT1 支持 - 改进日月食、月掩、行星事件及路径边界计算 - 完善恒星三维自行与动态距离传播 - 扩展 SVG、GeoJSON、KML 输出与底层距离换算工具 - 整理中英文手册、示例资源及回归测试
193 lines
5.6 KiB
Go
193 lines
5.6 KiB
Go
package basic
|
|
|
|
import (
|
|
"math"
|
|
|
|
"b612.me/astro/planet"
|
|
. "b612.me/astro/tools"
|
|
)
|
|
|
|
func SaturnL(jde float64) float64 {
|
|
return planet.WherePlanet(5, 0, jde)
|
|
}
|
|
|
|
func SaturnB(jde float64) float64 {
|
|
return planet.WherePlanet(5, 1, jde)
|
|
}
|
|
func SaturnR(jde float64) float64 {
|
|
return planet.WherePlanet(5, 2, jde)
|
|
}
|
|
func ASaturnX(jde float64) float64 {
|
|
l := SaturnL(jde)
|
|
b := SaturnB(jde)
|
|
r := SaturnR(jde)
|
|
el := planet.WherePlanet(-1, 0, jde)
|
|
eb := planet.WherePlanet(-1, 1, jde)
|
|
er := planet.WherePlanet(-1, 2, jde)
|
|
x := r*Cos(b)*Cos(l) - er*Cos(eb)*Cos(el)
|
|
return x
|
|
}
|
|
|
|
func ASaturnY(jde float64) float64 {
|
|
|
|
l := SaturnL(jde)
|
|
b := SaturnB(jde)
|
|
r := SaturnR(jde)
|
|
el := planet.WherePlanet(-1, 0, jde)
|
|
eb := planet.WherePlanet(-1, 1, jde)
|
|
er := planet.WherePlanet(-1, 2, jde)
|
|
y := r*Cos(b)*Sin(l) - er*Cos(eb)*Sin(el)
|
|
return y
|
|
}
|
|
func ASaturnZ(jde float64) float64 {
|
|
//l := SaturnL(jde)
|
|
b := SaturnB(jde)
|
|
r := SaturnR(jde)
|
|
// el := planet.WherePlanet(-1, 0, jde)
|
|
eb := planet.WherePlanet(-1, 1, jde)
|
|
er := planet.WherePlanet(-1, 2, jde)
|
|
z := r*Sin(b) - er*Sin(eb)
|
|
return z
|
|
}
|
|
|
|
func ASaturnXYZ(jde float64) (float64, float64, float64) {
|
|
l := SaturnL(jde)
|
|
b := SaturnB(jde)
|
|
r := SaturnR(jde)
|
|
el := planet.WherePlanet(-1, 0, jde)
|
|
eb := planet.WherePlanet(-1, 1, jde)
|
|
er := planet.WherePlanet(-1, 2, jde)
|
|
x := r*Cos(b)*Cos(l) - er*Cos(eb)*Cos(el)
|
|
y := r*Cos(b)*Sin(l) - er*Cos(eb)*Sin(el)
|
|
z := r*Sin(b) - er*Sin(eb)
|
|
return x, y, z
|
|
}
|
|
|
|
func SaturnApparentRa(jde float64) float64 {
|
|
lo, bo := SaturnApparentLoBo(jde)
|
|
eps := TrueObliquity(jde)
|
|
ra := math.Atan2((Sin(lo)*Cos(eps) - Tan(bo)*Sin(eps)), Cos(lo))
|
|
ra = ra * 180 / math.Pi
|
|
return Limit360(ra)
|
|
}
|
|
func SaturnApparentDec(jde float64) float64 {
|
|
lo, bo := SaturnApparentLoBo(jde)
|
|
eps := TrueObliquity(jde)
|
|
dec := ArcSin(Sin(bo)*Cos(eps) + Cos(bo)*Sin(eps)*Sin(lo))
|
|
return dec
|
|
}
|
|
|
|
func SaturnApparentRaDec(jde float64) (float64, float64) {
|
|
lo, bo := SaturnApparentLoBo(jde)
|
|
eps := TrueObliquity(jde)
|
|
ra := math.Atan2((Sin(lo)*Cos(eps) - Tan(bo)*Sin(eps)), Cos(lo))
|
|
ra = ra * 180 / math.Pi
|
|
dec := ArcSin(Sin(bo)*Cos(eps) + Cos(bo)*Sin(eps)*Sin(lo))
|
|
return Limit360(ra), dec
|
|
}
|
|
|
|
func EarthSaturnAway(jd float64) float64 {
|
|
return planetEarthAwayExplicitN(5, jd, -1)
|
|
}
|
|
|
|
func SaturnApparentLo(jd float64) float64 {
|
|
geo, _ := planetApparentGeocentricPositionN(5, jd, -1)
|
|
return geo.lo
|
|
}
|
|
|
|
func SaturnApparentBo(jd float64) float64 {
|
|
geo, _ := planetApparentGeocentricPositionN(5, jd, -1)
|
|
return geo.bo
|
|
}
|
|
|
|
func SaturnApparentLoBo(jd float64) (float64, float64) {
|
|
geo, _ := planetApparentGeocentricPositionN(5, jd, -1)
|
|
return geo.lo, geo.bo
|
|
}
|
|
|
|
func SaturnMag(jde float64) float64 {
|
|
return SaturnMagN(jde, -1)
|
|
}
|
|
|
|
func SaturnHeight(localJD, lon, lat, timezone float64) float64 {
|
|
// 转换为世界时
|
|
utcJD := localJD - timezone/24.0
|
|
// 计算视恒星时
|
|
ra, dec := SaturnApparentRaDec(UTC2TT(utcJD))
|
|
st := Limit360(ApparentSiderealTime(UTC2UT1(utcJD))*15 + lon)
|
|
// 计算时角
|
|
hourAngle := Limit360(st - ra)
|
|
// 高度角、时角与天球座标三角转换公式
|
|
// sin(h)=sin(lat)*sin(dec)+cos(dec)*cos(lat)*cos(hourAngle)
|
|
sinHeight := Sin(lat)*Sin(dec) + Cos(dec)*Cos(lat)*Cos(hourAngle)
|
|
return ArcSin(sinHeight)
|
|
}
|
|
|
|
func SaturnAzimuth(localJD, lon, lat, timezone float64) float64 {
|
|
// 转换为世界时
|
|
utcJD := localJD - timezone/24.0
|
|
// 计算视恒星时
|
|
ra, dec := SaturnApparentRaDec(UTC2TT(utcJD))
|
|
st := Limit360(ApparentSiderealTime(UTC2UT1(utcJD))*15 + lon)
|
|
// 计算时角
|
|
hourAngle := Limit360(st - ra)
|
|
// 三角转换公式
|
|
tanAzimuth := Sin(hourAngle) / (Cos(hourAngle)*Sin(lat) - Tan(dec)*Cos(lat))
|
|
azimuth := ArcTan(tanAzimuth)
|
|
if azimuth < 0 {
|
|
if hourAngle/15 < 12 {
|
|
return azimuth + 360
|
|
}
|
|
return azimuth + 180
|
|
}
|
|
if hourAngle/15 < 12 {
|
|
return azimuth + 180
|
|
}
|
|
return azimuth
|
|
}
|
|
|
|
func SaturnHourAngle(jd, lon, timezone float64) float64 {
|
|
siderealLongitude := Limit360(ApparentSiderealTime(UTC2UT1(jd-timezone/24))*15 + lon)
|
|
hourAngle := siderealLongitude - SaturnApparentRa(UTC2TT(jd-timezone/24.0))
|
|
if hourAngle < 0 {
|
|
hourAngle += 360
|
|
}
|
|
return hourAngle
|
|
}
|
|
|
|
func SaturnCulminationTime(localJD, lon, timezone float64) float64 {
|
|
// localJD 是本地民用日锚点(当地 0 时),不是力学时。
|
|
//ra,dec 瞬时天球座标,非J2000等时间天球坐标
|
|
localJD = math.Floor(localJD) + 0.5
|
|
estimateJD := localJD + Limit360(360-SaturnHourAngle(localJD, lon, timezone))/15.0/24.0*0.99726851851851851851
|
|
normalizedHourAngle := func(localJD, lon, timezone float64) float64 {
|
|
currentHourAngle := SaturnHourAngle(localJD, lon, timezone)
|
|
if currentHourAngle < 180 {
|
|
currentHourAngle += 360
|
|
}
|
|
return currentHourAngle
|
|
}
|
|
var ok bool
|
|
estimateJD, ok = eventNewtonRefine(estimateJD, 0.00001, func(prevJD float64) float64 {
|
|
hourAngleDelta := normalizedHourAngle(prevJD, lon, timezone) - 360
|
|
hourAngleSlope := (normalizedHourAngle(prevJD+0.000005, lon, timezone) - normalizedHourAngle(prevJD-0.000005, lon, timezone)) / 0.00001
|
|
return hourAngleDelta / hourAngleSlope
|
|
})
|
|
if !ok {
|
|
return math.NaN()
|
|
}
|
|
return estimateJD
|
|
}
|
|
|
|
func SaturnRiseTime(jd, lon, lat, timezone, aeroCorrection, observerHeight float64) (float64, error) {
|
|
return saturnRiseDown(jd, lon, lat, timezone, aeroCorrection, observerHeight, true)
|
|
}
|
|
|
|
func SaturnSetTime(jd, lon, lat, timezone, aeroCorrection, observerHeight float64) (float64, error) {
|
|
return saturnRiseDown(jd, lon, lat, timezone, aeroCorrection, observerHeight, false)
|
|
}
|
|
|
|
func saturnRiseDown(jd, lon, lat, timezone, aeroCorrection, observerHeight float64, isRise bool) (float64, error) {
|
|
return planetRiseDown(jd, lon, lat, timezone, aeroCorrection, observerHeight, isRise, SaturnCulminationTime, SaturnHeight, SaturnApparentDec)
|
|
}
|