Collection of DPF-based plugins for packaging
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.

222 lines
6.8KB

  1. /// @ref gtx_easing
  2. /// @file glm/gtx/easing.hpp
  3. /// @author Robert Chisholm
  4. ///
  5. /// @see core (dependence)
  6. ///
  7. /// @defgroup gtx_easing GLM_GTX_easing
  8. /// @ingroup gtx
  9. ///
  10. /// Include <glm/gtx/easing.hpp> to use the features of this extension.
  11. ///
  12. /// Easing functions for animations and transitons
  13. /// All functions take a parameter x in the range [0.0,1.0]
  14. ///
  15. /// Based on the AHEasing project of Warren Moore (https://github.com/warrenm/AHEasing)
  16. #pragma once
  17. // Dependency:
  18. #include "../glm.hpp"
  19. #include "../gtc/constants.hpp"
  20. #include "../detail/setup.hpp"
  21. #include "../detail/qualifier.hpp"
  22. #include "../detail/type_int.hpp"
  23. #ifndef GLM_ENABLE_EXPERIMENTAL
  24. # error "GLM: GLM_GTX_easing 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."
  25. #endif
  26. #if GLM_MESSAGES == GLM_MESSAGES_ENABLED && !defined(GLM_EXT_INCLUDED)
  27. # pragma message("GLM: GLM_GTX_easing extension included")
  28. #endif
  29. namespace glm{
  30. /// @addtogroup gtx_easing
  31. /// @{
  32. /// Modelled after the line y = x
  33. /// @see gtx_easing
  34. template <typename genType>
  35. GLM_FUNC_DECL genType linearInterpolation(genType const & a);
  36. /// Modelled after the parabola y = x^2
  37. /// @see gtx_easing
  38. template <typename genType>
  39. GLM_FUNC_DECL genType quadraticEaseIn(genType const & a);
  40. /// Modelled after the parabola y = -x^2 + 2x
  41. /// @see gtx_easing
  42. template <typename genType>
  43. GLM_FUNC_DECL genType quadraticEaseOut(genType const & a);
  44. /// Modelled after the piecewise quadratic
  45. /// y = (1/2)((2x)^2) ; [0, 0.5)
  46. /// y = -(1/2)((2x-1)*(2x-3) - 1) ; [0.5, 1]
  47. /// @see gtx_easing
  48. template <typename genType>
  49. GLM_FUNC_DECL genType quadraticEaseInOut(genType const & a);
  50. /// Modelled after the cubic y = x^3
  51. template <typename genType>
  52. GLM_FUNC_DECL genType cubicEaseIn(genType const & a);
  53. /// Modelled after the cubic y = (x - 1)^3 + 1
  54. /// @see gtx_easing
  55. template <typename genType>
  56. GLM_FUNC_DECL genType cubicEaseOut(genType const & a);
  57. /// Modelled after the piecewise cubic
  58. /// y = (1/2)((2x)^3) ; [0, 0.5)
  59. /// y = (1/2)((2x-2)^3 + 2) ; [0.5, 1]
  60. /// @see gtx_easing
  61. template <typename genType>
  62. GLM_FUNC_DECL genType cubicEaseInOut(genType const & a);
  63. /// Modelled after the quartic x^4
  64. /// @see gtx_easing
  65. template <typename genType>
  66. GLM_FUNC_DECL genType quarticEaseIn(genType const & a);
  67. /// Modelled after the quartic y = 1 - (x - 1)^4
  68. /// @see gtx_easing
  69. template <typename genType>
  70. GLM_FUNC_DECL genType quarticEaseOut(genType const & a);
  71. /// Modelled after the piecewise quartic
  72. /// y = (1/2)((2x)^4) ; [0, 0.5)
  73. /// y = -(1/2)((2x-2)^4 - 2) ; [0.5, 1]
  74. /// @see gtx_easing
  75. template <typename genType>
  76. GLM_FUNC_DECL genType quarticEaseInOut(genType const & a);
  77. /// Modelled after the quintic y = x^5
  78. /// @see gtx_easing
  79. template <typename genType>
  80. GLM_FUNC_DECL genType quinticEaseIn(genType const & a);
  81. /// Modelled after the quintic y = (x - 1)^5 + 1
  82. /// @see gtx_easing
  83. template <typename genType>
  84. GLM_FUNC_DECL genType quinticEaseOut(genType const & a);
  85. /// Modelled after the piecewise quintic
  86. /// y = (1/2)((2x)^5) ; [0, 0.5)
  87. /// y = (1/2)((2x-2)^5 + 2) ; [0.5, 1]
  88. /// @see gtx_easing
  89. template <typename genType>
  90. GLM_FUNC_DECL genType quinticEaseInOut(genType const & a);
  91. /// Modelled after quarter-cycle of sine wave
  92. /// @see gtx_easing
  93. template <typename genType>
  94. GLM_FUNC_DECL genType sineEaseIn(genType const & a);
  95. /// Modelled after quarter-cycle of sine wave (different phase)
  96. /// @see gtx_easing
  97. template <typename genType>
  98. GLM_FUNC_DECL genType sineEaseOut(genType const & a);
  99. /// Modelled after half sine wave
  100. /// @see gtx_easing
  101. template <typename genType>
  102. GLM_FUNC_DECL genType sineEaseInOut(genType const & a);
  103. /// Modelled after shifted quadrant IV of unit circle
  104. /// @see gtx_easing
  105. template <typename genType>
  106. GLM_FUNC_DECL genType circularEaseIn(genType const & a);
  107. /// Modelled after shifted quadrant II of unit circle
  108. /// @see gtx_easing
  109. template <typename genType>
  110. GLM_FUNC_DECL genType circularEaseOut(genType const & a);
  111. /// Modelled after the piecewise circular function
  112. /// y = (1/2)(1 - sqrt(1 - 4x^2)) ; [0, 0.5)
  113. /// y = (1/2)(sqrt(-(2x - 3)*(2x - 1)) + 1) ; [0.5, 1]
  114. /// @see gtx_easing
  115. template <typename genType>
  116. GLM_FUNC_DECL genType circularEaseInOut(genType const & a);
  117. /// Modelled after the exponential function y = 2^(10(x - 1))
  118. /// @see gtx_easing
  119. template <typename genType>
  120. GLM_FUNC_DECL genType exponentialEaseIn(genType const & a);
  121. /// Modelled after the exponential function y = -2^(-10x) + 1
  122. /// @see gtx_easing
  123. template <typename genType>
  124. GLM_FUNC_DECL genType exponentialEaseOut(genType const & a);
  125. /// Modelled after the piecewise exponential
  126. /// y = (1/2)2^(10(2x - 1)) ; [0,0.5)
  127. /// y = -(1/2)*2^(-10(2x - 1))) + 1 ; [0.5,1]
  128. /// @see gtx_easing
  129. template <typename genType>
  130. GLM_FUNC_DECL genType exponentialEaseInOut(genType const & a);
  131. /// Modelled after the damped sine wave y = sin(13pi/2*x)*pow(2, 10 * (x - 1))
  132. /// @see gtx_easing
  133. template <typename genType>
  134. GLM_FUNC_DECL genType elasticEaseIn(genType const & a);
  135. /// Modelled after the damped sine wave y = sin(-13pi/2*(x + 1))*pow(2, -10x) + 1
  136. /// @see gtx_easing
  137. template <typename genType>
  138. GLM_FUNC_DECL genType elasticEaseOut(genType const & a);
  139. /// Modelled after the piecewise exponentially-damped sine wave:
  140. /// y = (1/2)*sin(13pi/2*(2*x))*pow(2, 10 * ((2*x) - 1)) ; [0,0.5)
  141. /// y = (1/2)*(sin(-13pi/2*((2x-1)+1))*pow(2,-10(2*x-1)) + 2) ; [0.5, 1]
  142. /// @see gtx_easing
  143. template <typename genType>
  144. GLM_FUNC_DECL genType elasticEaseInOut(genType const & a);
  145. /// @see gtx_easing
  146. template <typename genType>
  147. GLM_FUNC_DECL genType backEaseIn(genType const& a);
  148. /// @see gtx_easing
  149. template <typename genType>
  150. GLM_FUNC_DECL genType backEaseOut(genType const& a);
  151. /// @see gtx_easing
  152. template <typename genType>
  153. GLM_FUNC_DECL genType backEaseInOut(genType const& a);
  154. /// @param a parameter
  155. /// @param o Optional overshoot modifier
  156. /// @see gtx_easing
  157. template <typename genType>
  158. GLM_FUNC_DECL genType backEaseIn(genType const& a, genType const& o);
  159. /// @param a parameter
  160. /// @param o Optional overshoot modifier
  161. /// @see gtx_easing
  162. template <typename genType>
  163. GLM_FUNC_DECL genType backEaseOut(genType const& a, genType const& o);
  164. /// @param a parameter
  165. /// @param o Optional overshoot modifier
  166. /// @see gtx_easing
  167. template <typename genType>
  168. GLM_FUNC_DECL genType backEaseInOut(genType const& a, genType const& o);
  169. /// @see gtx_easing
  170. template <typename genType>
  171. GLM_FUNC_DECL genType bounceEaseIn(genType const& a);
  172. /// @see gtx_easing
  173. template <typename genType>
  174. GLM_FUNC_DECL genType bounceEaseOut(genType const& a);
  175. /// @see gtx_easing
  176. template <typename genType>
  177. GLM_FUNC_DECL genType bounceEaseInOut(genType const& a);
  178. /// @}
  179. }//namespace glm
  180. #include "easing.inl"