我的测试方法如下:
TEST_METHOD(RotationTest1)
{
std::stringstream log;
Eigen::Affine3d t(
Eigen::AngleAxisd(M_PI / 4, Eigen::Vector3d::UnitZ())*
Eigen::AngleAxisd(M_PI / 8, Eigen::Vector3d::UnitY())
);
log << "Expected:\n" << t.rotation();
Eigen::Affine3d act;
act = Eigen::AngleAxisd(M_PI / 4, Eigen::Vector3d::UnitZ())*
Eigen::AngleAxisd(M_PI / 8, Eigen::Vector3d::UnitY()) * act;
//act.prerotate(Eigen::AngleAxisd(M_PI / 8, Eigen::Vector3d::UnitY()));
//act.prerotate(Eigen::AngleAxisd(M_PI / 4, Eigen::Vector3d::UnitZ()));
log << "\nActual:\n" << act.rotation();
Logger::WriteMessage(log.str().c_str());
Assert::IsTrue(t.rotation().isApprox(act.rotation()));
}这产生了以下不一致的输出:
Expected:
0.653281 -0.707107 0.270598
0.653281 0.707107 0.270598
-0.382683 0 0.92388
Actual:
-0.756394 0.645492 -0.10587
-0.324051 -0.510375 -0.79656
-0.568206 -0.568206 0.595217有没有人能给我解释一下上面的行为?
发布于 2017-02-23 11:07:43
在尝试任何其他转换之前,我没有将转换设置为identity。要解决此问题,请在default结构后添加以下行:
Eigen::Affine3d act;
act.setIdentity();或者使用单位矩阵进行构造:
Eigen::Affine3d act(Eigen::Affine3d::Identity());https://stackoverflow.com/questions/42405936
复制相似问题