コード例 #1
0
        public static double CalcMoonBrightLimb(double fSunRA, double fSunDecl, double fMRA, double fMDecl)
        {
            double fX, fY, fT, fDeltaRA;

            fSunRA   = fSunRA * 15;
            fMRA     = fMRA * 15;
            fDeltaRA = fSunRA - fMRA;

            fY = Trig.Cos(fSunDecl) * Trig.Sin(fDeltaRA);
            fX = (Trig.Cos(fMDecl) * Trig.Sin(fSunDecl)) - (Trig.Sin(fMDecl) * Trig.Cos(fSunDecl) * Trig.Cos(fDeltaRA));
            fT = Trig.Atan(fY / fX);
            return(Trig.TanQuadrant(fX, fY, fT));
        }
コード例 #2
0
        public static void CalcMoonPhase(DateTime dDate, DateTime dEpoch, double fMEpochLong, double fMPeriLong, double fMAscNode, double fMIncl, double fMEcc, double fSEpochEclLong, double fSPeriEclLong, double fSEcc, ref double fMPhase)
        {
            double fN, fSM, fSE, fSLambda;
            double fL, fMM, fMN, fME, fAE, fMEC, fA3, fA4, fMV, fMM1, fL1, fL2;
            double fJD1, fJD2, fDays, fMD;

            fJD1   = GetJulianDay(dDate, 0);
            fJD2   = GetJulianDay(dEpoch, 0);
            fDays  = (fJD1 - fJD2);
            fDays += 1;

            fN  = (360.0 / 365.242191) * fDays;
            fN  = Trig.PutIn360Deg(fN);
            fSM = fN + fSEpochEclLong - fSPeriEclLong;
            fSM = Trig.PutIn360Deg(fSM);

            fSE      = (360.0 / Math.PI) * fSEcc * Math.Sin(Trig.DegToRad(fSM));
            fSLambda = fN + fSE + fSEpochEclLong;

            fL = (13.176396 * fDays) + fMEpochLong;
            fL = Trig.PutIn360Deg(fL);

            fMM = fL - (0.111404 * fDays) - fMPeriLong;
            fMM = Trig.PutIn360Deg(fMM);

            fMN = fMAscNode - (0.0529539 * fDays);
            fMN = Trig.PutIn360Deg(fMN);

            fME = 1.2739 * Trig.Sin((2.0 * (fL - fSLambda)) - fMM);
            fAE = 0.1858 * Trig.Sin(fSM);
            fA3 = 0.37 * Trig.Sin(fSM);

            fMM1 = fMM + fME - fAE + fA3;

            fMEC = 6.2886 * Trig.Sin(fMM1);
            fA4  = 0.214 * Trig.Sin(2.0 * fMM1);
            fL1  = fL + fME + fMEC - fAE + fA4;

            fMV = 0.6583 * Trig.Sin(2.0 * (fL1 - fSLambda));
            fL2 = fL1 + fMV;

            fMD     = fL2 - fSLambda;
            fMPhase = 0.5 * (1.0 - Trig.Cos(fMD));
        }
コード例 #3
0
        public static void ConvEclToEqu(double fOblique, double fELong, double fELat, ref double fRA, ref double fDecl)
        {
            double fX;
            double fY;
            double fSinDecl;

            fELong   = Trig.DegToRad(fELong);
            fELat    = Trig.DegToRad(fELat);
            fOblique = Trig.DegToRad(fOblique);
            fSinDecl = (Math.Sin(fELat) * Math.Cos(fOblique)) + (Math.Cos(fELat) * Math.Sin(fOblique) * Math.Sin(fELong));
            fDecl    = Math.Asin(fSinDecl);
            fY       = (Math.Sin(fELong) * Math.Cos(fOblique)) - (Math.Tan(fELat) * Math.Sin(fOblique));
            fX       = Math.Cos(fELong);
            fRA      = Math.Atan(fY / fX);
            fRA      = Trig.RadToDeg(fRA);
            fDecl    = Trig.RadToDeg(fDecl);
            fRA      = Trig.TanQuadrant(fX, fY, fRA);
            fRA      = fRA / 15.0;
        }
コード例 #4
0
        /*
         * private static double mjd(int year, int month, int day)
         * {
         *      //
         *      //   takes the year, month and day as a Gregorian calendar date
         *      //   and returns the modified julian day number
         *      //
         *      double a;
         *      double b;
         *
         *      if (month <= 2)
         *      {
         *              month = month + 12;
         *              year--;
         *      }
         *
         *      b = (int)Math.Floor(year / 400.0) - (int)Math.Floor(year / 100.0) + (int)Math.Floor(year / 4.0);
         *      a = 365.0 * year - 679004.0;
         *      return a + b + (int)Math.Floor(30.6001 * (month + 1)) + day;
         * }
         */

        /*
         * private static double frac(double x)
         * {
         *      //
         *      //  returns the fractional part of x as used in minimoon and minisun
         *      //
         *      double a;
         *      a = x - (int)Math.Floor(x);
         *      return a;
         * }
         */

        /*
         * private static double range(double x)
         * {
         *      //
         *      //   returns an angle in degrees in the range 0 to 360
         *      //   used to condition the arguments for the Sun's orbit
         *      //   in function minisun below
         *      //
         *      double a;
         *      double b;
         *      b = x / 360;
         *      a = 360 * (b - (int)Math.Floor(b));
         *      if (a < 0)
         *      {
         *              a = a + 360;
         *      }
         *      return a;
         * }
         */

        /*
         * private static string hrsmin(double t)
         * {
         *      //
         *      //   takes a time as a decimal number of hours between 0 and 23.9999...
         *      //   and returns a string with the time in hhmm format
         *      //
         *      double hour;
         *      double min;
         *
         *      hour = (int)Math.Floor(t);
         *      min = (int)Math.Floor((t - hour) * 60 + 0.5);
         *      return (hour.ToString("00") + min.ToString("00"));
         *      //return "0000";
         * }
         */

        /*
         * private static double lmst(double mjd, double glong)
         * {
         *      //
         *      //  Takes the mjd and the longitude (west negative) and then returns
         *      //  the local sidereal time in hours. Im using Meeus formula 11.4
         *      //  instead of messing about with UTo and so on
         *      //
         *      double lst;
         *      double t;
         *      double d;
         *      d = mjd - 51544.5;
         *      t = d / 36525.0;
         *      lst = range(280.46061837 + 360.98564736629 * d + 0.000387933 * t * t - t * t * t / 38710000.0);
         *      return lst / 15.0 + glong / 15.0;
         * }
         */

        /*
         * private static void minisun(double t, ref double ra, ref double dec)
         * {
         *      //
         *      //   takes t (julian centuries since J2000.0) and empty variables ra and dec
         *      //   sets ra and dec to the value of the Sun coordinates at t
         *      //
         *      //   positions claimed to be within 1 arc min by Montenbruck and Pfleger
         *      //
         *      double p2;
         *      double coseps;
         *      double sineps;
         *      double l;
         *      double m;
         *      double DL;
         *      double SL;
         *      double x;
         *      double y;
         *      double z;
         *      double rho;
         *      p2 = 6.283185307;
         *      coseps = 0.91748;
         *      sineps = 0.39778;
         *
         *      m = p2 * frac(0.993133 + 99.997361 * t);
         *      DL = 6893.0 * System.Math.Sin(m) + 72.0 * System.Math.Sin(2 * m);
         *      l = p2 * frac(0.7859453 + m / p2 + (6191.2 * t + DL) / 1296000.0);
         *      SL = System.Math.Sin(l);
         *      x = System.Math.Cos(l);
         *      y = coseps * SL;
         *      z = sineps * SL;
         *      rho = System.Math.Sqrt(1 - z * z);
         *      dec = (360.0 / p2) * System.Math.Atan(z / rho);
         *      ra = (48.0 / p2) * System.Math.Atan(y / (x + rho));
         *      if (ra < 0)
         *      {
         *              ra = ra + 24;
         *      }
         * }
         */

        /*
         * private static void quad(double ym, double yz, double yp, ref int nz, ref double z1, ref double z2, ref double xe, ref double ye)
         * {
         *      //
         *      //  finds the parabola throuh the three points (-1,ym), (0,yz), (1, yp)
         *      //  and sets the coordinates of the max/min (if any) xe, ye
         *      //  the values of x where the parabola crosses zero (z1, z2)
         *      //  and the nz number of roots (0, 1 or 2) within the interval [-1, 1]
         *      //
         *      double a;
         *      double b;
         *      double c;
         *      double dis;
         *      double dx;
         *
         *      nz = 0;
         *      a = 0.5 * (ym + yp) - yz;
         *      b = 0.5 * (yp - ym);
         *      c = yz;
         *      xe = -b / (2 * a);
         *      ye = (a * xe + b) * xe + c;
         *      dis = b * b - 4.0 * a * c;
         *      if (dis > 0)
         *      {
         *              dx = 0.5 * System.Math.Sqrt(dis) / System.Math.Abs(a);
         *              z1 = xe - dx;
         *              z2 = xe + dx;
         *              if (System.Math.Abs(z1) <= 1.0)
         *              {
         *                      nz++;
         *              }
         *              if (System.Math.Abs(z2) <= 1.0)
         *              {
         *                      nz++;
         *              }
         *              if (z1 < -1.0)
         *              {
         *                      z1 = z2;
         *              }
         *      }
         * }
         */

        /*
         * private static double SinAltSun(double mjd0, double hour, double glong, double cglat, double sglat)
         * {
         *      //
         *      //  this rather mickey mouse function takes a lot of
         *      //  arguments and then returns the sine of the altitude of
         *      //  the object labelled by iobj. iobj = 1 is moon, iobj = 2 is sun
         *      //
         *      double mjd;
         *      double t;
         *      double ra = 0;
         *      double dec = 0;
         *      double tau;
         *      double salt;
         *      double rads;
         *      double alt;
         *      double refrac;
         *      double te;
         *      double step1, step2, step3;
         *      rads = 0.0174532925;
         *      mjd = mjd0 + hour / 24.0;
         *      t = (mjd - 51544.5) / 36525.0;
         *      minisun(t, ref ra, ref dec);
         *      // hour angle of object
         *      tau = 15.0 * (lmst(mjd, glong) - ra);
         *      // sin(alt) of object using the conversion formulas
         *      salt = sglat * System.Math.Sin(rads * dec) + cglat * System.Math.Cos(rads * dec) * System.Math.Cos(rads * tau);
         *      // MC: Add a simplified atmospheric refraction correction
         *      alt = radToDeg(Math.Asin(salt));
         *      if (alt > 85.0 || alt <= -0.575)
         *      {
         *              refrac = 0;
         *      }
         *      else
         *      {
         *              te = Math.Tan(degToRad(alt));
         *              if (alt > 5.0)
         *              {
         *                      refrac = 58.1 / te - 0.07 / (te * te * te) + 0.000086 / (te * te * te * te * te);
         *              }
         *              else if (alt > -0.575)
         *              {
         *                      step1 = -12.79 + alt * 0.7111;
         *                      step2 = 103.4 + alt * step1;
         *                      step3 = -518.2 + alt * step2;
         *                      refrac = 1735.0 + alt * step3;
         *              }
         *              else
         *              {
         *                      refrac = -20.774 / te;
         *              }
         *              refrac /= 3600.0;
         *      }
         *      return Math.Sin(degToRad(alt + refrac));
         * }
         */

        //
        //   Worksheet functions below....
        //

        /*
         * public static string sunevent(int year, int month, int day, double tz, double glong, double glat, int EventType)
         * {
         *      //
         *      //   This is the function that does most of the work
         *      //
         *      //			double sglong;
         *      double sglat;
         *      double cglat;
         *      double ddate;
         *      double ym;
         *      double yz;
         *      int above;
         *      double utrise = 0;
         *      double utset = 0;
         *      //          int above;
         *      utrise = 0;
         *      //          double utset;
         *      //          int above;
         *      //          double utrise;
         *      //          double utset;
         *      double yp;
         *      int nz;
         *      int rise;
         *      int sett;
         *      int j;
         *      double hour;
         *      double z1;
         *      double z2;
         *      double rads;
         *      double xe;
         *      double ye;
         *      string AlwaysUp;
         *      string AlwaysDown;
         *      string OutString = "";
         *      string NoEvent;
         *      //          string AlwaysDown;
         *      //          string OutString;
         *      //          string NoEvent;
         *      double[] sinho = new double[6];
         *      rads = 0.0174532925;
         *      AlwaysUp = "****";
         *      AlwaysDown = "....";
         *      NoEvent = "----";
         *
         *      //
         *      //   Set up the array with the 4 values of sinho needed for the 4
         *      //   kinds of sun event
         *      //
         *      sinho[1] = System.Math.Sin(rads * -0.833); //sunset upper limb simple refraction
         *      sinho[2] = System.Math.Sin(rads * -6.0); //civil twi
         *      sinho[3] = System.Math.Sin(rads * -12.0); //nautical twi
         *      sinho[4] = System.Math.Sin(rads * -18.0); //astro twi
         *      sglat = System.Math.Sin(rads * glat);
         *      cglat = System.Math.Cos(rads * glat);
         *      ddate = mjd(year, month, day) - tz / 24.0;
         *      //
         *      //   main loop takes each value of sinho in turn and finds the rise/set
         *      //   events associated with that altitude of the Sun
         *      //
         *      j = System.Math.Abs(EventType);
         *      nz = 0;
         *      z1 = 0;
         *      z2 = 0;
         *      xe = 0;
         *      ye = 0;
         *      rise = 0;
         *      sett = 0;
         *      above = 0;
         *      hour = 1.0;
         *      ym = SinAltSun(ddate, hour - 1.0, glong, cglat, sglat) - sinho[j];
         *      if (ym > 0.0)
         *      {
         *              above = 1;
         *      }
         *      //
         *      //  the while loop finds the sin(alt) for sets of three consecutive
         *      //  hours, and then tests for a single zero crossing in the interval
         *      //  or for two zero crossings in an interval or for a grazing event
         *      //  The flags rise and sett are set accordingly
         *      //
         *      while (hour < 25 && (sett == 0 || rise == 0))
         *      {
         *              yz = SinAltSun(ddate, hour, glong, cglat, sglat) - sinho[j];
         *              yp = SinAltSun(ddate, hour + 1.0, glong, cglat, sglat) - sinho[j];
         *              quad(ym, yz, yp, ref nz, ref z1, ref z2, ref xe, ref ye);
         *              // case when one event is found in the interval
         *              if (nz == 1)
         *              {
         *                      if (ym < 0.0)
         *                      {
         *                              utrise = hour + z1;
         *                              rise = 1;
         *                      }
         *                      else
         *                      {
         *                              utset = hour + z1;
         *                              sett = 1;
         *                      }
         *              } // end of nz = 1 case
         *              //
         *              //   case where two events are found in this interval
         *              //   (rare but whole reason we are not using simple iteration)
         *              //
         *              if (nz == 2)
         *              {
         *                      if (ye < 0.0)
         *                      {
         *                              utrise = hour + z2;
         *                              utset = hour + z1;
         *                      }
         *                      else
         *                      {
         *                              utrise = hour + z1;
         *                              utset = hour + z2;
         *                      }
         *                      rise = 1;
         *                      sett = 1;
         *              }
         *              //
         *              //   set up the next search interval
         *              //
         *              ym = yp;
         *              hour = hour + 2.0;
         *
         *      } // end of while loop
         *      //
         *      // now search has completed, we compile the string to pass back
         *      // to the user. The string depends on several combinations
         *      // of the above flag (always above or always below) and the rise
         *      // and sett flags
         *      //
         *      if (rise == 1 || sett == 1)
         *      {
         *              if (rise == 1)
         *              {
         *                      if (EventType > 0)
         *                      {
         *                              OutString = hrsmin(utrise);
         *                      }
         *              }
         *              else
         *              {
         *                      if (EventType > 0)
         *                      {
         *                              OutString = NoEvent;
         *                      }
         *              }
         *              if (sett == 1)
         *              {
         *                      if (EventType < 0)
         *                      {
         *                              OutString = hrsmin(utset);
         *                      }
         *              }
         *              else
         *              {
         *                      if (EventType < 0)
         *                      {
         *                              OutString = NoEvent;
         *                      }
         *              }
         *      }
         *      else
         *      {
         *              if (above == 1)
         *              {
         *                      OutString = AlwaysUp;
         *              }
         *              else
         *              {
         *                      OutString = AlwaysDown;
         *              }
         *      }
         *      return OutString;
         * }
         */

        /*
         * public static string sunrise(DateTime ddate, double tz, double glong, double glat)
         * {
         *      //
         *      //   simple way of calling sunevent() using the Excel date format
         *      //   returns just the sunrise time or NULL if no event
         *      //   I used the day(), month() and year() functions in excel to allow
         *      //   portability to the MAC (different date serial numbers)
         *      //
         *      string EventTime;
         *      string sOut;
         *      sOut = sunevent(ddate.Year, ddate.Month, ddate.Day, tz, glong, glat, cSunrise);
         *      if (sOut == "....")
         *      {
         *              EventTime = "Always Down";
         *      }
         *      else if (sOut == "----")
         *      {
         *              EventTime = "No event";
         *      }
         *      else if (sOut == "****")
         *      {
         *              EventTime = "Always Up";
         *      }
         *      else
         *      {
         *              EventTime = sOut.Substring(0, 2) + "h " + sOut.Substring(2, 2) + "m";
         *      }
         *      return EventTime;
         * }
         */

        /*
         * public static string sunset(DateTime ddate, double tz, double glong, double glat)
         * {
         *      //
         *      //   simple way of calling sunevent() using the Excel date format
         *      //   returns just the sunset time or ****, ...., ---- as approptiate in a string
         *      //   I used the day(), month() and year() functions in excel to allow
         *      //   portability to the MAC (different date serial number base)
         *      //
         *      string EventTime;
         *      string sOut;
         *      sOut = sunevent(ddate.Year, ddate.Month, ddate.Day, tz, glong, glat, cSunset);
         *      if (sOut == "....")
         *      {
         *              EventTime = "Always Down";
         *      }
         *      else if (sOut == "----")
         *      {
         *              EventTime = "No event";
         *      }
         *      else if (sOut == "****")
         *      {
         *              EventTime = "Always Up";
         *      }
         *      else
         *      {
         *              EventTime = sOut.Substring(0, 2) + "h " + sOut.Substring(2, 2) + "m";
         *      }
         *      return EventTime;
         * }
         */

        /*
         * public static string CivilTwilightStarts(DateTime ddate, double tz, double glong, double glat)
         * {
         *      //
         *      //   simple way of calling sunevent() using the Excel date format
         *      //   returns just the start of civil twilight time or ****, ...., ---- as approptiate
         *      //   I used the day(), month() and year() functions in excel to allow
         *      //   portability to the MAC (different date serial numbers)
         *      //
         *      string EventTime;
         *      string sOut;
         *      sOut = sunevent(ddate.Year, ddate.Month, ddate.Day, tz, glong, glat, cBeginCivilTwilight);
         *      if (sOut == "....")
         *      {
         *              EventTime = "Always Down";
         *      }
         *      else if (sOut == "----")
         *      {
         *              EventTime = "No event";
         *      }
         *      else if (sOut == "****")
         *      {
         *              EventTime = "Always Up";
         *      }
         *      else
         *      {
         *              EventTime = sOut.Substring(0, 2) + "h " + sOut.Substring(2, 2) + "m";
         *      }
         *      return EventTime;
         * }
         */

        /*
         * public static string CivilTwilightEnds(DateTime ddate, double tz, double glong, double glat)
         * {
         *      //
         *      string EventTime;
         *      string sOut;
         *      sOut = sunevent(ddate.Year, ddate.Month, ddate.Day, tz, glong, glat, cEndCivilTwilight);
         *      if (sOut == "....")
         *      {
         *              EventTime = "Always Down";
         *      }
         *      else if (sOut == "----")
         *      {
         *              EventTime = "No event";
         *      }
         *      else if (sOut == "****")
         *      {
         *              EventTime = "Always Up";
         *      }
         *      else
         *      {
         *              EventTime = sOut.Substring(0, 2) + "h " + sOut.Substring(2, 2) + "m";
         *      }
         *      return EventTime;
         * }
         */

        /*
         * public static string NauticalTwilightStarts(DateTime ddate, double tz, double glong, double glat)
         * {
         *      //
         *      string EventTime;
         *      string sOut;
         *      sOut = sunevent(ddate.Year, ddate.Month, ddate.Day, tz, glong, glat, cBeginNautTwilight);
         *      if (sOut == "....")
         *      {
         *              EventTime = "Always Down";
         *      }
         *      else if (sOut == "----")
         *      {
         *              EventTime = "No event";
         *      }
         *      else if (sOut == "****")
         *      {
         *              EventTime = "Always Up";
         *      }
         *      else
         *      {
         *              EventTime = sOut.Substring(0, 2) + "h " + sOut.Substring(2, 2) + "m";
         *      }
         *      return EventTime;
         * }
         */

        /*
         * public static string NauticalTwilightEnds(DateTime ddate, double tz, double glong, double glat)
         * {
         *      //
         *      string EventTime;
         *      string sOut;
         *      sOut = sunevent(ddate.Year, ddate.Month, ddate.Day, tz, glong, glat, cEndNautTwilight);
         *      if (sOut == "....")
         *      {
         *              EventTime = "Always Down";
         *      }
         *      else if (sOut == "----")
         *      {
         *              EventTime = "No event";
         *      }
         *      else if (sOut == "****")
         *      {
         *              EventTime = "Always Up";
         *      }
         *      else
         *      {
         *              EventTime = sOut.Substring(0, 2) + "h " + sOut.Substring(2, 2) + "m";
         *      }
         *      return EventTime;
         * }
         */

        /*
         * public static string AstroTwilightStarts(DateTime ddate, double tz, double glong, double glat)
         * {
         *      //
         *      string EventTime;
         *      string sOut;
         *      sOut = sunevent(ddate.Year, ddate.Month, ddate.Day, tz, glong, glat, cBeginAstroTwilight);
         *      if (sOut == "....")
         *      {
         *              EventTime = "Always Down";
         *      }
         *      else if (sOut == "----")
         *      {
         *              EventTime = "No event";
         *      }
         *      else if (sOut == "****")
         *      {
         *              EventTime = "Always Up";
         *      }
         *      else
         *      {
         *              EventTime = sOut.Substring(0, 2) + "h " + sOut.Substring(2, 2) + "m";
         *      }
         *      return EventTime;
         * }
         */

        /*
         * public static string AstroTwilightEnds(DateTime ddate, double tz, double glong, double glat)
         * {
         *      //
         *      string EventTime;
         *      string sOut;
         *      sOut = sunevent(ddate.Year, ddate.Month, ddate.Day, tz, glong, glat, cEndAstroTwilight);
         *      if (sOut == "....")
         *      {
         *              EventTime = "Always Down";
         *      }
         *      else if (sOut == "----")
         *      {
         *              EventTime = "No event";
         *      }
         *      else if (sOut == "****")
         *      {
         *              EventTime = "Always Up";
         *      }
         *      else
         *      {
         *              EventTime = sOut.Substring(0, 2) + "h " + sOut.Substring(2, 2) + "m";
         *      }
         *      return EventTime;
         * }
         */

        /*
         * public static void CalcMoonPos(DateTime dDate, DateTime dEpoch, double fMEpochLong, double fMPeriLong, double fMAscNode, double fMIncl, double fMEcc, double fSEpochEclLong, double fSPeriEclLong, double fSEcc, ref double fMRA, ref double fMDecl)
         * {
         *      double fN, fSM, fSE, fSLambda;
         *      double fL, fMM, fMN, fME, fAE, fMEC, fA3, fA4, fMV, fMM1, fL1, fL2, fN1, fX, fY;
         *      double fT, fMLambda, fMBeta, fJD1, fJD2, fDays;
         *
         *      fJD1 = GetJulianDay(dDate, 0);
         *      fJD2 = GetJulianDay(dEpoch, 0);
         *      fDays = (fJD1 - fJD2);
         *      fDays += 1;
         *
         *      fN = (360.0 / 365.242191) * fDays;
         *      fN = Trig.PutIn360Deg(fN);
         *      fSM = fN + fSEpochEclLong - fSPeriEclLong;
         *      fSM = Trig.PutIn360Deg(fSM);
         *
         *      fSE = (360.0 / Math.PI) * fSEcc * Math.Sin(Trig.DegToRad(fSM));
         *      fSLambda = fN + fSE + fSEpochEclLong;
         *
         *      fL = (13.176396 * fDays) + fMEpochLong;
         *      fL = Trig.PutIn360Deg(fL);
         *
         *      fMM = fL - (0.111404 * fDays) - fMPeriLong;
         *      fMM = Trig.PutIn360Deg(fMM);
         *
         *      fMN = fMAscNode - (0.0529539 * fDays);
         *      fMN = Trig.PutIn360Deg(fMN);
         *
         *      fME = 1.2739 * Trig.Sin((2.0 * (fL - fSLambda)) - fMM);
         *      fAE = 0.1858 * Trig.Sin(fSM);
         *      fA3 = 0.37 * Trig.Sin(fSM);
         *
         *      fMM1 = fMM + fME - fAE + fA3;
         *
         *      fMEC = 6.2886 * Trig.Sin(fMM1);
         *      fA4 = 0.214 * Trig.Sin(2.0 * fMM1);
         *      fL1 = fL + fME + fMEC - fAE + fA4;
         *
         *      fMV = 0.6583 * Trig.Sin(2.0 * (fL1 - fSLambda));
         *      fL2 = fL1 + fMV;
         *
         *      fN1 = fMN - (0.16 * Trig.Sin(fSM));
         *      fY = Trig.Sin(fL2 - fN1) * Trig.Cos(fMIncl);
         *      fX = Trig.Cos(fL2 - fN1);
         *
         *      fT = Trig.Atan(fY / fX);
         *
         *      fT = Trig.TanQuadrant(fX, fY, fT);
         *
         *      fMLambda = fT + fN1;
         *      fMBeta = Trig.Asin(Trig.Sin(fL2 - fN1) * Trig.Sin(fMIncl));
         *      ConvEclToEqu(23.441884, fMLambda, fMBeta, ref fMRA, ref fMDecl);
         * }
         */

        /*
         * public static void ConvEclToEqu(double fOblique, double fELong, double fELat, ref double fRA, ref double fDecl)
         * {
         *      double fX;
         *      double fY;
         *      double fSinDecl;
         *
         *      fELong = Trig.DegToRad(fELong);
         *      fELat = Trig.DegToRad(fELat);
         *      fOblique = Trig.DegToRad(fOblique);
         *      fSinDecl = (Math.Sin(fELat) * Math.Cos(fOblique)) + (Math.Cos(fELat) * Math.Sin(fOblique) * Math.Sin(fELong));
         *      fDecl = Math.Asin(fSinDecl);
         *      fY = (Math.Sin(fELong) * Math.Cos(fOblique)) - (Math.Tan(fELat) * Math.Sin(fOblique));
         *      fX = Math.Cos(fELong);
         *      fRA = Math.Atan(fY / fX);
         *      fRA = Trig.RadToDeg(fRA);
         *      fDecl = Trig.RadToDeg(fDecl);
         *      fRA = Trig.TanQuadrant(fX, fY, fRA);
         *      fRA = fRA / 15.0;
         * }
         */

        /*
         * public static void CalcMoonPhase(DateTime dDate, DateTime dEpoch, double fMEpochLong, double fMPeriLong, double fMAscNode, double fMIncl, double fMEcc, double fSEpochEclLong, double fSPeriEclLong, double fSEcc, ref double fMPhase)
         * {
         *      double fN, fSM, fSE, fSLambda;
         *      double fL, fMM, fMN, fME, fAE, fMEC, fA3, fA4, fMV, fMM1, fL1, fL2;
         *      double fJD1, fJD2, fDays, fMD;
         *
         *      fJD1 = GetJulianDay(dDate, 0);
         *      fJD2 = GetJulianDay(dEpoch, 0);
         *      fDays = (fJD1 - fJD2);
         *      fDays += 1;
         *
         *      fN = (360.0 / 365.242191) * fDays;
         *      fN = Trig.PutIn360Deg(fN);
         *      fSM = fN + fSEpochEclLong - fSPeriEclLong;
         *      fSM = Trig.PutIn360Deg(fSM);
         *
         *      fSE = (360.0 / Math.PI) * fSEcc * Math.Sin(Trig.DegToRad(fSM));
         *      fSLambda = fN + fSE + fSEpochEclLong;
         *
         *      fL = (13.176396 * fDays) + fMEpochLong;
         *      fL = Trig.PutIn360Deg(fL);
         *
         *      fMM = fL - (0.111404 * fDays) - fMPeriLong;
         *      fMM = Trig.PutIn360Deg(fMM);
         *
         *      fMN = fMAscNode - (0.0529539 * fDays);
         *      fMN = Trig.PutIn360Deg(fMN);
         *
         *      fME = 1.2739 * Trig.Sin((2.0 * (fL - fSLambda)) - fMM);
         *      fAE = 0.1858 * Trig.Sin(fSM);
         *      fA3 = 0.37 * Trig.Sin(fSM);
         *
         *      fMM1 = fMM + fME - fAE + fA3;
         *
         *      fMEC = 6.2886 * Trig.Sin(fMM1);
         *      fA4 = 0.214 * Trig.Sin(2.0 * fMM1);
         *      fL1 = fL + fME + fMEC - fAE + fA4;
         *
         *      fMV = 0.6583 * Trig.Sin(2.0 * (fL1 - fSLambda));
         *      fL2 = fL1 + fMV;
         *
         *      fMD = fL2 - fSLambda;
         *      fMPhase = 0.5 * (1.0 - Trig.Cos(fMD));
         * }
         */

        public static void CalcMoonDistance(DateTime dDate, DateTime dEpoch, double fMEpochLong, double fMPeriLong, double fMAscNode, double fMIncl, double fMEcc, double fSEpochEclLong, double fSPeriEclLong, double fSEcc, double fMSMA, ref double fMDistance)
        {
            double fN, fSM, fSE, fSLambda;
            double fL, fMM, fME, fAE, fMEC, fA3, fMM1;
            double fJD1, fJD2, fDays;

            fJD1   = GetJulianDay(dDate, 0);
            fJD2   = GetJulianDay(dEpoch, 0);
            fDays  = (fJD1 - fJD2);
            fDays += 1;

            fN  = (360.0 / 365.242191) * fDays;
            fN  = Trig.PutIn360Deg(fN);
            fSM = fN + fSEpochEclLong - fSPeriEclLong;
            fSM = Trig.PutIn360Deg(fSM);

            fSE      = (360.0 / Math.PI) * fSEcc * Math.Sin(Trig.DegToRad(fSM));
            fSLambda = fN + fSE + fSEpochEclLong;

            fL = (13.176396 * fDays) + fMEpochLong;
            fL = Trig.PutIn360Deg(fL);

            fMM = fL - (0.111404 * fDays) - fMPeriLong;
            fMM = Trig.PutIn360Deg(fMM);

            //fMN = fMAscNode - (0.0529539 * fDays);
            //fMN = Trig.PutIn360Deg(fMN);

            fME = 1.2739 * Trig.Sin((2.0 * (fL - fSLambda)) - fMM);
            fAE = 0.1858 * Trig.Sin(fSM);
            fA3 = 0.37 * Trig.Sin(fSM);

            fMM1 = fMM + fME - fAE + fA3;

            fMEC = 6.2886 * Trig.Sin(fMM1);

            fMDistance = fMSMA * ((1.0 - (fMEcc * fMEcc)) / (1.0 + (fMEcc * Trig.Cos(fMM1 + fMEC))));
        }