0

我正在尝试实现一些基本的矩阵乘法,以进行翻译。在我看来,乘法应该可以工作,但我得到了这个错误。

二进制 '*=' : 未找到采用 'FW::Vec4f' 类型的右侧操作数的运算符(或没有可接受的转换)

这是我的代码,使用 std 和 FW namepsace

    Mat4f World;

float x, y, z;

World.setCol(0, Vec4f(1, 0, 0, x));
World.setCol(1, Vec4f(0, 1, 0, y));
World.setCol(2, Vec4f(0, 0, 1, z));
World.setCol(3, Vec4f(0, 0, 0, 1));

World *= Vec4f(translation_, 1, 1, 1);
4

1 回答 1

1

矩阵与向量相乘的结果是向量(不是矩阵)。所以这

World *= Vec4f(translation_, 1, 1, 1);

没有意义。那会更像

Vec4f r = World * Vec4f(translation_, 1,1,1);

我的建议:完善你的线性代数。

于 2013-09-15T10:26:26.073 回答