2017-02-23 23 views
0

我的测试方法如下:征:: Affine3d旋转意想不到的结果

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 

有人可以给我解释上述行为,请?

回答

0

在尝试任何其他转换之前,我没有将转换设置为标识。要修复它添加行默认构造之后:

Eigen::Affine3d act; 
act.setIdentity(); 

或者与单位矩阵构建:

Eigen::Affine3d act(Eigen::Affine3d::Identity()); 
+1

或只是在产品链的删除权的行为实例。 – ggael