什么是通过迭代开始求解的最佳方法?

时间:2013-06-02 17:57:14

标签: c++ iteration equation

我正在开发一个家庭项目,我需要通过迭代仔细解决方程式。 M = E - e * sin(E)或其他方式(E - e * sin(E))/ M = 1。 先前已解决M并且在数据消息中给出e。

那么你会为E插入一个数字,然后检查该值到底有多接近1,然后继续调整E的插入值,直到表达式在设定值内为1.00000?

是否有一种“理想”的方法可以在软件中解决这样的问题?

我的计算功能的其余部分显示为 FP64定义为double

bool SV_pos_GAL_L1(int chan, FP64* x, FP64* y, FP64* z) //finds SV ECEF position in orbit at ref GAL system time
{
    FP64 smaxis = pow(GALChannel[chan].L1galData.sqrrtA, 2); //semi major axis
    FP64 nc = sqrt( MU/(pow(smaxis, 3)) ) + GALChannel[chan].L1galData.delta_n; //n corrected
    FP64 Tk = GALChannel[chan].L1galData.TOW - GALChannel[chan].L1galData.Toe;  //time since ephemeris
    FP64 M = GALChannel[chan].L1galData.M0 + nc * Tk; //mean anomaly

    FP64 E;

    FP64 v = atan( ((sqrt(1-pow(GALChannel[chan].L1galData.e,2)) * sin(E)) / (1-(GALChannel[chan].L1galData.e*cos(E))))  /  ((cos(E)-GALChannel[chan].L1galData.e) / (1-(cos(E)*GALChannel[chan].L1galData.e)))  );//true anomaly
    FP64 Omega = GALChannel[chan].L1galData.Omega0 + (Tk * (GALChannel[chan].L1galData.dot_Omega - GALChannel[chan].L1galData.w)) - ( GALChannel[chan].L1galData.w * GALChannel[chan].L1galData.Toe); //corrected longitude of ascinding node

    FP64 ArgLat = v + Omega; //argument of latitude
    FP64 Su = (GALChannel[chan].L1galData.Cus * sin(2*ArgLat)) + ( GALChannel[chan].L1galData.Cuc * cos(2*ArgLat)); //argument of latitude correction
    FP64 Sr = (GALChannel[chan].L1galData.Crs * sin(2*ArgLat)) + ( GALChannel[chan].L1galData.Crc * cos(2*ArgLat)); //radius correction
    FP64 Si = (GALChannel[chan].L1galData.Cis * sin(2*ArgLat)) + ( GALChannel[chan].L1galData.Cic * cos(2*ArgLat)); //inclination correction
    FP64 u = ArgLat + Su; //corrected arg latitude
    FP64 r = smaxis * (1 - (GALChannel[chan].L1galData.e * cos(E))) + Sr; //corrected radius
    FP64 i = GALChannel[chan].L1galData.i0 + Si + (GALChannel[chan].L1galData.dot_i * Tk); //corrected inclination
    FP64 x1 = r * cos(u);
    FP64 y1 = r * sin(u);
    x = (x1 * cos(Omega)) - (y1 * cos(i) * sin(Omega));
    y = (x1 * sin(Omega)) - (y1 * cos(i) * cos(Omega));
    z = y1 * sin(i);

    return true;
}

0 个答案:

没有答案