How to rotate 2d image stored in the Eigen matrix in a clockwise direction by 90 degrees?
My code:
Eigen::Matrix<int, n, n> m;
Eigen::Rotation2D rot(90);
auto m1 = m * rot.derived();
But I receive an error:
error: static_assert failed due to requirement 'ProductIsValid || SameSizes' "INVALID_MATRIX_PRODUCT"
Rotating counter clockwise,
Eigen::Matrix<int, n, n> m_rotated_ninty_ccwise = m.transpose().colwise().reverse();
Rotating clockwise,
Eigen::Matrix<int, n, n> m_rotated_ninty_cwise = m.reverse().transpose().reverse();
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With