#include "SateOrbit.h" //#define EIGEN_USE_MKL_ALL //#define EIGEN_VECTORIZE_SSE4_2 //#include #include #include #include #include //#include #include using namespace std; using namespace Eigen; using namespace arma; OrbitPoly::OrbitPoly() { } OrbitPoly::OrbitPoly(int polynum, Eigen::MatrixX polySatellitePara, double SatelliteModelStartTime) { if (polySatellitePara.rows() != polynum||polySatellitePara.cols()!=6) { throw exception("轨道模型参数形状不一致"); } this->polySatellitePara = polySatellitePara; this->SatelliteModelStartTime = SatelliteModelStartTime; this->polynum = polynum; } OrbitPoly::~OrbitPoly() { } Eigen::MatrixX OrbitPoly::SatelliteSpacePoint(Eigen::MatrixX satellitetime) { Eigen::MatrixX result= SatelliteSpacePoints(satellitetime, this->SatelliteModelStartTime, this->polySatellitePara, this->polynum); return result; } Eigen::MatrixX OrbitPoly::SatelliteSpacePoint(long double satellitetime) { if (this->polySatellitePara.rows() != polynum || this->polySatellitePara.cols() != 6) { throw exception("the size of satellitetime has error!! row: p1,p2,p3,p4 col: x,y,z,vx,vy,vz "); } // 更新轨道时间 double satellitetime2 =double( satellitetime - this->SatelliteModelStartTime); Eigen::MatrixX satetime(1, polynum); for (int i = 0; i < polynum; i++) { satetime(0, i) = pow(satellitetime2, i); } // 计算 Eigen::MatrixX satellitePoints(1, 6); satellitePoints = satetime * polySatellitePara; return satellitePoints; } /// /// 获取指定时刻的卫星轨道坐标 /// /// 卫星时刻 /// 模型起算时间 /// 模型参数[x1,y1,z1,vx1,vy1,vz1; x2,y2,z2,vx2,vy2,vz2; ..... ] /// 模型参数数量 /// 卫星坐标 Eigen::MatrixX SatelliteSpacePoints(Eigen::MatrixX& satellitetime, double SatelliteModelStartTime, Eigen::MatrixX& polySatellitePara, int polynum) { if (satellitetime.cols() != 1) { throw exception("the size of satellitetime has error!!"); } if (polySatellitePara.rows() != polynum || polySatellitePara.cols() != 6) { throw exception("the size of satellitetime has error!! row: p1,p2,p3,p4 col: x,y,z,vx,vy,vz "); } // 更新轨道时间 int satellitetime_num = satellitetime.rows(); satellitetime = satellitetime.array() - SatelliteModelStartTime; Eigen::MatrixX satelliteTime(satellitetime_num, polynum); for (int i = 0; i < polynum; i++) { satelliteTime.col(i) = satellitetime.array().pow(i); } // 计算 Eigen::MatrixX satellitePoints(satellitetime_num, 6); satellitePoints = satelliteTime * polySatellitePara; return satellitePoints; }