Tudat/Astrodynamics/MissionSegments/multiRevolutionLambertTargeterIzzo.cpp
//! Sanity check number of revolutions.
Sanity check number of revolutions.
Sanity check number of revolutions .
void MultiRevolutionLambertTargeterIzzo::sanityCheckNumberOfRevolutions( )
{
    if ( maximumNumberOfRevolutions == NO_MAXIMUM_REVOLUTIONS )
    {
        int copyOfOriginalNumberOfRevolutions = numberOfRevolutions;
        numberOfRevolutions = static_cast< int >(
                    normalizedTimeOfFlight / (
                        mathematical_constants::PI / 2.0
                        * std::sqrt( 2.0 * normalizedSemiPerimeter
                                     * normalizedSemiPerimeter
                                     * normalizedSemiPerimeter ) ) );
        if( numberOfRevolutions != 0)
        {
            try
            {
                computeRootTimeOfFlight();
            }
            catch( basic_mathematics::ConvergenceException )
            {
                numberOfRevolutions--;
            }
        }
        maximumNumberOfRevolutions = numberOfRevolutions;
        numberOfRevolutions = copyOfOriginalNumberOfRevolutions;
    }
    if ( numberOfRevolutions > maximumNumberOfRevolutions )
    {
        throw std::runtime_error(  "Number of revolutions specified in Lambert problem is larger than possible. Specified number of revolutions is " +
                                   std::to_string( numberOfRevolutions )  + " while the maximum is " +
                                   std::to_string( maximumNumberOfRevolutions ) );
    }
}
void MultiRevolutionLambertTargeterIzzo :: sanityCheckNumberOfRevolutions ( ) { if ( maximumNumberOfRevolutions == NO_MAXIMUM_REVOLUTIONS ) { int copyOfOriginalNumberOfRevolutions = numberOfRevolutions ; numberOfRevolutions = static_cast < int > ( normalizedTimeOfFlight / ( mathematical_constants :: PI / 2.0 * std :: sqrt ( 2.0 * normalizedSemiPerimeter * normalizedSemiPerimeter * normalizedSemiPerimeter ) ) ) ; if ( numberOfRevolutions != 0 ) { try { computeRootTimeOfFlight ( ) ; } catch ( basic_mathematics :: ConvergenceException ) { numberOfRevolutions -- ; } } maximumNumberOfRevolutions = numberOfRevolutions ; numberOfRevolutions = copyOfOriginalNumberOfRevolutions ; } if ( numberOfRevolutions > maximumNumberOfRevolutions ) { throw std :: runtime_error ( " " + std :: to_string ( numberOfRevolutions ) + " " + std :: to_string ( maximumNumberOfRevolutions ) ) ; } }
Sanity check number of revolutions.
Sanity check number of revolutions .
// If not yet defined, calculate number of revolutions possible. // Temporarily store specified number, as numberOfRevolutions is needed to calculate max // (this is a tricky way to work, but on the other hand this makes this approach decidedly // different from PyKEP routines and it also happens only once per object). // Calculate first guess of maximum, by dividing the time of flight of the minimum energy // ellipse by the normalized time of flight. // If the current guess for the maximum is non-zero, then additional analysis is required to // determine the correct maximum. // The following try-block is meant to check whether the solution converges or not. If // the current guess for the maximum number of revolutions is correct, then the problem // will converge. If it does not, an exception will be thrown stating that it did not // converge. Catching this exception allows to decrease the guess only when the // exception occurs, and not under other circumstances. // Compute root (no further information is required) // If the rootfinder did not converge, then the current guess is wrong and needs to // be decreased // No further analysis is needed of the current guess is equal to zero. // Maximum is now found. // Reinstating original number of revolutions specified. // Default: compare maximum with specified number of revolutions. // If specified is larger than maximum, no solution is possible. // Throw exception. // Else, nothing wrong.