Reputation: 948
Suppose that I have a matrix Eigen::Matrix<double, 3, 3>
whose entries are
1 2 3
4 5 6
7 8 9
How can I expand it to
1 2 3 0
4 5 6 0
7 8 9 0
0 0 0 1
I need this to multiply 3D affine/projective transformations (4 by 4, under the type Eigen::Transform) with 3D rotation matrices (3 by 3).
Upvotes: 2
Views: 2691
Reputation: 10596
You want conservativeResize:
Eigen::MatrixXf mat;
mat.resize(3,3);
mat << 1, 2, 3, 4, 5, 6, 7, 8, 9;
std::cout << mat << "\n\n";
mat.conservativeResize(4,4);
mat.col(3).setZero();
mat.row(3).setZero();
mat(3, 3) = 1;
std::cout << mat << "\n\n";
Upvotes: 5