matrix_transform_2d.hpp 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. /// @ref gtx_matrix_transform_2d
  2. /// @file glm/gtx/matrix_transform_2d.hpp
  3. /// @author Miguel Ángel Pérez Martínez
  4. ///
  5. /// @see core (dependence)
  6. ///
  7. /// @defgroup gtx_matrix_transform_2d GLM_GTX_matrix_transform_2d
  8. /// @ingroup gtx
  9. ///
  10. /// Include <glm/gtx/matrix_transform_2d.hpp> to use the features of this extension.
  11. ///
  12. /// Defines functions that generate common 2d transformation matrices.
  13. #pragma once
  14. // Dependency:
  15. #include "../mat3x3.hpp"
  16. #include "../vec2.hpp"
  17. #ifndef GLM_ENABLE_EXPERIMENTAL
  18. # error "GLM: GLM_GTX_matrix_transform_2d is an experimental extension and may change in the future. Use #define GLM_ENABLE_EXPERIMENTAL before including it, if you really want to use it."
  19. #endif
  20. #if GLM_MESSAGES == GLM_ENABLE && !defined(GLM_EXT_INCLUDED)
  21. # pragma message("GLM: GLM_GTX_matrix_transform_2d extension included")
  22. #endif
  23. namespace glm
  24. {
  25. /// @addtogroup gtx_matrix_transform_2d
  26. /// @{
  27. /// Builds a translation 3 * 3 matrix created from a vector of 2 components.
  28. ///
  29. /// @param m Input matrix multiplied by this translation matrix.
  30. /// @param v Coordinates of a translation vector.
  31. template<typename T, qualifier Q>
  32. GLM_FUNC_QUALIFIER mat<3, 3, T, Q> translate(
  33. mat<3, 3, T, Q> const& m,
  34. vec<2, T, Q> const& v);
  35. /// Builds a rotation 3 * 3 matrix created from an angle.
  36. ///
  37. /// @param m Input matrix multiplied by this translation matrix.
  38. /// @param angle Rotation angle expressed in radians.
  39. template<typename T, qualifier Q>
  40. GLM_FUNC_QUALIFIER mat<3, 3, T, Q> rotate(
  41. mat<3, 3, T, Q> const& m,
  42. T angle);
  43. /// Builds a scale 3 * 3 matrix created from a vector of 2 components.
  44. ///
  45. /// @param m Input matrix multiplied by this translation matrix.
  46. /// @param v Coordinates of a scale vector.
  47. template<typename T, qualifier Q>
  48. GLM_FUNC_QUALIFIER mat<3, 3, T, Q> scale(
  49. mat<3, 3, T, Q> const& m,
  50. vec<2, T, Q> const& v);
  51. /// Builds an horizontal (parallel to the x axis) shear 3 * 3 matrix.
  52. ///
  53. /// @param m Input matrix multiplied by this translation matrix.
  54. /// @param y Shear factor.
  55. template<typename T, qualifier Q>
  56. GLM_FUNC_QUALIFIER mat<3, 3, T, Q> shearX(
  57. mat<3, 3, T, Q> const& m,
  58. T y);
  59. /// Builds a vertical (parallel to the y axis) shear 3 * 3 matrix.
  60. ///
  61. /// @param m Input matrix multiplied by this translation matrix.
  62. /// @param x Shear factor.
  63. template<typename T, qualifier Q>
  64. GLM_FUNC_QUALIFIER mat<3, 3, T, Q> shearY(
  65. mat<3, 3, T, Q> const& m,
  66. T x);
  67. /// @}
  68. }//namespace glm
  69. #include "matrix_transform_2d.inl"