Beispiel #1
0
        /// <summary>
        /// 求空间两点连线与地球的交点(靠近点1的交点),返回在ZB.le_J,le_W,赤道坐标。R1,R2单位是千米
        /// </summary>
        /// <param name="J1"></param>
        /// <param name="W1"></param>
        /// <param name="R1"></param>
        /// <param name="J2"></param>
        /// <param name="W2"></param>
        /// <param name="R2"></param>
        public static void line_earth(double J1, double W1, double R1, double J2, double W2, double R2)
        {
            double x1 = R1 * Math.Cos(W1) * Math.Cos(J1), y1 = R1 * Math.Cos(W1) * Math.Sin(J1), z1 = R1 * Math.Sin(W1);
            double x2 = R2 * Math.Cos(W2) * Math.Cos(J2), y2 = R2 * Math.Cos(W2) * Math.Sin(J2), z2 = R2 * Math.Sin(W2);
            double dx = x2 - x1, dy = y2 - y1, dz = z2 - z1, f = 0.99664719, r = LunarHelper.cs_rEar; //直线参数及地球参数
            double x, y, z, lh = 0;

            if (Math.Abs(dx) < Math.Abs(dy)) //必要时仑换
            {
                lh = dx; dx = dy; dy = lh; lh = x1; x1 = y1; y1 = lh; lh = 1;
            }
            double a = dy / dx, b = y1 - a * x1, c = dz / dx / f, d = z1 / f - c * x1;
            double A = a * a + c * c + 1, B = a * b + c * d, C = b * b + d * d - r * r, D = B * B - A * C;

            if (D < 0)
            {
                ZB.le_J = ZB.le_W = 100; return;
            }                                               //返回100表示无解
            D = Math.Sqrt(D); if (x1 + B / A < 0)
            {
                D = -D;
            }
            x        = (-B + D) / A; y = a * x + b; z = (c * x + d) / f;
            ZB.le_R1 = Math.Sqrt((x - x1) * (x - x1) + (y - y1) * (y - y1) + (z - z1) * (z - z1));
            if (lh != 0)
            {
                lh = x; x = y; y = lh;
            }
            ZB.le_W = Math.Atan(z / Math.Sqrt(x * x + y * y));
            ZB.le_J = LunarHelper.rad2mrad(Math.Atan2(y, x));
        }
Beispiel #2
0
        /// <summary>
        /// 时差计算(高精度)
        /// </summary>
        /// <param name="t"></param>
        /// <returns></returns>
        public static double shiCha(double t)
        {
            double t2 = t * t, t3 = t2 * t, t4 = t3 * t, t5 = t4 * t;
            double L = (1753469512 + 628331965331.8 * t + 5296.74 * t2 + 0.432 * t3 - 0.1124 * t4 - 0.00009 * t5 + 630 * Math.Cos(6 + 0.3 * t)) / 1000000000 + Math.PI - 20.5 / LunarHelper.rad;

            double E, dE, dL;

            double[] z = new double[2];                                     // C#: 待定(?)
            dL = -17.2 * Math.Sin(2.1824 - 33.75705 * t) / LunarHelper.rad; //黄经章
            dE = 9.2 * Math.Cos(2.1824 - 33.75705 * t) / LunarHelper.rad;   //交角章
            E  = ZB.hcjj(t) + dE;                                           //真黄赤交角

            //地球坐标
            z[0] = XL.E_Lon(t, 50) + Math.PI + ZB.gxc_sunLon(t) + dL;
            z[1] = -(2796 * Math.Cos(3.1987 + 8433.46616 * t) + 1016 * Math.Cos(5.4225 + 550.75532 * t) + 804 * Math.Cos(3.88 + 522.3694 * t)) / 1000000000;

            ZB.llrConv(z, E); //z太阳地心赤道坐标
            z[0] -= dL * Math.Cos(E);

            L = LunarHelper.rad2mrad(L - z[0]);
            if (L > Math.PI)
            {
                L -= LunarHelper.pi2;
            }
            return(L / LunarHelper.pi2); //单位是周(天)
        }
Beispiel #3
0
        /// <summary>
        /// 球面坐标旋转
        /// </summary>
        /// <param name="JW"></param>
        /// <param name="E"></param>
        public static void llrConv(double[] JW, double E)
        {
            //黄道赤道坐标变换,赤到黄E取负
            double sinE = Math.Sin(E), cosE = Math.Cos(E);
            double sinJ = Math.Sin(JW[0]), cosJ = Math.Cos(JW[0]);
            double sinW = Math.Sin(JW[1]), cosW = Math.Cos(JW[1]), tanW = Math.Tan(JW[1]);

            JW[0] = Math.Atan2(sinJ * cosE - tanW * sinE, cosJ);
            JW[1] = Math.Asin(cosE * sinW + sinE * cosW * sinJ);
            JW[0] = LunarHelper.rad2mrad(JW[0]);
        }
Beispiel #4
0
        /// <summary>
        /// 球面坐标旋转
        /// </summary>
        /// <param name="JW"></param>
        /// <param name="E"></param>
        public static void llrConv(LunarInfoListT <double> JW, double E)    // C#: 新扩展出来的方法
        {
            //黄道赤道坐标变换,赤到黄E取负
            double sinE = Math.Sin(E), cosE = Math.Cos(E);
            double sinJ = Math.Sin((JW[0])), cosJ = Math.Cos((JW[0]));
            double sinW = Math.Sin((JW[1]));
            double cosW = Math.Cos((JW[1]));
            double tanW = Math.Tan((JW[1]));

            JW[0] = Math.Atan2(sinJ * cosE - tanW * sinE, cosJ);
            JW[1] = Math.Asin(cosE * sinW + sinE * cosW * sinJ);
            JW[0] = LunarHelper.rad2mrad((JW[0]));
        }
Beispiel #5
0
 /// <summary>
 /// 章动同时影响恒星时和天体坐标,所以不计算章动。返回时角及赤经纬
 /// </summary>
 /// <param name="jd"></param>
 /// <param name="H0"></param>
 /// <param name="z"></param>
 public static void Mcoord(double jd, double H0, LunarInfoListT <double> z)
 {
     XL.M_coord((jd + SZJ.dt) / 36525, z, 30, 20, 8); //低精度月亮赤经纬
     ZB.llrConv(z, SZJ.E);                            //转为赤道坐标
     z.H = LunarHelper.rad2mrad(ZB.gst(jd, SZJ.dt) - SZJ.L - z[0]);
     if (z.H > Math.PI)
     {
         z.H -= LunarHelper.pi2;                //得到此刻天体时角
     }
     if (H0 != 0)
     {
         z.H0 = SZJ.getH(0.7275 * LunarHelper.cs_rEar / z[2] - 34 * 60 / LunarHelper.rad, z[1]);          //升起对应的时角
     }
 }
Beispiel #6
0
        /// <summary>
        /// 时差计算(低精度),误差约在1秒以内
        /// </summary>
        /// <param name="t"></param>
        /// <returns></returns>
        public static double shiCha2(double t)
        {
            double L = (1753469512 + 628331965331.8 * t + 5296.74 * t * t) / 1000000000 + Math.PI;

            double[] z = new double[2];    // C#: 待定(?)
            double   E = (84381.4088 - 46.836051 * t) / LunarHelper.rad;

            z[0] = XL.E_Lon(t, 5) + Math.PI; z[1] = 0; // 地球坐标
            ZB.llrConv(z, E);                          // z太阳地心赤道坐标
            L = LunarHelper.rad2mrad(L - z[0]);
            if (L > Math.PI)
            {
                L -= LunarHelper.pi2;
            }
            return(L / LunarHelper.pi2);     // 单位是周(天)
        }
Beispiel #7
0
        }                                   // = 0;

        #endregion

        #endregion 公共属性



        #region 公共方法
        /// <summary>
        /// 计算 sun_moon 类的成员。参数:T是力学时,站点经度L,纬度fa,海拔high(千米)
        /// </summary>
        /// <param name="T">力学时</param>
        /// <param name="L">站点经度</param>
        /// <param name="fa">站点纬度</param>
        /// <param name="high">海拔</param>
        public void calc(double T, double L, double fa, double high)
        {
            //基本参数计算
            this.T   = T;
            this.L   = L; this.fa = fa;
            this.dt  = JD.deltatT2(T);                                        //TD-UT
            this.jd  = T - this.dt;                                           //UT
            T       /= 36525; ZB.nutation(T);
            this.dL  = ZB.dL;                                                 //黄经章
            this.dE  = ZB.dE;                                                 //交角章动
            this.E   = ZB.hcjj(T) + this.dE;                                  //真黄赤交角
            this.gst = ZB.gst(this.jd, this.dt) + this.dL * Math.Cos(this.E); //真恒星时(不考虑非多项式部分)
            double[] z = new double[4];

            //=======月亮========
            //月亮黄道坐标
            XL.M_coord(T, z, -1, -1, -1);                                                                   //月球坐标
            z[0]     = LunarHelper.rad2mrad(z[0] + ZB.gxc_moonLon(T) + this.dL); z[1] += ZB.gxc_moonLat(T); //补上月球光行差及章动
            this.mHJ = z[0]; this.mHW = z[1]; this.mR = z[2];                                               //月球视黄经,视黄纬,地月质心距

            //月球赤道坐标
            ZB.llrConv(z, this.E);            //转为赤道坐标
            this.mCJ = z[0]; this.mCW = z[1]; //月球视赤经,月球赤纬

            //月亮时角计算
            this.mShiJ = LunarHelper.rad2mrad(this.gst - L - z[0]); //得到此刻天体时角
            if (this.mShiJ > Math.PI)
            {
                this.mShiJ -= LunarHelper.pi2;
            }

            //修正了视差的赤道坐标
            ZB.parallax(z, this.mShiJ, fa, high); //视差修正
            this.mCJ2 = z[0]; this.mCW2 = z[1]; this.mR2 = z[2];

            //月亮时角坐标
            z[0] += Math.PI / 2d - this.gst + L;  //转到相对于地平赤道分点的赤道坐标(时角坐标)

            //月亮地平坐标
            ZB.llrConv(z, Math.PI / 2 - fa);  //转到地平坐标(只改经纬度)
            z[0]     = LunarHelper.rad2mrad(Math.PI / 2 - z[0]);
            this.mDJ = z[0]; this.mDW = z[1]; //方位角,高度角
            if (z[1] > 0)
            {
                z[1] += ZB.AR2(z[1]);         //大气折射修正
            }
            this.mPJ = z[0]; this.mPW = z[1]; //方位角,高度角

            //=======太阳========
            //太阳黄道坐标
            XL.E_coord(T, z, -1, -1, -1);                                                 //地球坐标
            z[0]     = LunarHelper.rad2mrad(z[0] + Math.PI + ZB.gxc_sunLon(T) + this.dL); //补上太阳光行差及章动
            z[1]     = -z[1] + ZB.gxc_sunLat(T);                                          //z数组为太阳地心黄道视坐标
            this.sHJ = z[0]; this.sHW = z[1]; this.sR = z[2];                             //太阳视黄经,视黄纬,日地质心距

            //太阳赤道坐标
            ZB.llrConv(z, this.E);            //转为赤道坐标
            this.sCJ = z[0]; this.sCW = z[1]; //太阳视赤经,视赤纬

            //太阳时角计算
            this.sShiJ = LunarHelper.rad2mrad(this.gst - L - z[0]); //得到此刻天体时角
            if (this.sShiJ > Math.PI)
            {
                this.sShiJ -= LunarHelper.pi2;
            }

            //修正了视差的赤道坐标
            ZB.parallax(z, this.sShiJ, fa, high); //视差修正
            this.sCJ2 = z[0]; this.sCW2 = z[1]; this.sR2 = z[2];

            //太阳时角坐标
            z[0] += Math.PI / 2 - this.gst + L;  //转到相对于地平赤道分点的赤道坐标

            //太阳地平坐标
            ZB.llrConv(z, Math.PI / 2 - fa);
            z[0] = LunarHelper.rad2mrad(Math.PI / 2 - z[0]);
            //z[1] -= 8.794/rad/z[2]*Math.cos(z[1]); //直接在地平坐标中视差修正(这里把地球看为球形,精度比ZB.parallax()稍差一些)
            this.sDJ = z[0]; this.sDW = z[1]; //方位角,高度角

            if (z[1] > 0)
            {
                z[1] += ZB.AR2(z[1]);         //大气折射修正
            }
            this.sPJ = z[0]; this.sPW = z[1]; //方位角,高度角

            //=======其它========
            //时差计算
            double t = T / 10; double t2 = t * t, t3 = t2 * t, t4 = t3 * t, t5 = t4 * t;
            double Lon = (1753469512 + 6283319653318 * t + 529674 * t2 + 432 * t3 - 1124 * t4 - 9 * t5 + 630 * Math.Cos(6 + 3 * t)) / 1000000000 + Math.PI - 20.5 / LunarHelper.rad; //修正了光行差的太阳平黄经

            Lon = LunarHelper.rad2mrad(Lon - (this.sCJ - this.dL * Math.Cos(this.E)));                                                                                               //(修正了光行差的平黄经)-(不含dL*cos(E)的视赤经)
            if (Lon > Math.PI)
            {
                Lon -= LunarHelper.pi2;        //得到时差,单位是弧度
            }
            this.sc = Lon / LunarHelper.pi2;   //时差(单位:日)

            //真太阳与平太阳
            this.pty = this.jd - L / LunarHelper.pi2;           //平太阳时
            this.zty = this.jd - L / LunarHelper.pi2 + this.sc; //真太阳时

            //视半径
            //this.mRad = XL.moonRad(this.mR,this.mDW);  //月亮视半径(角秒)
            this.mRad     = 358473400d / this.mR2;                                                                     //月亮视半径(角秒)
            this.sRad     = 959.63 / this.sR2;                                                                         //太阳视半径(角秒)
            this.e_mRad   = 358473400d / this.mR;                                                                      //月亮地心视半径(角秒)
            this.eShadow  = (LunarHelper.cs_rEarA / this.mR * LunarHelper.rad - (959.63 - 8.794) / this.sR) * 51 / 50; //地本影在月球向径处的半径(角秒),式中51/50是大气厚度补偿
            this.eShadow2 = (LunarHelper.cs_rEarA / this.mR * LunarHelper.rad + (959.63 + 8.794) / this.sR) * 51 / 50; //地半影在月球向径处的半径(角秒),式中51/50是大气厚度补偿
            this.mIll     = XL.moonIll(T);                                                                             //月亮被照面比例

            //中心食计算
            if (Math.Abs(LunarHelper.rad2rrad(this.mCJ - this.sCJ)) < 50 / 180 * Math.PI)
            {
                ZB.line_earth(this.mCJ, this.mCW, this.mR, this.sCJ, this.sCW, this.sR * LunarHelper.cs_AU);
                this.zx_J = LunarHelper.rad2rrad(this.gst - ZB.le_J);
                this.zx_W = ZB.le_W; //无解返回值是100
            }
            else
            {
                this.zx_J = this.zx_W = 100;
            }
        }
Beispiel #8
0
 /// <summary>
 /// 直角坐标转球
 /// </summary>
 /// <param name="x"></param>
 /// <param name="y"></param>
 /// <param name="z"></param>
 /// <param name="q"></param>
 public static void xyz2llr(double x, double y, double z, double[] q)
 {
     q[2] = Math.Sqrt(x * x + y * y + z * z);
     q[1] = Math.Asin(z / q[2]);
     q[0] = LunarHelper.rad2mrad(Math.Atan2(y, x));
 }