Tudat/Astrodynamics/MissionSegments/multiRevolutionLambertTargeterIzzo.cpp
//! Solve the time of flight equation for x (for multiple revolutions).
Solve the time of flight equation for x (for multiple revolutions).
Solve the time of flight equation for x ( for multiple revolutions ) .
double MultiRevolutionLambertTargeterIzzo::computeRootTimeOfFlight( )
{
    using mathematical_constants::PI;
    double x1, x2;
    if ( isRightBranch )
    { 
        x1 = std::tan( .7234 * PI / 2.0 );
        x2 = std::tan( .5234 * PI / 2.0 );
    }
    else
    { 
        x1 = std::tan( -.5234 * PI / 2.0 );
        x2 = std::tan( -.2234 * PI / 2.0 );
    }
    double y1 = computeTimeOfFlight( std::atan( x1 ) * 2.0 / PI ) - normalizedTimeOfFlight;
    double y2 = computeTimeOfFlight( std::atan( x2 ) * 2.0 / PI ) - normalizedTimeOfFlight;
    double rootFindingError = 1.0, xNew = 0.0, yNew = 0.0;
    int iterator = 0;
    while ( ( rootFindingError > convergenceTolerance ) && ( y1 != y2 )
            && ( iterator < maximumNumberOfIterations ) )
    {
        iterator++;
        xNew = ( x1 * y2 - y1 * x2 ) / ( y2 - y1 );
        yNew = computeTimeOfFlight( std::atan( xNew ) * 2.0 / PI ) - normalizedTimeOfFlight;
        x1 = x2;
        y1 = y2;
        x2 = xNew;
        y2 = yNew;
        rootFindingError = std::fabs( x1 - xNew );
    }
    if ( iterator == maximumNumberOfIterations )
    {
        throw basic_mathematics::ConvergenceException(
                    "Multi-Revolution Lambert targeter failed to converge to a solution. Reached the maximum number of iterations: %d"
                    + std::to_string( maximumNumberOfIterations ) );;
    }
    double xParameter = std::atan( xNew ) * 2.0 / PI;
    return xParameter;
}
double MultiRevolutionLambertTargeterIzzo :: computeRootTimeOfFlight ( ) { using mathematical_constants :: PI ; double x1 , x2 ; if ( isRightBranch ) { x1 = std :: tan ( .7234 * PI / 2.0 ) ; x2 = std :: tan ( .5234 * PI / 2.0 ) ; } else { x1 = std :: tan ( -.5234 * PI / 2.0 ) ; x2 = std :: tan ( -.2234 * PI / 2.0 ) ; } double y1 = computeTimeOfFlight ( std :: atan ( x1 ) * 2.0 / PI ) - normalizedTimeOfFlight ; double y2 = computeTimeOfFlight ( std :: atan ( x2 ) * 2.0 / PI ) - normalizedTimeOfFlight ; double rootFindingError = 1.0 , xNew = 0.0 , yNew = 0.0 ; int iterator = 0 ; while ( ( rootFindingError > convergenceTolerance ) && ( y1 != y2 ) && ( iterator < maximumNumberOfIterations ) ) { iterator ++ ; xNew = ( x1 * y2 - y1 * x2 ) / ( y2 - y1 ) ; yNew = computeTimeOfFlight ( std :: atan ( xNew ) * 2.0 / PI ) - normalizedTimeOfFlight ; x1 = x2 ; y1 = y2 ; x2 = xNew ; y2 = yNew ; rootFindingError = std :: fabs ( x1 - xNew ) ; } if ( iterator == maximumNumberOfIterations ) { throw basic_mathematics :: ConvergenceException ( " " + std :: to_string ( maximumNumberOfIterations ) ) ; ; } double xParameter = std :: atan ( xNew ) * 2.0 / PI ; return xParameter ; }
Solve the time of flight equation for x (for multiple revolutions).
Solve the time of flight equation for x ( for multiple revolutions ) .
// Define initial guesses for abcissae (x) and ordinates (y). // right branch solution. // left branch solution. // Declare and initialize root-finding parameters. // Root-finding loop. // Update iterator. // Compute new x-value. // Compute corresponding y-value. // Update abcissae and ordinates. // Compute root-finding error. // Verify that root-finder has converged. // Revert to x parameter.