package basic import ( "math" "b612.me/astro/planet" . "b612.me/astro/tools" ) func NeptuneL(jde float64) float64 { return planet.WherePlanet(7, 0, jde) } func NeptuneB(jde float64) float64 { return planet.WherePlanet(7, 1, jde) } func NeptuneR(jde float64) float64 { return planet.WherePlanet(7, 2, jde) } func ANeptuneX(jde float64) float64 { l := NeptuneL(jde) b := NeptuneB(jde) r := NeptuneR(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 ANeptuneY(jde float64) float64 { l := NeptuneL(jde) b := NeptuneB(jde) r := NeptuneR(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 ANeptuneZ(jde float64) float64 { //l := NeptuneL(jde) b := NeptuneB(jde) r := NeptuneR(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 ANeptuneXYZ(jde float64) (float64, float64, float64) { l := NeptuneL(jde) b := NeptuneB(jde) r := NeptuneR(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 NeptuneApparentRa(jde float64) float64 { lo, bo := NeptuneApparentLoBo(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 NeptuneApparentDec(jde float64) float64 { lo, bo := NeptuneApparentLoBo(jde) eps := TrueObliquity(jde) dec := ArcSin(Sin(bo)*Cos(eps) + Cos(bo)*Sin(eps)*Sin(lo)) return dec } func NeptuneApparentRaDec(jde float64) (float64, float64) { lo, bo := NeptuneApparentLoBo(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 EarthNeptuneAway(jd float64) float64 { return planetEarthAwayExplicitN(7, jd, -1) } func NeptuneApparentLo(jd float64) float64 { geo, _ := planetApparentGeocentricPositionN(7, jd, -1) return geo.lo } func NeptuneApparentBo(jd float64) float64 { geo, _ := planetApparentGeocentricPositionN(7, jd, -1) return geo.bo } func NeptuneApparentLoBo(jd float64) (float64, float64) { geo, _ := planetApparentGeocentricPositionN(7, jd, -1) return geo.lo, geo.bo } func NeptuneMag(jde float64) float64 { sunDistance := NeptuneR(jde) earthDistance := EarthNeptuneAway(jde) earthSunDistance := planet.WherePlanet(-1, 2, jde) i := (sunDistance*sunDistance + earthDistance*earthDistance - earthSunDistance*earthSunDistance) / (2 * sunDistance * earthDistance) i = ArcCos(i) mag := -6.87 + 5*math.Log10(sunDistance*earthDistance) return FloatRound(mag, 2) } // NeptuneHeightWithInstance 用指定星历实例求值;inst 为 nil 时用进程当前模型 / evaluation with an explicit instance; nil uses the process model. func NeptuneHeightWithInstance(localJD, lon, lat, timezone float64, inst *Instance) float64 { return planetHeightN(7, localJD, lon, lat, timezone, -1, inst) } // NeptuneAzimuthWithInstance 用指定星历实例求值;inst 为 nil 时用进程当前模型 / evaluation with an explicit instance; nil uses the process model. func NeptuneAzimuthWithInstance(localJD, lon, lat, timezone float64, inst *Instance) float64 { return planetAzimuthN(7, localJD, lon, lat, timezone, -1, inst) } // NeptuneHourAngleWithInstance 用指定星历实例求值;inst 为 nil 时用进程当前模型 / evaluation with an explicit instance; nil uses the process model. func NeptuneHourAngleWithInstance(jd, lon, timezone float64, inst *Instance) float64 { siderealLongitude := Limit360(ApparentSiderealTime(UTC2UT1(jd-timezone/24))*15 + lon) hourAngle := siderealLongitude - NeptuneApparentRaWithInstance(UTC2TT(jd-timezone/24.0), inst) if hourAngle < 0 { hourAngle += 360 } return hourAngle } // NeptuneCulminationTimeWithInstance 用指定星历实例求值;inst 为 nil 时用进程当前模型 / evaluation with an explicit instance; nil uses the process model. func NeptuneCulminationTimeWithInstance(localJD, lon, timezone float64, inst *Instance) float64 { // localJD 是本地民用日锚点(当地 0 时),不是力学时。 //ra,dec 瞬时天球座标,非J2000等时间天球坐标 localJD = math.Floor(localJD) + 0.5 estimateJD := localJD + Limit360(360-NeptuneHourAngleWithInstance(localJD, lon, timezone, inst))/15.0/24.0*0.99726851851851851851 normalizedHourAngle := func(localJD, lon, timezone float64) float64 { currentHourAngle := NeptuneHourAngleWithInstance(localJD, lon, timezone, inst) 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 } // NeptuneRiseTimeWithInstance 用指定星历实例求值;inst 为 nil 时用进程当前模型 / evaluation with an explicit instance; nil uses the process model. func NeptuneRiseTimeWithInstance(jd, lon, lat, timezone, aeroCorrection, observerHeight float64, inst *Instance) (float64, error) { return neptuneRiseDown(jd, lon, lat, timezone, aeroCorrection, observerHeight, true, inst) } // NeptuneSetTimeWithInstance 用指定星历实例求值;inst 为 nil 时用进程当前模型 / evaluation with an explicit instance; nil uses the process model. func NeptuneSetTimeWithInstance(jd, lon, lat, timezone, aeroCorrection, observerHeight float64, inst *Instance) (float64, error) { return neptuneRiseDown(jd, lon, lat, timezone, aeroCorrection, observerHeight, false, inst) } func neptuneRiseDown(jd, lon, lat, timezone, aeroCorrection, observerHeight float64, isRise bool, instances ...*Instance) (float64, error) { inst := instanceValue(instances) return planetRiseDown(jd, lon, lat, timezone, aeroCorrection, observerHeight, isRise, func(localJD, lon, timezone float64) float64 { return NeptuneCulminationTimeWithInstance(localJD, lon, timezone, inst) }, func(localJD, lon, lat, timezone float64) float64 { return NeptuneHeightWithInstance(localJD, lon, lat, timezone, inst) }, func(jde float64) float64 { return NeptuneApparentDecWithInstance(jde, inst) }) }