Esempio n. 1
0
/*
 * given a particular time (expressed in seconds since the unix
 * epoch), compute position on the earth (lat, lon) such that sun is
 * directly overhead.
 */
void sun_position(time_t ssue, double *lat, double *lon)
     //time_t  ssue;              /* seconds since unix epoch */
     //double *lat;               /* (return) latitude        */
     //double *lon;               /* (return) longitude       */
{
  double lambda;
  double alpha, delta;
  double tmp;

  lambda = sun_ecliptic_longitude(ssue);
  ecliptic_to_equatorial(lambda, 0.0, &alpha, &delta);

  tmp = alpha - (TWOPI/24)*GST(ssue);
  if (tmp < -M_PI)
  {
    do tmp += TWOPI;
    while (tmp < -M_PI);
  }
  else if (tmp > M_PI)
  {
    do tmp -= TWOPI;
    while (tmp < -M_PI);
  }

  *lon = tmp * (360/TWOPI);
  *lat = delta * (360/TWOPI);
}
Esempio n. 2
0
/* Calculate the position of the sun at a given time.  pages 89-91 */
void
sun_position (time_t unix_time, gdouble *lat, gdouble *lon)
{
  gdouble jd, D, N, M, E, x, v, lambda;
  gdouble ra, dec;
  jd = unix_time_to_julian_date (unix_time);

  /* Calculate number of days since the epoch */
  D = jd - EPOCH;

  N = D*360/365.242191;

  /* normalize to 0 - 360 degrees */
  NORMALIZE (N);

  /* Step 4: */
  M = N + EPSILON_G - MU_G;
  NORMALIZE (M);

  /* Step 5: convert to radians */
  M = DEG_TO_RADS (M);

  /* Step 6: */
  E = solve_keplers_equation (ECCENTRICITY, M);

  /* Step 7: */
  x = sqrt ((1 + ECCENTRICITY)/(1 - ECCENTRICITY)) * tan (E/2);

  /* Step 8, 9 */
  v = 2 * RADS_TO_DEG (atan (x));
  NORMALIZE (v);

  /* Step 10 */
  lambda = v + MU_G;
  NORMALIZE (lambda);

  /* convert the ecliptic longitude to right ascension and declination */
  ecliptic_to_equatorial (DEG_TO_RADS (lambda), 0.0, &ra, &dec);

  ra = ra - (G_PI/12) * greenwich_sidereal_time (unix_time);
  ra = RADS_TO_DEG (ra);
  dec = RADS_TO_DEG (dec);
  NORMALIZE (ra);
  NORMALIZE (dec);

  *lat = dec;
  *lon = ra;
}
Esempio n. 3
0
/*
 * given a particular time (expressed in seconds since the unix
 * epoch), compute position on the earth (lat, lon) such that sun is
 * directly overhead.
 */
void sun_position(time_t ssue, double *lat, double *lon)
/*     time_t  ssue;               seconds since unix epoch    */
/*     double *lat;                (return) latitude  in rad   */
/*     double *lon;                (return) longitude in rad   */
{
    double lambda;
    double alpha, delta;
    double tmp;

    lambda = sun_ecliptic_longitude(ssue);
    ecliptic_to_equatorial(lambda, 0.0, &alpha, &delta);

    tmp = alpha - (TWOPI / 24) * GST(ssue);
    Normalize(tmp);
    *lon = tmp;
    *lat = delta;
}
Esempio n. 4
0
/*
 * given a particular time (expressed in seconds since the unix
 * epoch), compute position on the earth (lat, lon) such that the
 * moon is directly overhead.
 *
 * Based on duffett-smith **2nd ed** section 61; combines some steps
 * into single expressions to reduce the number of extra variables.
 */
void moon_position(time_t ssue, double *lat, double *lon)
/*    time_t  ssue;              seconds since unix epoch    */
/*   double *lat;                (return) latitude   in ra   */
/*  double *lon;                 (return) longitude   in ra  */
{
    double lambda, beta;
    double D, L, Ms, Mm, N, Ev, Ae, Ec, alpha, delta;

    D = DaysSinceEpoch(ssue);
    lambda = sun_ecliptic_longitude(ssue);
    Ms = mean_sun(D);

    L = fmod(D / SideralMonth, 1.0) * TWOPI + MoonMeanLongitude;
    Normalize(L);
    Mm = L - DegsToRads(0.1114041 * D) - MoonMeanLongitudePerigee;
    Normalize(Mm);
    N = MoonMeanLongitudeNode - DegsToRads(0.0529539 * D);
    Normalize(N);
    Ev = DegsToRads(1.2739) * sin(2.0 * (L - lambda) - Mm);
    Ae = DegsToRads(0.1858) * sin(Ms);
    Mm += Ev - Ae - DegsToRads(0.37) * sin(Ms);
    Ec = DegsToRads(6.2886) * sin(Mm);
    L += Ev + Ec - Ae + DegsToRads(0.214) * sin(2.0 * Mm);
    L += DegsToRads(0.6583) * sin(2.0 * (L - lambda));
    N -= DegsToRads(0.16) * sin(Ms);

    L -= N;
    lambda = (fabs(cos(L)) < 1e-12) ?
	(N + sin(L) * cos(MoonInclination) * PI / 2) :
	(N + atan2(sin(L) * cos(MoonInclination), cos(L)));
    Normalize(lambda);
    beta = asin(sin(L) * sin(MoonInclination));
    ecliptic_to_equatorial(lambda, beta, &alpha, &delta);
    alpha -= (TWOPI / 24) * GST(ssue);
    Normalize(alpha);
    *lon = alpha;
    *lat = delta;
}