Beispiel #1
0
       void SunTimes::Sun_RA_dec(double d,  double &RA,  double &dec,  double &r)
        {
            double lon, obl_ecl, x, y, z;
            lon = 0.0;

            Sunpos(d,  lon,  r);
            //计算太阳的黄道坐标。

            x = r * Cosd(lon);
            y = r * Sind(lon);
            //计算太阳的直角坐标。

            obl_ecl = 23.4393 - 3.563E-7 * d;
            //黄赤交角,同前。

            z = y * Sind(obl_ecl);
            y = y * Cosd(obl_ecl);
            //把太阳的黄道坐标转换成赤道坐标(暂改用直角坐标)。

            RA = Atan2d(y, x);
            dec = Atan2d(z, sqrt(x * x + y * y));
            //最后转成赤道坐标。显然太阳的位置是由黄道坐标方便地直接确定的,但必须转换到赤
            //道坐标里才能结合地球的自转确定我们需要的白昼长度。

        }
Beispiel #2
0
        void SunTimes::Sunpos(double d, double &lon,  double &r)
        {
            double M,//太阳的平均近点角,从太阳观察到的地球(=从地球看到太阳的)距近日点(近地点)的角度。
                w, //近日点的平均黄道经度。
                e, //地球椭圆公转轨道离心率。
                E, //太阳的偏近点角。计算公式见下面。

                x, y,
                v;  //真近点角,太阳在任意时刻的真实近点角。


            M = Revolution(356.0470 + 0.9856002585 * d);//自变量的组成:2000.0时刻太阳黄经为356.0470度,此后每天约推进一度(360度/365天
            w = 282.9404 + 4.70935E-5 * d;//近日点的平均黄经。

            e = 0.016709 - 1.151E-9 * d;//地球公转椭圆轨道离心率的时间演化。以上公式和黄赤交角公式一样,不必深究。

            E = M + e * Radge * Sind(M) * (1.0 + e * Cosd(M));
            x = Cosd(E) - e;
            y = sqrt(1.0 - e * e) * Sind(E);
            r = sqrt(x * x + y * y);
            v = Atan2d(y, x);
            lon = v + w;
            if (lon >= 360.0)
                lon -= 360.0;
        }
Beispiel #3
0
/*-------------------------------------------------------------------------------*/
int calcTasQAngles(MATRIX UB, MATRIX planeNormal, int ss,  tasQEPosition qe, 
		   ptasAngles angles){
  MATRIX R, QC;
  double om, q, theta, cos2t;
  int errorCode = 1;

  R = buildRMatrix(UB, planeNormal, qe, &errorCode);
  if(R == NULL){
    return errorCode;
  }
  

  angles->sgl = Asind(-R[2][0]);
  if(ABS(angles->sgl -90.) < .5){
  	mat_free(R);
    return BADUBORQ;
  }
  /*
    Now, this is slightly different then in the publication by M. Lumsden.
    The reason is that the atan2 helps to determine the sign of om
    whereas the sin, cos formula given by M. Lumsden yield ambiguous signs 
    especially for om.
    sgu = atan(R[2][1],R[2][2]) where:
      R[2][1] = cos(sgl)sin(sgu)
      R[2][2] = cos(sgu)cos(sgl)
    om = atan(R[1][0],R[0][0]) where:
      R[1][0] = sin(om)cos(sgl)
      R[0][0] = cos(om)cos(sgl)
    The definitions of th R components are taken from M. Lumsden
    R-matrix definition.
  */

  om = Atan2d(R[1][0],R[0][0]);
  angles->sgu = Atan2d(R[2][1],R[2][2]);

  QC = tasReflectionToQC(qe,UB);
  if(QC == NULL){
  	mat_free(R);
    return UBNOMEMORY;
  }

  q = vectorLength(QC);
  q = 2.*PI*vectorLength(QC); 
  cos2t = (qe.ki*qe.ki + qe.kf*qe.kf - q*q)/(2. * ABS(qe.ki) * ABS(qe.kf));
  if(ABS(cos2t) > 1.){
  	mat_free(R);
  	killVector(QC);
    return TRIANGLENOTCLOSED;
  }
  angles->sample_two_theta = ss*Acosd(cos2t);
  
  theta = calcTheta(qe.ki, qe.kf,angles->sample_two_theta);
  
  angles->a3 = om + theta;
  /*
    put a3 into -180, 180 properly. We cal always turn by 180 because the
    scattering geometry is symmetric in this respect. It is like looking at
    the scattering plane from the other side
  */
  angles->a3 -= 180.;
  if(angles->a3 < -180.){
    angles->a3 += 360.;
  }

  killVector(QC);
  mat_free(R);

  return 1;
}