test.cpp 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. // test.cpp : 此文件包含 "main" 函数。程序执行将在此处开始并结束。
  2. //
  3. #include <iostream>
  4. #include <Eigen/Dense>
  5. #include <cmath>
  6. using namespace Eigen;
  7. int main()
  8. {
  9. Matrix3d R;
  10. Vector3d v;
  11. v << 0, 1, 0;
  12. R << 0.99296001,0.11836079,0.00459846,
  13. -0.11840988,0.99288611,0.01250104,
  14. -0.00308611, -0.01295754,0.99991129;
  15. RowVector3d ret = R * v ;
  16. //std::cout << ret << std::endl;
  17. /* Quaterniond gnss(0.50, 0, 0, 0.086376804);
  18. auto gnssangle = gnss.matrix().eulerAngles(0, 1, 2);
  19. std::cout << gnssangle *180/3.14 << std::endl; */
  20. // Quaterniond ndt(0, 0, -0.75208, 0.659070); //mian xiang qiao
  21. AngleAxisd rotation_vector;
  22. Quaterniond E(0.99992576,0, 0, -0.001222);
  23. rotation_vector = E;
  24. std::cout << "Axis: \n" << rotation_vector.axis() << std::endl;
  25. auto e = E.matrix().eulerAngles(0, 1, 2).transpose();
  26. std::cout <<"E: \n"<< e * 180 / 3.14 << std::endl;
  27. Quaterniond S(0.713180376625,0, 0, -0.700980);
  28. auto s = S.matrix().eulerAngles(0, 1, 2).transpose();
  29. std::cout <<"S: \n"<< s * 180 / 3.14 << std::endl;
  30. Quaterniond W(0.00165279,0, 0, 0.999984);
  31. rotation_vector = W;
  32. std::cout << "Axis: \n" << rotation_vector.axis() << std::endl;
  33. auto w = W.matrix().eulerAngles(0, 1, 2).transpose();
  34. std::cout << "W: \n" << w * 180 / 3.14 << std::endl;
  35. Quaterniond N(0, 0, 0.7018073567, 0.71236678);
  36. auto n = N.matrix().eulerAngles(0, 1, 2).transpose();
  37. std::cout << "N:\n" << n * 180 / 3.14 << std::endl;
  38. Quaterniond ES(0, 0, -0.39001, 0.920807);
  39. auto es = ES.matrix().eulerAngles(0, 1, 2).transpose();
  40. std::cout << "ES:\n" << es * 180 / 3.14 << std::endl;
  41. Quaterniond WN(0, 0, 0.89513307, 0.445799);
  42. auto wn = WN.matrix().eulerAngles(0, 1, 2).transpose();
  43. std::cout << "WN:\n" << wn * 180 / 3.14 << std::endl;
  44. Quaterniond WS(0, 0, -0.9286255, 0.3710184);
  45. auto ws = WS.matrix().eulerAngles(0, 1, 2).transpose();
  46. std::cout << "WS:\n" << ws * 180 / 3.14 << std::endl;
  47. Quaterniond EN(0, 0, 0.35893411, 0.93336290);
  48. auto en = EN.matrix().eulerAngles(0, 1, 2).transpose();
  49. std::cout << "EN:\n" << en * 180 / 3.14 << std::endl;
  50. // std::cout << ndtangle - gnssangle << std::endl;
  51. return 0;
  52. /*
  53. auto eulerAngle = R.eulerAngles(0, 1, 2);
  54. float x = 3.12909;
  55. float y = 3.13609;
  56. float z = 3.1415926 ;
  57. std::cout << eulerAngle << std::endl;
  58. Eigen::AngleAxisd rollAngle(AngleAxisd(x, Vector3d::UnitX()));
  59. Eigen::AngleAxisd pitchAngle(AngleAxisd(y, Vector3d::UnitY()));
  60. Eigen::AngleAxisd yawAngle(AngleAxisd(z, Vector3d::UnitZ()));
  61. // Eigen::Matrix3d rotation_matrix;
  62. R = rollAngle * pitchAngle * yawAngle;
  63. std::cout << R << std::endl;
  64. eulerAngle = R.eulerAngles(0, 1, 2);
  65. std::cout << eulerAngle << std::endl;
  66. */
  67. }
  68. // 运行程序: Ctrl + F5 或调试 >“开始执行(不调试)”菜单
  69. // 调试程序: F5 或调试 >“开始调试”菜单
  70. // 入门使用技巧:
  71. // 1. 使用解决方案资源管理器窗口添加/管理文件
  72. // 2. 使用团队资源管理器窗口连接到源代码管理
  73. // 3. 使用输出窗口查看生成输出和其他消息
  74. // 4. 使用错误列表窗口查看错误
  75. // 5. 转到“项目”>“添加新项”以创建新的代码文件,或转到“项目”>“添加现有项”以将现有代码文件添加到项目
  76. // 6. 将来,若要再次打开此项目,请转到“文件”>“打开”>“项目”并选择 .sln 文件