Tudat/Astrodynamics/BasicAstrodynamics/attitudeElementConversions.cpp
//! Convert modified Rodrigues parameters to quaternions.
Convert modified Rodrigues parameters to quaternions.
Convert modified Rodrigues parameters to quaternions .
Eigen::Vector4d convertModifiedRodriguesParametersToQuaternionElements( const Eigen::Vector4d& modifiedRodriguesParameterElements )
{
    Eigen::Vector4d convertedQuaternionElements;
    Eigen::Vector3d modifiedRodriguesParametersVector =
            modifiedRodriguesParameterElements.segment( sigma1ModifiedRodriguesParametersIndex, 3 );
    double modifiedRodriguesParametersMagnitudeSquared = modifiedRodriguesParametersVector.squaredNorm( );
    double conversionSign = ( int( modifiedRodriguesParameterElements( shadowFlagModifiedRodriguesParametersIndex ) ) == 1 ) ?
                - 1.0 : 1.0; 
    convertedQuaternionElements( etaQuaternionIndex ) = conversionSign *
            ( 1.0 - modifiedRodriguesParametersMagnitudeSquared ) /
            ( 1.0 + modifiedRodriguesParametersMagnitudeSquared );
    convertedQuaternionElements.segment( epsilon1QuaternionIndex, 3 ) = conversionSign *
            2.0 / ( 1.0 + modifiedRodriguesParametersMagnitudeSquared ) *
            modifiedRodriguesParametersVector;
    return convertedQuaternionElements;
}
Eigen :: Vector4d convertModifiedRodriguesParametersToQuaternionElements ( const Eigen :: Vector4d & modifiedRodriguesParameterElements ) { Eigen :: Vector4d convertedQuaternionElements ; Eigen :: Vector3d modifiedRodriguesParametersVector = modifiedRodriguesParameterElements . segment ( sigma1ModifiedRodriguesParametersIndex , 3 ) ; double modifiedRodriguesParametersMagnitudeSquared = modifiedRodriguesParametersVector . squaredNorm ( ) ; double conversionSign = ( int ( modifiedRodriguesParameterElements ( shadowFlagModifiedRodriguesParametersIndex ) ) == 1 ) ? - 1.0 : 1.0 ; convertedQuaternionElements ( etaQuaternionIndex ) = conversionSign * ( 1.0 - modifiedRodriguesParametersMagnitudeSquared ) / ( 1.0 + modifiedRodriguesParametersMagnitudeSquared ) ; convertedQuaternionElements . segment ( epsilon1QuaternionIndex , 3 ) = conversionSign * 2.0 / ( 1.0 + modifiedRodriguesParametersMagnitudeSquared ) * modifiedRodriguesParametersVector ; return convertedQuaternionElements ; }
Convert modified Rodrigues parameters to quaternions.
Convert modified Rodrigues parameters to quaternions .
// Declare eventual output vector // Extract modified Rodrigues parameters // Precompute often used variables // Convert modified Rodrigues parameters to quaternions // converion is slightly different for SMRP and MRP // Give output