Ejemplo n.º 1
0
void slaEqecl ( double dr, double dd, double date,
                double *dl, double *db )
/*
**  - - - - - - - - -
**   s l a E q e c l
**  - - - - - - - - -
**
**  Transformation from J2000.0 equatorial coordinates to
**  ecliptic coordinates.
**
**  (double precision)
**
**  Given:
**     dr,dd       double      J2000.0 mean RA,Dec (radians)
**     date        double      TDB (loosely ET) as Modified Julian Date
**                                              (JD-2400000.5)
**  Returned:
**     *dl,*db     double      ecliptic longitude and latitude
**                             (mean of date, IAU 1980 theory, radians)
**
**
**  Called:
**     slaDcs2c, slaPrec, slaEpj, slaDmxv, slaEcmat, slaDcc2s,
**     slaDranrm, slaDrange
**
**
**  Last revision:   31 October 1993
**
**  Copyright P.T.Wallace.  All rights reserved.
*/
{
   double rmat[3][3], v1[3], v2[3];

/* Spherical to Cartesian */
   slaDcs2c ( dr, dd, v1 );

/* Mean J2000 to mean of date */
   slaPrec ( 2000.0, slaEpj ( date ), rmat );
   slaDmxv ( rmat, v1, v2 );

/* Equatorial to ecliptic */
   slaEcmat ( date, rmat );
   slaDmxv ( rmat, v2, v1 );

/* Cartesian to spherical */
   slaDcc2s ( v1, dl, db );

/* Express in conventional ranges */
   *dl = slaDranrm ( *dl );
   *db = slaDrange ( *db );
}
Ejemplo n.º 2
0
void projCircle(double racen, double deccen, double radius, double val) {
  int i, j, ip, in, sign, pixval;
  float mx[NCIRC], my[NCIRC];
  double t, axialvec[3], cenvec[3], angvec[3], rotvec[3], rmat[3][3];
  double ra[NCIRC], rap[NCIRC], ran[NCIRC];
  double dec[NCIRC], decp[NCIRC], decn[NCIRC];
  double x, y;

  // make Cartesian representation of the vector pointing to center
  slaDcs2c(racen, deccen, cenvec);

  // make Cartesian representation of a vector pointing radius away
  if(deccen>0.0)
    slaDcs2c(racen, deccen-radius, angvec);
  else
    slaDcs2c(racen, deccen+radius, angvec);

  t = 0;
  for(i=0; i<NCIRC; i++) {
    // length of axial vector is angle of rotation
    for(j=0;j<3;j++) axialvec[j] = cenvec[j]*t;
    // get rotation matrix
    slaDav2m(axialvec, rmat);
    // apply rotation to angled vector
    slaDmxv(rmat, angvec, rotvec);
    // get new ra, dec
    slaDcc2s(rotvec, &(ra[i]), &(dec[i]));
    //    if(ra[i] < 0 && racen > 0.0) ra[i] += 2*M_PI;
    //    if(ra[i] > 0 && racen < 0.0) ra[i] -= 2*M_PI;
    // update rotation angle
    t += 2.0*M_PI/(double) (NCIRC-1);
  }

  pixval = rint((__minind*(__maxval-val) + __maxind*(val-__minval))/
               (__maxval-__minval));

  // saturate properly
  pixval = MIN(__maxind, pixval);
  pixval = MAX(__minind, pixval);

  cpgsci(pixval);

  // determine if the polygon wraps around
  sign = 0;
  for(i=0; i<NCIRC-1; i++) {
    if(dec[i]>deccen && ra[i+1]*ra[i] < 0 && ra[i+1]<ra[i]) sign = 1;
  }

  // if so, draw two polygons separately
  if(sign) {
    in = 0;
    ip = 0;
    for(i=0; i<NCIRC; i++) {
      if(ra[i]<0.0) {
        ran[in] = ra[i]; decn[in] = dec[i]; in++;
      }
      else {
        ran[in] = -0.99999*M_PI; decn[in] = dec[i]; in++;
      }
      if(ra[i]>0.0) {
        rap[ip] = ra[i]; decp[ip] = dec[i]; ip++;
      }
      else {
        rap[ip] = 0.99999*M_PI; decp[ip] = dec[i]; ip++;
      }
    }
    
    for(i=0; i<ip; i++) {
      // Hammer-Aitoff projection
      project(rap[i], decp[i], &x, &y);
      mx[i] = x; my[i] = y;
    }
    cpgpoly(ip,mx,my);
    
    for(i=0; i<in; i++) {
      // Hammer-Aitoff projection
      project(ran[i], decn[i], &x, &y);
      mx[i] = x; my[i] = y;
    }
    cpgpoly(in,mx,my);
  }
  // otherwise draw only one
  else {
    for(i=0; i<NCIRC; i++) {
      // Hammer-Aitoff projection
      project(ra[i], dec[i], &x, &y);
      mx[i] = x; my[i] = y;
    }
    cpgpoly(NCIRC,mx,my);
  }

  cpgsci(1);
}