horizontalPosition function
Horizontal coordinates of body target (NAIF code: Sun, Moon,
planets, or a small body from an added file) for observer at jdTT.
Topocentric: the observer's position is subtracted from the apparent
geocentric position (parallax – up to about 1° for the Moon, 30″ for
Venus, 8.8″ for the Sun). Diurnal aberration (at most 0.3″) is
neglected. withRefraction adds atmospheric refraction.
Implementation
HorizontalPosition horizontalPosition(
Ephemeris ephemeris,
int target,
Observer observer,
double jdTT, {
bool withRefraction = false,
double pressure = 1010,
double temperature = 10,
double? deltaTSeconds,
}) {
final p = equatorialOfDate(ephemeris, target, jdTT);
final ra = p.rightAscension * _degree, dec = p.declination * _degree;
final geocentric =
Vector3(
math.cos(dec) * math.cos(ra),
math.cos(dec) * math.sin(ra),
math.sin(dec),
) *
p.distance;
final topocentric =
geocentric - observer.position(jdTT, deltaTSeconds: deltaTSeconds);
final distance = topocentric.length;
final tra = math.atan2(topocentric.y, topocentric.x) / _degree;
return _horizontal(
tra < 0 ? tra + 360 : tra,
math.asin(topocentric.z / distance) / _degree,
distance,
observer,
jdTT,
withRefraction,
pressure,
temperature,
deltaTSeconds,
);
}