The DCM class defined in C++ provides a Direction Cosine Matrix (DCM) representation for attitude in Cartesian coordinate systems. It is derived from the Matrix class and includes additional functionalities specific to attitude representation.

The DCM Class

Description and Naming

The DCM class is a templated class with one template argument - T. DCM<T> produces a 3x3 matrix of type T. The argument is:

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

The DCM class inherits from the Matrix class but has additional characteristics:

  • It is always a 3x3 matrix.

  • The default constructor initializes it to the identity matrix.

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

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

Creating a DCM

Description C++ Example Python Example

Default Constructor - Creates a DCM initialized to the identity matrix.

DCM<double> dcm1;
dcm1 = DCM()

Constructor with Initial Value - Creates a DCM initialized with values from a initializer list.

DCM<double> dcm2({{1, 0, 0}, {0, 1, 0}, {0, 0, 1}});
dcm2 = DCM([[1, 0, 0], [0, 1, 0], [0, 0, 1]])

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

std::array<std::array<double, 3>, 3> initial = {{1, 0, 0}, {0, 1, 0}, {0, 0, 1}};
DCM<double> dcm3(initial);
initial = [[1, 0, 0], [0, 1, 0], [0, 0, 1]]
dcm3 = DCM(initial)

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

DCM<double> dcm4(dcm3);
dcm4 = dcm3

Inverting a DCM

Description C++ Example Python Example

Inverse of a DCM - Calculates the inverse of the DCM.

DCM<double> inverseDcm;
dcm1.inverse(inverseDcm);
inverseDcm = DCM()
dcm1.inverse(inverseDcm)

Inverse of a DCM (Return by Value) - Calculates and returns the inverse of the DCM.

DCM<double> inverseDcm = dcm1.inverse();
inverseDcm = dcm1.inverse()

Dynamics and Kinematics

Description C++ Example Python Example

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

CartesianVector<double, 3> omega;
Matrix<double, 3, 3> dcmdot;
dcm1.rate(omega, dcmdot);
omega = CartesianVector3D()
dcmdot = Matrix3D()
dcm1.rate(omega, dcmdot)

Conversions to Other Attitude Representations

Description C++ Example Python Example

Convert to Euler321 - Converts the DCM to a 321 Euler sequence.

Euler321<double> euler;
dcm1.toEuler321(euler);
euler = Euler321()
dcm1.toEuler321(euler)

Convert to Euler321 (Return by Value) - Converts and returns the DCM as a 321 Euler sequence.

Euler321<double> euler = dcm1.toEuler321();
euler = dcm1.toEuler321()

Convert to Quaternion - Converts the DCM to a quaternion.

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

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

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

Convert to MRP - Converts the DCM to a Modified Rodrigues Parameter (MRP).

MRP<double> mrp;
dcm1.toMRP(mrp);
mrp = MRP()
dcm1.toMRP(mrp)

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

MRP<double> mrp = dcm1.toMRP();
mrp = dcm1.toMRP()