InertialTrajProcess.cpp 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. #include "InertialTrajProcess.h"
  2. void InertialTrajProcess::TrajRotate(int *pos, float rotateMatrix[4])
  3. {
  4. /*
  5. 本函数为将地理坐标的航向转移到自定义的X方向(鞋子朝向)
  6. */
  7. float pos_f[3];
  8. pos_f[2] = float(pos[2]) * 0.01f;
  9. pos_f[1] = float(pos[1]) * 0.01f;
  10. pos_f[0] = float(pos[0]) * 0.01f;
  11. float posTemp[3];
  12. posTemp[2] = pos_f[2];
  13. posTemp[0] = rotateMatrix[0] * float(pos_f[0]) + rotateMatrix[1] * float(pos_f[1]);
  14. posTemp[1] = rotateMatrix[2] * float(pos_f[0]) + rotateMatrix[3] * float(pos_f[1]);
  15. pos[0] = (int)(posTemp[0] * 100.0f);
  16. pos[1] = (int)(posTemp[1] * 100.0f);
  17. pos[2] = (int)(posTemp[2] * 100.0f);
  18. }
  19. void InertialTrajProcess::TrajRotate(int* pos)
  20. {
  21. /*
  22. 本函数为将地理坐标的航向转移到硬件所指的X方向(鞋子朝向)
  23. */
  24. float pos_f[3];
  25. pos_f[2] = float(pos[2]) * 0.01f;
  26. pos_f[1] = float(pos[1]) * 0.01f;
  27. pos_f[0] = float(pos[0]) * 0.01f;
  28. float posTemp[3];
  29. posTemp[2] = pos_f[2];
  30. posTemp[0] = cos(curheading) * float(pos_f[0]) + sin(curheading) * float(pos_f[1]);
  31. posTemp[1] = -sin(curheading) * float(pos_f[0]) + cos(curheading) * float(pos_f[1]);
  32. pos[0] = (int)(posTemp[0] * 100.0f);
  33. pos[1] = (int)(posTemp[1] * 100.0f);
  34. pos[2] = (int)(posTemp[2] * 100.0f);
  35. //std::cout << "DanceGame:Rotate : " << pos[0] << " " << pos[1] << " " << pos[2] << std::endl;
  36. }
  37. void InertialTrajProcess::ResetHeading(int heading)
  38. {
  39. /*
  40. 重置朝向
  41. */
  42. curheading = (float)(heading * 0.0001f);
  43. }
  44. InertialTrajProcess::InertialTrajProcess()
  45. {
  46. memset(shoesPos, 0, 3 * sizeof(int));
  47. curheading = 0.0f;
  48. }