智慧水务管理系统 - 精河县供水工程综合管理平台

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. import Check from "../Core/Check.js";
  2. import Matrix3 from "../Core/Matrix3.js";
  3. import Matrix4 from "../Core/Matrix4.js";
  4. /**
  5. * An enum describing the x, y, and z axes and helper conversion functions.
  6. *
  7. * @enum {number}
  8. */
  9. const Axis = {
  10. /**
  11. * Denotes the x-axis.
  12. *
  13. * @type {number}
  14. * @constant
  15. */
  16. X: 0,
  17. /**
  18. * Denotes the y-axis.
  19. *
  20. * @type {number}
  21. * @constant
  22. */
  23. Y: 1,
  24. /**
  25. * Denotes the z-axis.
  26. *
  27. * @type {number}
  28. * @constant
  29. */
  30. Z: 2,
  31. };
  32. /**
  33. * Matrix used to convert from y-up to z-up
  34. *
  35. * @type {Matrix4}
  36. * @constant
  37. */
  38. Axis.Y_UP_TO_Z_UP = Matrix4.fromRotationTranslation(
  39. // Rotation about PI/2 around the X-axis
  40. Matrix3.fromArray([1, 0, 0, 0, 0, 1, 0, -1, 0]),
  41. );
  42. /**
  43. * Matrix used to convert from z-up to y-up
  44. *
  45. * @type {Matrix4}
  46. * @constant
  47. */
  48. Axis.Z_UP_TO_Y_UP = Matrix4.fromRotationTranslation(
  49. // Rotation about -PI/2 around the X-axis
  50. Matrix3.fromArray([1, 0, 0, 0, 0, -1, 0, 1, 0]),
  51. );
  52. /**
  53. * Matrix used to convert from x-up to z-up
  54. *
  55. * @type {Matrix4}
  56. * @constant
  57. */
  58. Axis.X_UP_TO_Z_UP = Matrix4.fromRotationTranslation(
  59. // Rotation about -PI/2 around the Y-axis
  60. Matrix3.fromArray([0, 0, 1, 0, 1, 0, -1, 0, 0]),
  61. );
  62. /**
  63. * Matrix used to convert from z-up to x-up
  64. *
  65. * @type {Matrix4}
  66. * @constant
  67. */
  68. Axis.Z_UP_TO_X_UP = Matrix4.fromRotationTranslation(
  69. // Rotation about PI/2 around the Y-axis
  70. Matrix3.fromArray([0, 0, -1, 0, 1, 0, 1, 0, 0]),
  71. );
  72. /**
  73. * Matrix used to convert from x-up to y-up
  74. *
  75. * @type {Matrix4}
  76. * @constant
  77. */
  78. Axis.X_UP_TO_Y_UP = Matrix4.fromRotationTranslation(
  79. // Rotation about PI/2 around the Z-axis
  80. Matrix3.fromArray([0, 1, 0, -1, 0, 0, 0, 0, 1]),
  81. );
  82. /**
  83. * Matrix used to convert from y-up to x-up
  84. *
  85. * @type {Matrix4}
  86. * @constant
  87. */
  88. Axis.Y_UP_TO_X_UP = Matrix4.fromRotationTranslation(
  89. // Rotation about -PI/2 around the Z-axis
  90. Matrix3.fromArray([0, -1, 0, 1, 0, 0, 0, 0, 1]),
  91. );
  92. /**
  93. * Gets the axis by name
  94. *
  95. * @param {string} name The name of the axis.
  96. * @returns {number} The axis enum.
  97. */
  98. Axis.fromName = function (name) {
  99. //>>includeStart('debug', pragmas.debug);
  100. Check.typeOf.string("name", name);
  101. //>>includeEnd('debug');
  102. return Axis[name];
  103. };
  104. Object.freeze(Axis);
  105. export default Axis;