term method

double term(
  1. int y,
  2. int n,
  3. bool pd
)

Implementation

double term(int y, int n, bool pd) {
  // 儒略日
  double juD = 365.2423112;

  juD -= 6.4e-14 * (y - 100) * (y - 100);
  juD -= 3.047e-8 * (y - 100);
  juD *= y;
  juD += 15.218427 * n + 1721050.71301;

  // 角度
  double tht = 3e-4 * y - 0.372781384 - 0.2617913325 * n;

  //年差实均数
  double yrD = (1.945 * sin(tht) - 0.01206 * sin(2 * tht));
  yrD *= (1.048994 - 2.583e-5 * y);

  //朔差实均数
  double shuoD = -18e-4 * sin(2.313908653 * y - 0.439822951 - 3.0443 * n);

  double vs = pd
      ? (juD + yrD + shuoD - equivalentStandardDay(y, 1, 0) - 1721425)
      : (juD - equivalentStandardDay(y, 1, 0) - 1721425);
  return vs;
}