The MRP (Modified Rodrigues Parameter) class defined in C++ provides an attitude representation for Cartesian coordinate systems. It is derived from the CartesianVector class and includes additional functionalities specific to attitude representation.

The MRP Class

Description and Naming

The MRP class is a templated class with one template argument - T. MRP<T> produces an MRP with three elements of type T. The argument is:

  • T - The type of the MRP elements. This should be a floating point type.

The MRP class inherits from the CartesianVector class but has additional characteristics:

  • It always has three elements.

  • The default constructor initializes it to zeros.

  • It includes functions to convert to other attitude representations, calculate the rate of change based on angular velocity, and convert to the shadow set of MRPs.

For a complete guide on interacting with the MRP class, refer to the Doxygen documentation: MRP Doxygen

Creating an MRP

Description C++ Example Python Example

Default Constructor - Creates an MRP initialized to zeros.

MRP<double> mrp1;
mrp1 = MRP()

Constructor with Initial Value - Creates an MRP initialized with values from an initializer list.

MRP<double> mrp2({0, 0, 0});
mrp2 = MRP([0, 0, 0])

Constructor with std::array - Creates an MRP initialized with values from a std::array.

std::array<double, 3> initial = {0, 0, 0};
MRP<double> mrp3(initial);
initial = [0, 0, 0]
mrp3 = MRP(initial)

Copy Constructor - Creates a new MRP as a copy of another MRP.

MRP<double> mrp4(mrp3);
mrp4 = mrp3

Calculating the Rate of Change

Description C++ Example Python Example

Rate of Change - Calculates the rate of change of the MRP based on the angular velocity vector.

CartesianVector<double, 3> omega;
Matrix<double, 3, 1> mrpdot;
mrp1.rate(omega, mrpdot);
omega = CartesianVector3D()
mrpdot = Matrix31()
mrp1.rate(omega, mrpdot)

Converting to Shadow Set

Description C++ Example Python Example

Convert to Shadow Set - Converts the MRP to its shadow set.

mrp1.shadow();
mrp1.shadow()

Conversions to Other Attitude Representations

Description C++ Example Python Example

Convert to DCM - Converts the MRP to a Direction Cosine Matrix (DCM).

DCM<double> dcm;
mrp1.toDCM(dcm);
dcm = DCM()
mrp1.toDCM(dcm)

Convert to DCM (Return by Value) - Converts and returns the MRP as a DCM.

DCM<double> dcm = mrp1.toDCM();
dcm = mrp1.toDCM()

Convert to Quaternion - Converts the MRP to a quaternion.

Quaternion<double> quat;
mrp1.toQuaternion(quat);
quat = Quaternion()
mrp1.toQuaternion(quat)

Convert to Quaternion (Return by Value) - Converts and returns the MRP as a quaternion.

Quaternion<double> quat = mrp1.toQuaternion();
quat = mrp1.toQuaternion()