Eigen3 を使用して、C++ で次の関数を作成しました。
MatrixXf transformPoints(MatrixXf X, MatrixXf P)
{
// create a new matrix to host points
MatrixXf tempMatrix = MatrixXf::Zero(4, P.cols());
// extract rotational and traslational parts from X
MatrixXf rotmat = tempMatrix.block<2,2>(0,0);
Vector2f traMat = tempMatrix.block<2,1>(0,2);
// separate points from normals
// int cols_of_P = P.cols();
MatrixXf points = tempMatrix.block<2,P.cols()>(0,0);
MatrixXf normals = tempMatrix.block<2,P.cols()>(2,0);
}
私の考えでは、最後の 2 行で、p から部分行列を抽出できるはずです。その列の数は事前にわかっていませんが、P のサイズによって異なります。次のエラーが表示されます。
home/ubisum/fuerte_workspace/thesis_pack/src/least_squares_utilities.h: In function ‘Eigen::MatrixXf least_squares::transformPoints(Eigen::MatrixXf, Eigen::MatrixXf)’:
/home/ubisum/fuerte_workspace/thesis_pack/src/least_squares_utilities.h:18:47: error: ‘P’ cannot appear in a constant-expression
/home/ubisum/fuerte_workspace/thesis_pack/src/least_squares_utilities.h:18:49: error: ‘.’ cannot appear in a constant-expression
/home/ubisum/fuerte_workspace/thesis_pack/src/least_squares_utilities.h:18:54: error: a function call cannot appear in a constant-expression
/home/ubisum/fuerte_workspace/thesis_pack/src/least_squares_utilities.h:18:60: error: no matching function for call to ‘Eigen::Matrix<float, -0x00000000000000001, -0x00000000000000001>::block(int, int)’
次の変更も試しました。
int cols_of_P = P.cols();
MatrixXf points = tempMatrix.block<2,cols_of_P>(0,0);
MatrixXf normals = tempMatrix.block<2,cols_of_P>(2,0);
しかし、何も変わりませんでした。手伝って頂けますか?
ありがとうございました。