public static function Apcs($date1, $date2, array $pv, array $ebpv,
          array $ehp, iauASTROM &$astrom) {

    /* au/d to m/s */
    $AUDMS = DAU / DAYSEC;

    /* Light time for 1 AU (day) */
    $CR = AULT / DAYSEC;

    $i;
    $dp;
    $dv;
    $pb = [];
    $vb = [];
    $ph = [];
    $v2;
    $w;

    /* Time since reference epoch, years (for proper motion calculation). */
    $astrom->pmt = ( ($date1 - DJ00) + $date2 ) / DJY;

    /* Adjust Earth ephemeris to observer. */
    for ($i = 0; $i < 3; $i++) {
      $dp     = $pv[0][$i] / DAU;
      $dv     = $pv[1][$i] / $AUDMS;
      $pb[$i] = $ebpv[0][$i] + $dp;
      $vb[$i] = $ebpv[1][$i] + $dv;
      $ph[$i] = $ehp[$i] + $dp;
    }

    /* Barycentric position of observer (au). */
    static::Cp($pb, $astrom->eb);

    /* Heliocentric direction and distance (unit vector and au). */
    static::Pn($ph, $astrom->em, $astrom->eh);

    /* Barycentric vel. in units of c, and reciprocal of Lorenz factor. */
    $v2 = 0.0;
    for ($i = 0; $i < 3; $i++) {
      $w             = $vb[$i] * $CR;
      $astrom->v[$i] = $w;
      $v2 += $w * $w;
    }
    $astrom->bm1 = sqrt(1.0 - $v2);

    /* Reset the NPB matrix. */
    static::Ir($astrom->bpn);

    /* Finished. */
  }