2

I'm writing code to implement rotation matrix/Direction Cosine Matrix (DCM).

I know the rotation angle at compile time, so in order to save on execution time, I wish to initialize the rotation matrix at compile time. but I'm getting the below-mentioned errors.

Code:

Eigen::Matrix3d lcs_rotation_matrix (
    -1.0,  0.0, 0.0,
     0.0, -1.0, 0.0,
     0.0,  0.0, 1.0
);

Code:

Eigen::Matrix3d rotation_matrix {
    -1.0,  0.0, 0.0,
    0.0, -1.0, 0.0,
    0.0,  0.0, 1.0
};

Code:

const Eigen::Matrix3d lcs_rotation_matrix {
    -1.0,  0.0, 0.0,
     0.0, -1.0, 0.0,
     0.0,  0.0, 1.0
};

Code:

static const Eigen::Matrix3d lcs_rotation_matrix {
    -1.0,  0.0, 0.0,
     0.0, -1.0, 0.0,
     0.0,  0.0, 1.0
};

Error:

Eigen/src/Core/PlainObjectBase.h:538:7: error: static assertion failed due to requirement 'PlainObjectBase<Eigen::Matrix<double, 3, 3, 0, 3, 3>>::IsVectorAtCompileTime': THIS_METHOD_IS_ONLY_FOR_VECTORS_OF_A_SPECIFIC_SIZE

0

1 Answer 1

7

Matrix3d constructor expects vectors, not scalars:

Eigen::Matrix3d lcs_rotation_matrix{
    {-1.0,  0.0, 0.0},
    { 0.0, -1.0, 0.0},
    { 0.0,  0.0, 1.0},
};
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.