euler.h 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  1. /*
  2. ** Command & Conquer Generals(tm)
  3. ** Copyright 2025 Electronic Arts Inc.
  4. **
  5. ** This program is free software: you can redistribute it and/or modify
  6. ** it under the terms of the GNU General Public License as published by
  7. ** the Free Software Foundation, either version 3 of the License, or
  8. ** (at your option) any later version.
  9. **
  10. ** This program is distributed in the hope that it will be useful,
  11. ** but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. ** GNU General Public License for more details.
  14. **
  15. ** You should have received a copy of the GNU General Public License
  16. ** along with this program. If not, see <http://www.gnu.org/licenses/>.
  17. */
  18. /* $Header: /Commando/Code/wwmath/euler.h 5 5/05/01 5:48p Jani_p $ */
  19. /***********************************************************************************************
  20. *** Confidential - Westwood Studios ***
  21. ***********************************************************************************************
  22. * *
  23. * Project Name : Commando / G Math Library *
  24. * *
  25. * $Archive:: /Commando/Code/wwmath/euler.h $*
  26. * *
  27. * Author:: Greg_h *
  28. * *
  29. * $Modtime:: 5/04/01 8:37p $*
  30. * *
  31. * $Revision:: 5 $*
  32. * *
  33. *---------------------------------------------------------------------------------------------*
  34. * Functions: *
  35. * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
  36. #if defined(_MSC_VER)
  37. #pragma once
  38. #endif
  39. #ifndef EULER_H
  40. #define EULER_H
  41. #include "always.h"
  42. #include "matrix3d.h"
  43. #include "quat.h"
  44. /*********************************************************************
  45. Euler Order Types
  46. When creating an EulerAngles object, use one of the below
  47. constants to describe the axis convention.
  48. XYZ - order of the axes
  49. s/r - whether the rotations are applied to a static or
  50. rotating frame.
  51. *********************************************************************/
  52. /* static axes */
  53. extern int EulerOrderXYZs;
  54. extern int EulerOrderXYXs;
  55. extern int EulerOrderXZYs;
  56. extern int EulerOrderXZXs;
  57. extern int EulerOrderYZXs;
  58. extern int EulerOrderYZYs;
  59. extern int EulerOrderYXZs;
  60. extern int EulerOrderYXYs;
  61. extern int EulerOrderZXYs;
  62. extern int EulerOrderZXZs;
  63. extern int EulerOrderZYXs;
  64. extern int EulerOrderZYZs;
  65. /* rotating axes */
  66. extern int EulerOrderXYZr;
  67. extern int EulerOrderXYXr;
  68. extern int EulerOrderXZYr;
  69. extern int EulerOrderXZXr;
  70. extern int EulerOrderYZXr;
  71. extern int EulerOrderYZYr;
  72. extern int EulerOrderYXZr;
  73. extern int EulerOrderYXYr;
  74. extern int EulerOrderZXYr;
  75. extern int EulerOrderZXZr;
  76. extern int EulerOrderZYXr;
  77. extern int EulerOrderZYZr;
  78. /*********************************************************************
  79. EulerAnglesClass
  80. The purpose for this class is mainly for conversion. You can
  81. choose a convention for the order of your rotations and then
  82. convert matrices into a set of euler angles. You don't really
  83. want to use this at run-time to convert matrices into angles.
  84. The guts of this implementation is based on the article in Graphics
  85. Gems IV by Ken Shoemake. The original article is on page 222.
  86. *********************************************************************/
  87. class EulerAnglesClass
  88. {
  89. public:
  90. EulerAnglesClass(void) : Order(0) { Angle[0] = 0.0; Angle[1] = 0.0; Angle[2] = 0.0; };
  91. EulerAnglesClass(const Matrix3D & from,int order);
  92. void From_Matrix(const Matrix3D & from,int order);
  93. void To_Matrix(Matrix3D & M);
  94. double Get_Angle(int i);
  95. private:
  96. double Angle[3];
  97. int Order;
  98. };
  99. #endif /*EULER_H*/