예제 #1
0
    private void ComputeMoonPosition()
    {
      double lp = 3.8104 + 8399.7091 * _epoch2000Centuries;
      double m = 6.2300 + 628.3019 * _epoch2000Centuries;
      double f = 1.6280 + 8433.4663 * _epoch2000Centuries;
      double mp = 2.3554 + 8328.6911 * _epoch2000Centuries;
      double d = 5.1985 + 7771.3772 * _epoch2000Centuries;

      double longitude =
          lp
          + 0.1098 * Math.Sin(mp)
          + 0.0222 * Math.Sin(2 * d - mp)
          + 0.0115 * Math.Sin(2 * d)
          + 0.0037 * Math.Sin(2 * mp)
          - 0.0032 * Math.Sin(m)
          - 0.0020 * Math.Sin(2 * f)
          + 0.0010 * Math.Sin(2 * d - 2 * mp)
          + 0.0010 * Math.Sin(2 * d - m - mp)
          + 0.0009 * Math.Sin(2 * d + mp)
          + 0.0008 * Math.Sin(2 * d - m)
          + 0.0007 * Math.Sin(mp - m)
          - 0.0006 * Math.Sin(d)
          - 0.0005 * Math.Sin(m + mp);

      double latitude =
          +0.0895 * Math.Sin(f)
          + 0.0049 * Math.Sin(mp + f)
          + 0.0048 * Math.Sin(mp - f)
          + 0.0030 * Math.Sin(2 * d - f)
          + 0.0010 * Math.Sin(2 * d + f - mp)
          + 0.0008 * Math.Sin(2 * d - f - mp)
          + 0.0006 * Math.Sin(2 * d + f);

      longitude = InRange(longitude);
      _sunEclipticLongitude = InRange(_sunEclipticLongitude);
      MoonPhaseAngle = Math.Abs(longitude - _sunEclipticLongitude);
      MoonPhaseAngle = InRange(MoonPhaseAngle);

      double pip =
          +0.016593
          + 0.000904 * Math.Cos(mp)
          + 0.000166 * Math.Cos(2 * d - mp)
          + 0.000137 * Math.Cos(2 * d)
          + 0.000049 * Math.Cos(2 * mp)
          + 0.000015 * Math.Cos(2 * d + mp)
          + 0.000009 * Math.Cos(2 * d - m);

      double dMoon = 1.0 / pip; // Earth radii

      // Moon position in Cartesian coordinates of the ecliptic coordinates system.
      Vector3D moonPositionEcliptic = ToCartesian(dMoon, latitude, longitude);

      // Moon position in Cartesian coordinates of the equatorial coordinates system.
      Vector3D moonPositionEquatorial = EclipticToEquatorial * moonPositionEcliptic;

      // To [m].
      moonPositionEquatorial *= 6378.137 * 1000;

      // Note: The moon formula is already corrected by precession.
      MoonPosition = _equatorialToWorldNoPrecession.TransformPosition(moonPositionEquatorial);
    }