I wrote the following function in C++, using Eigen3:
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);
}
In my idea, on last two rows, I should be able to extract a submatrix from p, whose number of column is not known a priori, but it depends on P's size. I get the following error:
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)’
I even tried the following modification:
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);
but nothing changed. Can you help me?
Thank you.