示例#1
0
double 
MoonPhases::FindNext( double julianDay, Angle phaseAngle )
{
    const double synodicMonth = 29.5305888531;
    Angle lunarPhase = LunarPhase( julianDay );
    Angle phaseDiff = phaseAngle - lunarPhase;
    phaseDiff.NormalizePositive( );
    double offset = phaseDiff.Cycles() * synodicMonth;
    double estimate = julianDay + offset;
    double lowEst = estimate - 0.5;
    double highEst = estimate + 0.5;
    MoonPhaseFunc phaseFunc( phaseAngle );
#ifdef DEBUG
    bool brcktRslt =
#endif
            RootFinder::BracketRoot( phaseFunc, &lowEst, &highEst );
    Assert( brcktRslt );
    double phaseJD;
#ifdef DEBUG
    bool rootRslt =
#endif
            RootFinder::Brent( phaseFunc, &phaseJD, lowEst, highEst, 1.e-4 );
    Assert( rootRslt );
    double ut_tdb = - TDB_UT( phaseJD ).Days();
    return  (phaseJD + ut_tdb);
}
TimeIncrement 
EquationOfTime( double julianDay )
{
    shared_ptr< JPLEphemeris > spEphem
            = JPLEphemeris::GetEphemeris( julianDay );
    if ( ! spEphem )
        return TimeIncrement( 0 );
    Angle meanSolarLong = MeanSolarLongitude( julianDay );
    Point3D earthBarycentric;
    Vector3D earthBarycentricVelocity;
#ifdef DEBUG
    bool earthRslt =
#endif
            GetEarthBarycentric( julianDay, &earthBarycentric,
                                 &earthBarycentricVelocity, spEphem );
    Assert( earthRslt );
    Matrix3D precessionMatrix = Precession( julianDay ).Matrix( );
    Nutation nutation( 0., 0. );
    if ( spEphem->NutationAvailable() )
    {
#ifdef DEBUG
        bool nutRslt =
#endif
                spEphem->GetNutation( julianDay, &nutation );
        Assert( nutRslt );
    }
    Angle meanObliquity = MeanObliquity( julianDay );
    Angle trueObliquity = TrueObliquity( meanObliquity, nutation );
    Matrix3D nutAndPrecMatrix = nutation.Matrix( meanObliquity )
            * precessionMatrix;
    JPLBarycentricEphemeris sunEphem( spEphem, JPLEphemeris::Sun );
    Point3D sunPos = GetSunApparentPlace( julianDay, sunEphem,
                                          earthBarycentric,
                                          earthBarycentricVelocity,
                                          nutAndPrecMatrix );
    Equatorial sunEquatorial( sunPos );
    Angle eotAngle = meanSolarLong  -  Angle( 0.0057183, Angle::Degree )
            -  sunEquatorial.RightAscension()
            +  nutation.NutLongitude() * Cos( trueObliquity );
    return TimeIncrement( eotAngle.Cycles() );
}