EulerAngles.h 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. // David Eberly, Geometric Tools, Redmond WA 98052
  2. // Copyright (c) 1998-2020
  3. // Distributed under the Boost Software License, Version 1.0.
  4. // https://www.boost.org/LICENSE_1_0.txt
  5. // https://www.geometrictools.com/License/Boost/LICENSE_1_0.txt
  6. // Version: 4.0.2019.08.13
  7. #pragma once
  8. #include <Mathematics/Vector.h>
  9. // The Euler angle data structure for representing rotations. See the
  10. // document
  11. // https://www.geometrictools.com/Documentation/EulerAngles.pdf
  12. namespace WwiseGTE
  13. {
  14. // Factorization into Euler angles is not necessarily unique. Let the
  15. // integer indices for the axes be (N0,N1,N2), which must be in the set
  16. // {(0,1,2),(0,2,1),(1,0,2),(1,2,0),(2,0,1),(2,1,0),
  17. // (0,1,0),(0,2,0),(1,0,1),(1,2,1),(2,0,2),(2,1,2)}
  18. // Let the corresponding angles be (angleN0,angleN1,angleN2). If the
  19. // result is ER_NOT_UNIQUE_SUM, then the multiple solutions occur because
  20. // angleN2+angleN0 is constant. If the result is ER_NOT_UNIQUE_DIF, then
  21. // the multiple solutions occur because angleN2-angleN0 is constant. In
  22. // either type of nonuniqueness, the function returns angleN0=0.
  23. enum EulerResult
  24. {
  25. // The solution is invalid (incorrect axis indices).
  26. ER_INVALID,
  27. // The solution is unique.
  28. ER_UNIQUE,
  29. // The solution is not unique. A sum of angles is constant.
  30. ER_NOT_UNIQUE_SUM,
  31. // The solution is not unique. A difference of angles is constant.
  32. ER_NOT_UNIQUE_DIF
  33. };
  34. template <typename Real>
  35. class EulerAngles
  36. {
  37. public:
  38. EulerAngles()
  39. :
  40. axis{0, 0, 0},
  41. angle{ (Real)0, (Real)0, (Real)0 },
  42. result(ER_INVALID)
  43. {
  44. }
  45. EulerAngles(int i0, int i1, int i2, Real a0, Real a1, Real a2)
  46. :
  47. axis{ i0, i1, i2 },
  48. angle{ a0, a1, a2 },
  49. result(ER_UNIQUE)
  50. {
  51. }
  52. std::array<int, 3> axis;
  53. std::array<Real, 3> angle;
  54. // This member is set during conversions from rotation matrices,
  55. // quaternions, or axis-angles.
  56. EulerResult result;
  57. };
  58. }