Tudat/Mathematics/GeometricShapes/conicalFrustum.cpp
//! Get surface derivative on conical frustum.
Get surface derivative on conical frustum.
Get surface derivative on conical frustum .
Eigen::VectorXd ConicalFrustum::getSurfaceDerivative(
        const double lengthFraction, const double azimuthAngle,
        const int powerOfLengthFractionDerivative, const int powerOfAzimuthAngleDerivative )
{
    Eigen::VectorXd derivative_ = Eigen::VectorXd( 3 );
    if ( powerOfLengthFractionDerivative < 0 || powerOfAzimuthAngleDerivative < 0 )
    {
        derivative_( 0 ) = 0.0;
        derivative_( 1 ) = 0.0;
        derivative_( 2 ) = 0.0;
        throw std::runtime_error( " No negative derivatives allowed when retrieving cone derivative " );
    }
    else if ( powerOfLengthFractionDerivative == 0 && powerOfAzimuthAngleDerivative == 0 )
    {
        derivative_ = getSurfacePoint( lengthFraction, azimuthAngle );
    }
    else
    {
        Eigen::VectorXd derivative1Contribution_ = Eigen::VectorXd( 3 );
        Eigen::VectorXd derivative2Contribution_ = Eigen::VectorXd( 3 );
        switch( powerOfLengthFractionDerivative )
        {
        case( 0 ):
            derivative1Contribution_( 0 ) = 0.0;
            derivative1Contribution_( 1 ) = 0.0;
            derivative1Contribution_( 2 ) = -length_ * lengthFraction;
            break;
        case( 1 ):
            derivative1Contribution_( 0 ) = 0.0;
            derivative1Contribution_( 1 ) = 0.0;
            derivative1Contribution_( 2 ) = -length_;
            break;
        default:
            derivative1Contribution_( 0 ) = 0.0;
            derivative1Contribution_( 1 ) = 0.0;
            derivative1Contribution_( 2 ) = 0.0;
            break;
        }
        switch( powerOfAzimuthAngleDerivative % 4 )
        {
        case( 0 ):
            derivative2Contribution_( 0 ) = -sin( azimuthAngle );
            derivative2Contribution_( 1 ) = cos( azimuthAngle );
            derivative2Contribution_( 2 ) = 0.0;
            break;
        case( 1 ):
            derivative2Contribution_( 0 ) = -cos( azimuthAngle );
            derivative2Contribution_( 1 ) = -sin( azimuthAngle );
            derivative2Contribution_( 2 ) = 0.0;
            break;
        case( 2 ):
            derivative2Contribution_( 0 ) = sin( azimuthAngle );
            derivative2Contribution_( 1 ) = -cos( azimuthAngle );
            derivative2Contribution_( 2 ) = 0.0;
            break;
        case( 3 ):
            derivative2Contribution_( 0 ) = cos( azimuthAngle );
            derivative2Contribution_( 1 ) = sin( azimuthAngle );
            derivative2Contribution_( 2 ) = 0.0;
            break;
        default:
            throw std::runtime_error( " Bad value for powerOfAzimuthAngleDerivative ( mod 4 ) of value is not 0, 1, 2 or 3 ");
        }
        derivative_( 0 ) = derivative1Contribution_( 0 ) * derivative2Contribution_( 0 );
        derivative_( 1 ) = derivative1Contribution_( 1 ) * derivative2Contribution_( 1 );
        derivative_( 2 ) = derivative1Contribution_( 2 ) * derivative2Contribution_( 2 );
        derivative_ = scalingMatrix_ * rotationMatrix_ * derivative_;
    }
    return derivative_;
}
Eigen :: VectorXd ConicalFrustum :: getSurfaceDerivative ( const double lengthFraction , const double azimuthAngle , const int powerOfLengthFractionDerivative , const int powerOfAzimuthAngleDerivative ) { Eigen :: VectorXd derivative_ = Eigen :: VectorXd ( 3 ) ; if ( powerOfLengthFractionDerivative < 0 || powerOfAzimuthAngleDerivative < 0 ) { derivative_ ( 0 ) = 0.0 ; derivative_ ( 1 ) = 0.0 ; derivative_ ( 2 ) = 0.0 ; throw std :: runtime_error ( " " ) ; } else if ( powerOfLengthFractionDerivative == 0 && powerOfAzimuthAngleDerivative == 0 ) { derivative_ = getSurfacePoint ( lengthFraction , azimuthAngle ) ; } else { Eigen :: VectorXd derivative1Contribution_ = Eigen :: VectorXd ( 3 ) ; Eigen :: VectorXd derivative2Contribution_ = Eigen :: VectorXd ( 3 ) ; switch ( powerOfLengthFractionDerivative ) { case ( 0 ) : derivative1Contribution_ ( 0 ) = 0.0 ; derivative1Contribution_ ( 1 ) = 0.0 ; derivative1Contribution_ ( 2 ) = - length_ * lengthFraction ; break ; case ( 1 ) : derivative1Contribution_ ( 0 ) = 0.0 ; derivative1Contribution_ ( 1 ) = 0.0 ; derivative1Contribution_ ( 2 ) = - length_ ; break ; default : derivative1Contribution_ ( 0 ) = 0.0 ; derivative1Contribution_ ( 1 ) = 0.0 ; derivative1Contribution_ ( 2 ) = 0.0 ; break ; } switch ( powerOfAzimuthAngleDerivative % 4 ) { case ( 0 ) : derivative2Contribution_ ( 0 ) = - sin ( azimuthAngle ) ; derivative2Contribution_ ( 1 ) = cos ( azimuthAngle ) ; derivative2Contribution_ ( 2 ) = 0.0 ; break ; case ( 1 ) : derivative2Contribution_ ( 0 ) = - cos ( azimuthAngle ) ; derivative2Contribution_ ( 1 ) = - sin ( azimuthAngle ) ; derivative2Contribution_ ( 2 ) = 0.0 ; break ; case ( 2 ) : derivative2Contribution_ ( 0 ) = sin ( azimuthAngle ) ; derivative2Contribution_ ( 1 ) = - cos ( azimuthAngle ) ; derivative2Contribution_ ( 2 ) = 0.0 ; break ; case ( 3 ) : derivative2Contribution_ ( 0 ) = cos ( azimuthAngle ) ; derivative2Contribution_ ( 1 ) = sin ( azimuthAngle ) ; derivative2Contribution_ ( 2 ) = 0.0 ; break ; default : throw std :: runtime_error ( " " ) ; } derivative_ ( 0 ) = derivative1Contribution_ ( 0 ) * derivative2Contribution_ ( 0 ) ; derivative_ ( 1 ) = derivative1Contribution_ ( 1 ) * derivative2Contribution_ ( 1 ) ; derivative_ ( 2 ) = derivative1Contribution_ ( 2 ) * derivative2Contribution_ ( 2 ) ; derivative_ = scalingMatrix_ * rotationMatrix_ * derivative_ ; } return derivative_ ; }
Get surface derivative on conical frustum.
Get surface derivative on conical frustum .
// Declare and set size of derivative vector. // No negative derivatives may be retrieved, a zero vector is returned in // this case. // When requesting the zeroth derivative with respect to the two // independent variables, the surface point is returned. // The contributions of the two parametrizing variables are determined and // then multiplied component-wise. // Declare and set sizes of contribution vectors. // For all higher derivatives, all components are zero. // Since this derivative is "cyclical", as it is only dependant on sines // and cosines, only the "modulo 4"th derivative need be determined. // Derivatives are determined from the form of the cylindrical coordinates, // see basic_mathematics::coordinateConversions::convertSphericalToCartesian // Combine contributions to derivative. // Rotate derivatives to take into account rotation of cone. // Return derivative vector.