我正在尝试对Eigen Matrix<int,200,200>
进行简单的转换,但我无法让Eigen::Translation
工作。由于我对C ++很陌生,因此Eigen的官方文档对我没什么用处。我无法从中提取任何有用的信息。我试图将我的翻译声明为:
Translation<int,2> t(1,0);
希望有一个简单的一行转换,但我不能让它对我的矩阵做任何事情。实际上我甚至不确定这个方法的用途是什么......如果没有,你能不能推荐一些其他的,最好是快速的在圆环上进行矩阵翻译的方法?我正在寻找相当于MATLab的圈子。
答案 0 :(得分:1)
Translation
类模板来自Geometry模块,代表转换转换。它与在数组/矩阵中移动值无关。
根据this discussion,截至2010年,这一转变功能尚未实施,当时的优先级较低。我没有在文档中看到任何迹象表明4年后现在情况有所不同。
所以,你需要自己做。例如:
/// Shifts a matrix/vector row-wise.
/// A negative \a down value is taken to mean shifting up.
/// When passed zero for \a down, the input matrix is returned unchanged.
/// The type \a M can be either a fixed- or dynamically-sized matrix.
template <typename M> M shiftedByRows(const M & in, int down)
{
if (!down) return in;
M out(in.rows(), in.cols());
if (down > 0) down = down % in.rows();
else down = in.rows() - (-down % in.rows());
// We avoid the implementation-defined sign of modulus with negative arg.
int rest = in.rows() - down;
out.topRows(down) = in.bottomRows(down);
out.bottomRows(rest) = in.topRows(rest);
return out;
}