/// <summary> /// 由测站地心地固大地坐标计算在天球空间直角坐标的位置和速度。 /// </summary> /// <param name="geo">大地坐标</param> /// <param name="date">时间</param> /// <param name="ellipsoid">参考椭球</param> /// <param name="isKm">是否是千米</param> /// <returns></returns> public static MotionState GetMovingState( GeoCoord geo, Julian date, Geo.Referencing.Ellipsoid ellipsoid = null, bool isKm = true ) { double lat = geo.Lat; double lon = geo.Lon; double alt = geo.Altitude; if (geo.Unit == AngleUnit.Degree) { lat = AngularConvert.DegToRad(lat); lon = AngularConvert.DegToRad(lon); } if (ellipsoid == null) { ellipsoid = Geo.Referencing.Ellipsoid.WGS84; } double f = ellipsoid.Flattening; double a = ellipsoid.SemiMajorAxis; if (isKm) { a = ellipsoid.SemiMajorAxis / 1000.0; } // Calculate Local Mean Sidereal Time (theta) double theta = date.GetLocalMeanSiderealTime(lon); double c = 1.0 / Math.Sqrt(1.0 + f * (f - 2.0) * GeoMath.Sqr(Math.Sin(lat))); double s = GeoMath.Sqr(1.0 - f) * c; double achcp = (a * c + alt) * Math.Cos(lat); XYZ pos = new XYZ(); pos.X = achcp * Math.Cos(theta); pos.Y = achcp * Math.Sin(theta); pos.Z = (a * s + alt) * Math.Sin(lat); XYZ vel = GetVelocityInCelestialSphere(pos); return(new MotionState(pos, vel)); }
public XYZ GetSatPos(OrbitParam param, double time, Geo.Referencing.Ellipsoid ellipsoid = null) { if (ellipsoid == null) { ellipsoid = Geo.Referencing.Ellipsoid.WGS84; } double u = ellipsoid.GM; double a = param.SemiMajor; double tao = param.EpochOfPerigee; double e = param.Eccentricity; double omega = param.ArgumentOfPerigee; double bigOmega = param.LongOfAscension; double i = param.Inclination; //1.由 a 计算平均角速度 double n = Math.Sqrt(u / a / a / a); //2.计算平近点角 M double M = n * (time - tao); //3.计算偏近点角,解开普勒方程。 double E = KeplerEqForEccAnomaly(M, e); double sinE = Math.Sin(E); double cosE = Math.Cos(E); //4.计算矢径 r 和真近点角 f。则已经在极坐标中确定了卫星位置 double r = a * (1.0 - e * Math.Cos(E)); double f = 2.0 * Math.Atan(Math.Sqrt((1 + e) / (1 - e)) * Math.Tan(E / 2)); //5.计算轨道平面坐标(x’,y’) double theta = f + omega; double x1 = r * Math.Cos(theta); double y1 = r * Math.Sin(theta); XYZ xyz1 = new XYZ(x1, y1, 0); //6.计算天球空间直角坐标(x,y,z) XYZ rotation = new XYZ(-i, 0, -bigOmega); XYZ xyz = xyz1.Rotate(rotation); //7.计算瞬时地球坐标系 //Z轴旋转对应时刻的平格林尼治子午面的春分点时角 //8.计算到协议地球坐标系里,如WGS84 return(xyz); }