我有以下功能
transformShape(Shape& shape, Eigen::Matrix4f transformation);
这显然是几何形状的变换,我有一个形式的翻译
Eigen::Vector3f
我希望做这样的事情:
Eigen::Vector3f myVector = //calculate
Eigen::Matrix4f mat = Eigen::Matrix4f::Identity();
mat = myVector * mat;
transformShape(shape, mat);
但这是不可能的,因为我要乘以不同维度的结构,所以我的问题是如何将 Vector3f 转换为具有 4 个维度的 Translation 或 Vector
干杯
最佳答案
vector (x,y,z)的平移矩阵形式
1 0 0 x
0 1 0 y
0 0 1 z
0 0 0 1
阅读http://en.wikipedia.org/wiki/Translation_matrix
还有 Eigen::Translation 你可以使用:
Vector3f v(1,2,3);
Matrix4f m = Affine3f(Translation3f(v)).matrix();
关于c++ - 从 Vector3f 转换为 Matrix4f,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15073259/