InertialTrajProcess.cpp 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. #include "InertialTrajProcess.h"
  2. #include <math.h>
  3. void InertialTrajProcess::TrajRotate(int *pos, float rotateMatrix[4])
  4. {
  5. /*
  6. ������Ϊ����������ĺ���ת�Ƶ��Զ����X����Ь�ӳ���
  7. */
  8. float pos_f[3];
  9. pos_f[2] = float(pos[2]) * 0.01f;
  10. pos_f[1] = float(pos[1]) * 0.01f;
  11. pos_f[0] = float(pos[0]) * 0.01f;
  12. float posTemp[3];
  13. posTemp[2] = pos_f[2];
  14. posTemp[0] = rotateMatrix[0] * float(pos_f[0]) + rotateMatrix[1] * float(pos_f[1]);
  15. posTemp[1] = rotateMatrix[2] * float(pos_f[0]) + rotateMatrix[3] * float(pos_f[1]);
  16. pos[0] = (int)(posTemp[0] * 100.0f);
  17. pos[1] = (int)(posTemp[1] * 100.0f);
  18. pos[2] = (int)(posTemp[2] * 100.0f);
  19. }
  20. void InertialTrajProcess::TrajRotate(int* pos)
  21. {
  22. /*
  23. ������Ϊ����������ĺ���ת�Ƶ�Ӳ����ָ��X����Ь�ӳ���
  24. */
  25. float pos_f[3];
  26. pos_f[2] = float(pos[2]) * 0.01f;
  27. pos_f[1] = float(pos[1]) * 0.01f;
  28. pos_f[0] = float(pos[0]) * 0.01f;
  29. float posTemp[3];
  30. posTemp[2] = pos_f[2];
  31. posTemp[0] = cos(curheading) * float(pos_f[0]) + sin(curheading) * float(pos_f[1]);
  32. posTemp[1] = -sin(curheading) * float(pos_f[0]) + cos(curheading) * float(pos_f[1]);
  33. pos[0] = (int)(posTemp[0] * 100.0f);
  34. pos[1] = (int)(posTemp[1] * 100.0f);
  35. pos[2] = (int)(posTemp[2] * 100.0f);
  36. //std::cout << "DanceGame:Rotate : " << pos[0] << " " << pos[1] << " " << pos[2] << std::endl;
  37. }
  38. void InertialTrajProcess::ResetHeading(int heading)
  39. {
  40. /*
  41. ����
  42. */
  43. curheading = (float)(heading * 0.0001f);
  44. }
  45. InertialTrajProcess::InertialTrajProcess()
  46. {
  47. memset(shoesPos, 0, 3 * sizeof(int));
  48. curheading = 0.0f;
  49. }