C++ 在C+中用不同的参照表示向量和方向+;带本征

C++ 在C+中用不同的参照表示向量和方向+;带本征,c++,eigen,C++,Eigen,假设我有三个参考(A、B和C) 我知道以下价值观: B在A中的位置(作为特征::Vector3d) B在A中的方向(作为本征::四元数) C在B中的位置(作为特征::Vector3d) C在B中的方向(作为本征::四元数) 如何找到C++与EGIN?< /P>中的A的位置和方位? Eigen::Vector3d p_B_in_A = Eigen::Vector3d(...); Eigen::Quaterniond q_B_in_A = Eigen::Quaterniond(...); Ei

假设我有三个参考(A、B和C)

我知道以下价值观:

  • B在A中的位置(作为特征::Vector3d)
  • B在A中的方向(作为本征::四元数)
  • C在B中的位置(作为特征::Vector3d)
  • C在B中的方向(作为本征::四元数)
如何找到C++与EGIN?< /P>中的A的位置和方位?
Eigen::Vector3d p_B_in_A = Eigen::Vector3d(...);
Eigen::Quaterniond q_B_in_A = Eigen::Quaterniond(...);
Eigen::Vector3d p_C_in_B = Eigen::Vector3d(...);
Eigen::Quaterniond q_C_in_B = Eigen::Quaterniond(...);

Eigen::Vector3d p_A_in_C = ???
Eigen::Quaterniond q_A_in_C = ???

我以以下代码为例回答自己的问题:

Eigen::Affine3d B2A = Eigen::Affine3d::Identity();
B2A.translation() << 2 , -1 , 1;
B2A.linear() << std::sqrt(2)/2,  0, std::sqrt(2)/2,
               -std::sqrt(2)/2,  0, std::sqrt(2)/2,
                        0        , -1,         0;

Eigen::Affine3d C2B = Eigen::Affine3d::Identity();
C2B.translation() << 0, 1, 3*sqrt(2);
C2B.linear() <<  1, 0, 0,
                 0,-1, 0,
                 0, 0,-1;

Eigen::Affine3d A2C = C2B.inverse() * B2A.inverse();
// At this point, the orientation of A in C can be found in
// A2C.linear() as a 3x3 rotation matrix. the position of A 
// in C can be found in A2C.translation() as a Vector3d.
Eigen::Affine3d B2A=Eigen::Affine3d::Identity();

B2A.平译():你是在问数学、特征API还是如何用C++编写它?如何用C++写C++,我会编辑它,谢谢。