I have four column vectors. I need to append them to make a four by four matrix. Is there a constructor or something for that?
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
回答1:
You can also append them using the comma initializer syntax:
m << v1, v2, v3, v4;
The matrix m mus have been properly resized first.
回答2:
A quick check on the docs:
Vector4f v1(1,0,0,0);
Vector4f v2(0,1,0,0);
Vector4f v3(0,0,1,0);
Vector4f v4(0,0,0,1);
Matrix4f m;
m.row(0) = v1;
m.row(1) = v2;
m.row(2) = v3;
m.row(3) = v4;
std::cout << m << std::endl;
output:
1,0,0,0
0,1,0,0
0,0,1,0
0,0,0,1