fixedStarDirection function

({Vector3 direction, double distance}) fixedStarDirection(
  1. Ephemeris ephemeris,
  2. FixedStar star,
  3. double jdTT, {
  4. Corrections corrections = const Corrections(),
})

Geocentric direction (unit vector, GCRS/ICRF) to star at jdTT and its distance in km (infinite for zero parallax).

In order: space motion since the catalogue epoch, annual parallax (shift from the solar system barycentre to the Earth's centre), deflection of light by the Sun and aberration – the last two as set in corrections. No light-time: the catalogue gives the star as it is seen.

Implementation

({Vector3 direction, double distance}) fixedStarDirection(
  Ephemeris ephemeris,
  FixedStar star,
  double jdTT, {
  Corrections corrections = const Corrections(),
}) {
  final jdTDB = jdTT + tdbMinusTT(jdTT) / 86400;
  final et = (jdTDB - j2000) * 86400;
  final earth = ephemeris.state(Naif.earth, Naif.solarSystemBarycenter, et);
  final parallax = star._parallaxRadians;

  // r/d₀ − E/d₀, a 1/d₀ = ϖ/AU.
  final geocentric =
      star.barycentricScaled(jdTDB) -
      earth.position * (parallax / astronomicalUnit);
  var direction = geocentric.unit;
  final distance = parallax == 0
      ? double.infinity
      : geocentric.length * astronomicalUnit / parallax;

  if (corrections.deflection) {
    final sun = ephemeris
        .state(Naif.sun, Naif.solarSystemBarycenter, et)
        .position;
    final sunFromEarth = sun - earth.position;
    if (!onSolarDisk(direction, sunFromEarth)) {
      // Od Słońca gwiazda leży praktycznie w tym samym kierunku co od
      // Ziemi; poprawka (E − S)/d₀ ma znaczenie tylko dla najbliższych.
      final sunToStar =
          geocentric - sunFromEarth * (parallax / astronomicalUnit);
      direction = deflectLight(direction, sunToStar, sunFromEarth * -1);
    }
  }
  if (corrections.aberration) {
    direction = aberrate(direction, earth.velocity * (1 / speedOfLight));
  }
  return (direction: direction, distance: distance);
}