master
ブランチ master
ShaderPlayground / deps / glm / glm / gtx / easing.hpp
6.7 KB、219行 生 Blame 履歴
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
17#pragma once
18
19// Dependency:
20#include "../glm.hpp"
21#include "../gtc/constants.hpp"
22#include "../detail/qualifier.hpp"
23
24#ifndef GLM_ENABLE_EXPERIMENTAL
25# 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."
26#endif
27
28#if GLM_MESSAGES == GLM_ENABLE && !defined(GLM_EXT_INCLUDED)
29# pragma message("GLM: GLM_GTX_easing extension included")
30#endif
31
32namespace glm{
33 /// @addtogroup gtx_easing
34 /// @{
35
36 /// Modelled after the line y = x
37 /// @see gtx_easing
38 template <typename genType>
39 GLM_FUNC_DECL genType linearInterpolation(genType const & a);
40
41 /// Modelled after the parabola y = x^2
42 /// @see gtx_easing
43 template <typename genType>
44 GLM_FUNC_DECL genType quadraticEaseIn(genType const & a);
45
46 /// Modelled after the parabola y = -x^2 + 2x
47 /// @see gtx_easing
48 template <typename genType>
49 GLM_FUNC_DECL genType quadraticEaseOut(genType const & a);
50
51 /// Modelled after the piecewise quadratic
52 /// y = (1/2)((2x)^2) ; [0, 0.5)
53 /// y = -(1/2)((2x-1)*(2x-3) - 1) ; [0.5, 1]
54 /// @see gtx_easing
55 template <typename genType>
56 GLM_FUNC_DECL genType quadraticEaseInOut(genType const & a);
57
58 /// Modelled after the cubic y = x^3
59 template <typename genType>
60 GLM_FUNC_DECL genType cubicEaseIn(genType const & a);
61
62 /// Modelled after the cubic y = (x - 1)^3 + 1
63 /// @see gtx_easing
64 template <typename genType>
65 GLM_FUNC_DECL genType cubicEaseOut(genType const & a);
66
67 /// Modelled after the piecewise cubic
68 /// y = (1/2)((2x)^3) ; [0, 0.5)
69 /// y = (1/2)((2x-2)^3 + 2) ; [0.5, 1]
70 /// @see gtx_easing
71 template <typename genType>
72 GLM_FUNC_DECL genType cubicEaseInOut(genType const & a);
73
74 /// Modelled after the quartic x^4
75 /// @see gtx_easing
76 template <typename genType>
77 GLM_FUNC_DECL genType quarticEaseIn(genType const & a);
78
79 /// Modelled after the quartic y = 1 - (x - 1)^4
80 /// @see gtx_easing
81 template <typename genType>
82 GLM_FUNC_DECL genType quarticEaseOut(genType const & a);
83
84 /// Modelled after the piecewise quartic
85 /// y = (1/2)((2x)^4) ; [0, 0.5)
86 /// y = -(1/2)((2x-2)^4 - 2) ; [0.5, 1]
87 /// @see gtx_easing
88 template <typename genType>
89 GLM_FUNC_DECL genType quarticEaseInOut(genType const & a);
90
91 /// Modelled after the quintic y = x^5
92 /// @see gtx_easing
93 template <typename genType>
94 GLM_FUNC_DECL genType quinticEaseIn(genType const & a);
95
96 /// Modelled after the quintic y = (x - 1)^5 + 1
97 /// @see gtx_easing
98 template <typename genType>
99 GLM_FUNC_DECL genType quinticEaseOut(genType const & a);
100
101 /// Modelled after the piecewise quintic
102 /// y = (1/2)((2x)^5) ; [0, 0.5)
103 /// y = (1/2)((2x-2)^5 + 2) ; [0.5, 1]
104 /// @see gtx_easing
105 template <typename genType>
106 GLM_FUNC_DECL genType quinticEaseInOut(genType const & a);
107
108 /// Modelled after quarter-cycle of sine wave
109 /// @see gtx_easing
110 template <typename genType>
111 GLM_FUNC_DECL genType sineEaseIn(genType const & a);
112
113 /// Modelled after quarter-cycle of sine wave (different phase)
114 /// @see gtx_easing
115 template <typename genType>
116 GLM_FUNC_DECL genType sineEaseOut(genType const & a);
117
118 /// Modelled after half sine wave
119 /// @see gtx_easing
120 template <typename genType>
121 GLM_FUNC_DECL genType sineEaseInOut(genType const & a);
122
123 /// Modelled after shifted quadrant IV of unit circle
124 /// @see gtx_easing
125 template <typename genType>
126 GLM_FUNC_DECL genType circularEaseIn(genType const & a);
127
128 /// Modelled after shifted quadrant II of unit circle
129 /// @see gtx_easing
130 template <typename genType>
131 GLM_FUNC_DECL genType circularEaseOut(genType const & a);
132
133 /// Modelled after the piecewise circular function
134 /// y = (1/2)(1 - sqrt(1 - 4x^2)) ; [0, 0.5)
135 /// y = (1/2)(sqrt(-(2x - 3)*(2x - 1)) + 1) ; [0.5, 1]
136 /// @see gtx_easing
137 template <typename genType>
138 GLM_FUNC_DECL genType circularEaseInOut(genType const & a);
139
140 /// Modelled after the exponential function y = 2^(10(x - 1))
141 /// @see gtx_easing
142 template <typename genType>
143 GLM_FUNC_DECL genType exponentialEaseIn(genType const & a);
144
145 /// Modelled after the exponential function y = -2^(-10x) + 1
146 /// @see gtx_easing
147 template <typename genType>
148 GLM_FUNC_DECL genType exponentialEaseOut(genType const & a);
149
150 /// Modelled after the piecewise exponential
151 /// y = (1/2)2^(10(2x - 1)) ; [0,0.5)
152 /// y = -(1/2)*2^(-10(2x - 1))) + 1 ; [0.5,1]
153 /// @see gtx_easing
154 template <typename genType>
155 GLM_FUNC_DECL genType exponentialEaseInOut(genType const & a);
156
157 /// Modelled after the damped sine wave y = sin(13pi/2*x)*pow(2, 10 * (x - 1))
158 /// @see gtx_easing
159 template <typename genType>
160 GLM_FUNC_DECL genType elasticEaseIn(genType const & a);
161
162 /// Modelled after the damped sine wave y = sin(-13pi/2*(x + 1))*pow(2, -10x) + 1
163 /// @see gtx_easing
164 template <typename genType>
165 GLM_FUNC_DECL genType elasticEaseOut(genType const & a);
166
167 /// Modelled after the piecewise exponentially-damped sine wave:
168 /// y = (1/2)*sin(13pi/2*(2*x))*pow(2, 10 * ((2*x) - 1)) ; [0,0.5)
169 /// y = (1/2)*(sin(-13pi/2*((2x-1)+1))*pow(2,-10(2*x-1)) + 2) ; [0.5, 1]
170 /// @see gtx_easing
171 template <typename genType>
172 GLM_FUNC_DECL genType elasticEaseInOut(genType const & a);
173
174 /// @see gtx_easing
175 template <typename genType>
176 GLM_FUNC_DECL genType backEaseIn(genType const& a);
177
178 /// @see gtx_easing
179 template <typename genType>
180 GLM_FUNC_DECL genType backEaseOut(genType const& a);
181
182 /// @see gtx_easing
183 template <typename genType>
184 GLM_FUNC_DECL genType backEaseInOut(genType const& a);
185
186 /// @param a parameter
187 /// @param o Optional overshoot modifier
188 /// @see gtx_easing
189 template <typename genType>
190 GLM_FUNC_DECL genType backEaseIn(genType const& a, genType const& o);
191
192 /// @param a parameter
193 /// @param o Optional overshoot modifier
194 /// @see gtx_easing
195 template <typename genType>
196 GLM_FUNC_DECL genType backEaseOut(genType const& a, genType const& o);
197
198 /// @param a parameter
199 /// @param o Optional overshoot modifier
200 /// @see gtx_easing
201 template <typename genType>
202 GLM_FUNC_DECL genType backEaseInOut(genType const& a, genType const& o);
203
204 /// @see gtx_easing
205 template <typename genType>
206 GLM_FUNC_DECL genType bounceEaseIn(genType const& a);
207
208 /// @see gtx_easing
209 template <typename genType>
210 GLM_FUNC_DECL genType bounceEaseOut(genType const& a);
211
212 /// @see gtx_easing
213 template <typename genType>
214 GLM_FUNC_DECL genType bounceEaseInOut(genType const& a);
215
216 /// @}
217}//namespace glm
218
219#include "easing.inl"