💿🐜 Antkeeper source code https://antkeeper.com
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

89 lines
2.8 KiB

  1. /*
  2. * Copyright (C) 2023 Christopher J. Howard
  3. *
  4. * This file is part of Antkeeper source code.
  5. *
  6. * Antkeeper source code is free software: you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License as published by
  8. * the Free Software Foundation, either version 3 of the License, or
  9. * (at your option) any later version.
  10. *
  11. * Antkeeper source code is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public License
  17. * along with Antkeeper source code. If not, see <http://www.gnu.org/licenses/>.
  18. */
  19. #ifndef ANTKEEPER_ANIMATION_EULER_IK_CONSTRAINT_HPP
  20. #define ANTKEEPER_ANIMATION_EULER_IK_CONSTRAINT_HPP
  21. #include <engine/animation/ik/ik-constraint.hpp>
  22. #include <engine/math/euler-angles.hpp>
  23. #include <engine/math/numbers.hpp>
  24. /**
  25. * Euler angle IK constraint.
  26. */
  27. class euler_ik_constraint: public ik_constraint
  28. {
  29. public:
  30. void solve(math::fquat& q) override;
  31. /**
  32. * Sets the rotation sequence of the Euler angles of the constraint.
  33. *
  34. * @param sequence Euler angle rotation sequence.
  35. */
  36. inline void set_rotation_sequence(math::rotation_sequence sequence) noexcept
  37. {
  38. m_rotation_sequence = sequence;
  39. }
  40. /**
  41. * Sets the minimum Euler angles of the constraint.
  42. *
  43. * @param angles Minimum angles of the first, second, and third Euler angles, in radians.
  44. */
  45. inline void set_min_angles(const math::fvec3& angles) noexcept
  46. {
  47. m_min_angles = angles;
  48. }
  49. /**
  50. * Sets the maximum Euler angles of the constraint.
  51. *
  52. * @param angles Maximum angles of the first, second, and third Euler angles, in radians.
  53. */
  54. inline void set_max_angles(const math::fvec3& angles) noexcept
  55. {
  56. m_max_angles = angles;
  57. }
  58. /// Returns the rotation sequence of the Euler angles of the constraint.
  59. [[nodiscard]] inline constexpr math::rotation_sequence get_rotation_sequence() const noexcept
  60. {
  61. return m_rotation_sequence;
  62. }
  63. /// Returns the minimum angles of the first, second, and third Euler angles, in radians.
  64. [[nodiscard]] inline constexpr const math::fvec3& get_min_angles() const noexcept
  65. {
  66. return m_min_angles;
  67. }
  68. /// Returns the maximum angles of the first, second, and third Euler angles, in radians.
  69. [[nodiscard]] inline constexpr const math::fvec3& get_max_angles() const noexcept
  70. {
  71. return m_max_angles;
  72. }
  73. private:
  74. math::rotation_sequence m_rotation_sequence{math::rotation_sequence::xyz};
  75. math::fvec3 m_min_angles{-math::pi<float>, -math::pi<float>, -math::pi<float>};
  76. math::fvec3 m_max_angles{ math::pi<float>, math::pi<float>, math::pi<float>};
  77. };
  78. #endif // ANTKEEPER_ANIMATION_EULER_IK_CONSTRAINT_HPP