Tudat/Astrodynamics/TrajectoryDesign/planetTrajectory.cpp
//! Return a vector of positions and times from ephemeris data for a certain epoch and duration.
Return a vector of positions and times from ephemeris data for a certain epoch and duration.
Return a vector of positions and times from ephemeris data for a certain epoch and duration .
void returnPlanetTrajectory( const ephemerides::EphemerisPointer & ephemerisPtr,
                             const double centralBodyGravitationalParameter,
                             const double startingEpochMJD2000,
                             const double duration,
                             const double maximumTimeStep,
                             std::vector < Eigen::Vector3d >& positionVector,
                             std::vector < double >& timeVector,
                             const double startingTime )
{
    double MJD2000 = 51544.5;
    int numberOfSteps = std::ceil( duration / maximumTimeStep );
    double timeStep = duration / numberOfSteps;
    positionVector.resize( numberOfSteps + 1 );
    timeVector.resize( numberOfSteps + 1 );
    Eigen::Vector6d temporaryCartesianElements;
    double timeMJD2000 = startingEpochMJD2000 + MJD2000;
    double time = 0.0;
    for ( int counter = 0; counter < numberOfSteps + 1; counter++ )
    {
        temporaryCartesianElements = ephemerisPtr->getCartesianState( time );
        positionVector[ counter ] = temporaryCartesianElements.segment( 0, 3 );
        timeVector[ counter ] = time + startingTime;
        time += timeStep;
        timeMJD2000 += timeStep / physical_constants::JULIAN_DAY;
    }
}
void returnPlanetTrajectory ( const ephemerides :: EphemerisPointer & ephemerisPtr , const double centralBodyGravitationalParameter , const double startingEpochMJD2000 , const double duration , const double maximumTimeStep , std :: vector < Eigen :: Vector3d > & positionVector , std :: vector < double > & timeVector , const double startingTime ) { double MJD2000 = 51544.5 ; int numberOfSteps = std :: ceil ( duration / maximumTimeStep ) ; double timeStep = duration / numberOfSteps ; positionVector . resize ( numberOfSteps + 1 ) ; timeVector . resize ( numberOfSteps + 1 ) ; Eigen :: Vector6d temporaryCartesianElements ; double timeMJD2000 = startingEpochMJD2000 + MJD2000 ; double time = 0.0 ; for ( int counter = 0 ; counter < numberOfSteps + 1 ; counter ++ ) { temporaryCartesianElements = ephemerisPtr -> getCartesianState ( time ) ; positionVector [ counter ] = temporaryCartesianElements . segment ( 0 , 3 ) ; timeVector [ counter ] = time + startingTime ; time += timeStep ; timeMJD2000 += timeStep / physical_constants :: JULIAN_DAY ; } }
Return a vector of positions and times from ephemeris data for a certain epoch and duration.
Return a vector of positions and times from ephemeris data for a certain epoch and duration .
// Calculate the number of intermediate steps required and the corresponding time step. // Resize the position and time vectors. Note that the "+ 1" comes from the end points. // Initiate variables to temporarily store the ephemeris data. // Initiate time variable in JD for extracting data, and a time variable in seconds to store // the time in the vector. //    std::shared_ptr<ephemerides::ApproximatePlanetPositions> approxEphemerisPtr = //            std::dynamic_pointer_cast<ephemerides::ApproximatePlanetPositions>(ephemerisPtr); //    double timeJD2000; //    double timeSecondsSinceEpoch; // Start the for loop to obtain positions along the trajectory. // Get Keplerian state of the planet at the corresponding time. // Store the position and time // Update the times.