Пример #1
0
int DLL_FUNC calc_planet_orientation( int planet_no, int system_no, double jd,
                                                         double *matrix)
#endif
{
   static int prev_planet_no = -1, prev_system_no = -1, prev_rval = 0;
   static double prev_jd = -1.;
   static double prev_matrix[9];
   int i, rval, is_retrograde;
   double pole_ra, pole_dec, omega;

   if( planet_no == prev_planet_no && system_no == prev_system_no
                           && jd == prev_jd)
      {
      memcpy( matrix, prev_matrix, 9 * sizeof( double));
      return( prev_rval);
      }

   prev_planet_no = planet_no;
   prev_system_no = system_no;
   prev_jd = jd;

   if( planet_no == 3)        /* handle earth with "normal" precession: */
      {
      const double J2000 = 2451545.;   /* 1.5 Jan 2000 = JD 2451545 */
      const double t_cen = (jd - J2000) / 36525.;
      int i;

      setup_precession( matrix, 2000., 2000. + t_cen * 100.);
      for( i = 3; i < 6; i++)
         matrix[i] = -matrix[i];
      spin_matrix( matrix, matrix + 3, green_sidereal_time( jd));
      memcpy( prev_matrix, matrix, 9 * sizeof( double));
      prev_rval = 0;
      return( 0);
      }

         /* For everybody else,  we use TD.  Only the earth uses UT. */
         /* (This correction added 5 Nov 98,  after G Seronik pointed */
         /* out an error in the Saturn central meridian.)             */

   jd += td_minus_ut( jd) / 86400.;   /* correct from UT to TD */
   rval = get_cospar_data_from_text_file( planet_no, system_no, jd,
                  &pole_ra, &pole_dec, &omega, &is_retrograde);
   pole_ra *= PI / 180.;
   pole_dec *= PI / 180.;
   polar3_to_cartesian( matrix, pole_ra - PI / 2., 0.);
   polar3_to_cartesian( matrix + 3, pole_ra - PI, PI / 2. - pole_dec);
   polar3_to_cartesian( matrix + 6, pole_ra, pole_dec);

   spin_matrix( matrix, matrix + 3, omega * PI / 180. + PI);
   if( is_retrograde)
      for( i = 3; i < 6; i++)
         matrix[i] *= -1.;
   memcpy( prev_matrix, matrix, 9 * sizeof( double));
   prev_rval = rval;
   return( rval);
}
Пример #2
0
void DLL_FUNC calc_triton_loc( const double jd, double *vect)
{
   const double t_cent = (jd - J2000) / 36525.;
   const double n = (359.28 + 54.308 * t_cent) * (PI / 180.);
   const double t0 = 2433282.5;
   const double theta = (151.401 + .57806 * (jd - t0) / 365.25) * (PI / 180.);
            /* Semimajor axis is 488.49 arcseconds at one AU: */
   const double semimajor = 488.49 * (PI / 180.) / 3600.;
   const double longitude =
               (200.913 + 61.2588532 * (jd - t0)) * (PI / 180.);
   const double gamma = 158.996 * (PI / 180.);

         /* Calculate longitude and latitude on invariable plane: */
   const double lon_on_ip = theta + atan2( sin( longitude) * cos( gamma),
                                     cos( longitude));
   const double lat_on_ip = asin( sin( longitude) * sin( gamma));
         /* Vectors defining invariable plane,  expressed in B1950: */
   double x_axis[3], y_axis[3], z_axis[3];
         /* Vector defining Triton position in invariable plane space: */
   double triton[3];
         /* RA/dec of the pole: */
   double ra_dec_p[2];
   double matrix[9];
   double vect_1950[3];
   int i;

   polar3_to_cartesian( triton, lon_on_ip, lat_on_ip);

   ra_dec_p[0] = (298.72 * PI / 180.) + (2.58 * PI / 180.) * sin( n)
                     - (0.04 * PI / 180.) * sin( n + n);
   ra_dec_p[1] = (42.63 * PI / 180.) - (1.90 * PI / 180.) * cos( n)
                     + (0.01 * PI / 180.) * cos( n + n);
   setup_precession( matrix, 1950., 2000.);
   precess_ra_dec( matrix, ra_dec_p, ra_dec_p, 1);
   polar3_to_cartesian( x_axis, ra_dec_p[0] + PI / 2., 0.);
   polar3_to_cartesian( y_axis, ra_dec_p[0] + PI, PI / 2. - ra_dec_p[1]);
   polar3_to_cartesian( z_axis, ra_dec_p[0], ra_dec_p[1]);

   for( i = 0; i < 3; i++)
      vect_1950[i] = semimajor * (x_axis[i] * triton[0] +
                      y_axis[i] * triton[1] + z_axis[i] * triton[2]);
   precess_vector( matrix, vect_1950, vect);
}
Пример #3
0
int fill_planet_data( PLANET_DATA *pdata, const int planet_no, const double jd,
                  const double observer_lat, const double observer_lon,
                  const char *vsop_data)
{
   double loc_sidereal_time = green_sidereal_time( jd) + observer_lon;
   double t_centuries = (jd - J2000) / 36525.;
   double obliquity = mean_obliquity( t_centuries);
   double loc[3];

   pdata->jd = jd;
   if( planet_no == 10)         /* get lunar data,  not VSOP */
      {
      double fund[N_FUND];

      lunar_fundamentals( vsop_data, t_centuries, fund);
      lunar_lon_and_dist( vsop_data, fund, &pdata->ecliptic_lon, &pdata->r, 0L);
      pdata->ecliptic_lon *= pi / 180.;
      pdata->ecliptic_lat = lunar_lat( vsop_data, fund, 0L) * pi / 180.;
      }
   else
      {
                  /* What we _really_ want is the location of the sun as */
                  /* seen from the earth.  VSOP gives us the opposite,   */
                  /* i.e.,  where the _earth_ is as seen from the _sun_. */
                  /* To evade this,  we add PI to the longitude and      */
                  /* negate the latitude.                                */
      pdata->ecliptic_lon =
               calc_vsop_loc( vsop_data, planet_no, 0, t_centuries, 0.) + pi;
      pdata->ecliptic_lat =
                  -calc_vsop_loc( vsop_data, planet_no, 1, t_centuries, 0.);
      pdata->r   = calc_vsop_loc( vsop_data, planet_no, 2, t_centuries, 0.);
      }


   polar3_to_cartesian( loc, pdata->ecliptic_lon, pdata->ecliptic_lat);
   memcpy( pdata->ecliptic_loc, loc, 3 * sizeof( double));

                  /* At this point,  loc is a unit vector in ecliptic */
                  /* coords of date.  Rotate it by 'obliquity' to get */
                  /* a vector in equatorial coords of date: */

   rotate_vector( loc, obliquity, 0);
   memcpy( pdata->equatorial_loc, loc, 3 * sizeof( double));

               /* The following two rotations take us from a vector in */
               /* equatorial coords of date to an alt/az vector: */
   rotate_vector( loc, -loc_sidereal_time, 2);
/* printf( "LST: %lf\n", fmod( loc_sidereal_time * 180. / pi, 360.)); */
   pdata->hour_angle = atan2( loc[1], loc[0]);
   rotate_vector( loc, observer_lat - pi / 2., 1);
   memcpy( pdata->altaz_loc, loc, 3 * sizeof( double));
   return( 0);
}