如何在 Eigen 中翻译一个矩阵(4x4)?
//identity matrix 4x4
/*type=*/Eigen::Matrix<float, 4, 4> /*name=*/result = Eigen::Matrix<float, 4, 4>::Identity();
//translation vector
// 3.0f
// 4.0f
// 5.0f
Translation<float, 3> trans(3.0f, 4.0f, 5.0f);
即,我有矩阵:
1.0 0.0 0.0 0.0
0.0 1.0 0.0 0.0
0.0 0.0 1.0 0.0
0.0 0.0 0.0 1.0
我想得到这个:
1.0 0.0 0.0 3.0
0.0 1.0 0.0 4.0
0.0 0.0 1.0 5.0
0.0 0.0 0.0 1.0
对吧?我该怎么做?
我能做到:
result(0, 3) = 3.0f;
result(1, 3) = 4.0f;
result(2, 3) = 5.0f;
但这并不优雅。 =) 你有什么建议?
最佳答案
像这样:
Affine3f transform(Translation3f(1,2,3));
Matrix4f matrix = transform.matrix();
Here是包含更多详细信息的文档。
关于c++ - 如何在 Eigen 中翻译矩阵(4x4)?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20323487/