250 * @param t Current time (in frames or seconds). |
250 * @param t Current time (in frames or seconds). |
251 * @return The correct value. |
251 * @return The correct value. |
252 */ |
252 */ |
253 static qreal easeInSine(qreal t) |
253 static qreal easeInSine(qreal t) |
254 { |
254 { |
255 return (t == 1.0) ? 1.0 : -::cos(t * M_PI_2) + 1.0; |
255 return (t == 1.0) ? 1.0 : -::qCos(t * M_PI_2) + 1.0; |
256 } |
256 } |
257 |
257 |
258 /** |
258 /** |
259 * Easing equation function for a sinusoidal (sin(t)) easing out: decelerating from zero velocity. |
259 * Easing equation function for a sinusoidal (sin(t)) easing out: decelerating from zero velocity. |
260 * |
260 * |
261 * @param t Current time (in frames or seconds). |
261 * @param t Current time (in frames or seconds). |
262 * @return The correct value. |
262 * @return The correct value. |
263 */ |
263 */ |
264 static qreal easeOutSine(qreal t) |
264 static qreal easeOutSine(qreal t) |
265 { |
265 { |
266 return ::sin(t* M_PI_2); |
266 return ::qSin(t* M_PI_2); |
267 } |
267 } |
268 |
268 |
269 /** |
269 /** |
270 * Easing equation function for a sinusoidal (sin(t)) easing in/out: acceleration until halfway, then deceleration. |
270 * Easing equation function for a sinusoidal (sin(t)) easing in/out: acceleration until halfway, then deceleration. |
271 * |
271 * |
272 * @param t Current time (in frames or seconds). |
272 * @param t Current time (in frames or seconds). |
273 * @return The correct value. |
273 * @return The correct value. |
274 */ |
274 */ |
275 static qreal easeInOutSine(qreal t) |
275 static qreal easeInOutSine(qreal t) |
276 { |
276 { |
277 return -0.5 * (::cos(M_PI*t) - 1); |
277 return -0.5 * (::qCos(M_PI*t) - 1); |
278 } |
278 } |
279 |
279 |
280 /** |
280 /** |
281 * Easing equation function for a sinusoidal (sin(t)) easing out/in: deceleration until halfway, then acceleration. |
281 * Easing equation function for a sinusoidal (sin(t)) easing out/in: deceleration until halfway, then acceleration. |
282 * |
282 * |
395 if (t==0) return b; |
395 if (t==0) return b; |
396 qreal t_adj = (qreal)t / (qreal)d; |
396 qreal t_adj = (qreal)t / (qreal)d; |
397 if (t_adj==1) return b+c; |
397 if (t_adj==1) return b+c; |
398 |
398 |
399 qreal s; |
399 qreal s; |
400 if(a < ::fabs(c)) { |
400 if(a < ::qFabs(c)) { |
401 a = c; |
401 a = c; |
402 s = p / 4.0f; |
402 s = p / 4.0f; |
403 } else { |
403 } else { |
404 s = p / (2 * M_PI) * ::asin(c / a); |
404 s = p / (2 * M_PI) * ::qAsin(c / a); |
405 } |
405 } |
406 |
406 |
407 t_adj -= 1.0f; |
407 t_adj -= 1.0f; |
408 return -(a*::qPow(2.0f,10*t_adj) * ::sin( (t_adj*d-s)*(2*M_PI)/p )) + b; |
408 return -(a*::qPow(2.0f,10*t_adj) * ::qSin( (t_adj*d-s)*(2*M_PI)/p )) + b; |
409 } |
409 } |
410 |
410 |
411 /** |
411 /** |
412 * Easing equation function for an elastic (exponentially decaying sine wave) easing in: accelerating from zero velocity. |
412 * Easing equation function for an elastic (exponentially decaying sine wave) easing in: accelerating from zero velocity. |
413 * |
413 * |
467 qreal s; |
467 qreal s; |
468 if(a < 1.0) { |
468 if(a < 1.0) { |
469 a = 1.0; |
469 a = 1.0; |
470 s = p / 4.0f; |
470 s = p / 4.0f; |
471 } else { |
471 } else { |
472 s = p / (2 * M_PI) * ::asin(1.0 / a); |
472 s = p / (2 * M_PI) * ::qAsin(1.0 / a); |
473 } |
473 } |
474 |
474 |
475 if (t < 1) return -.5*(a*::qPow(2.0f,10*(t-1)) * ::sin( (t-1-s)*(2*M_PI)/p )); |
475 if (t < 1) return -.5*(a*::qPow(2.0f,10*(t-1)) * ::qSin( (t-1-s)*(2*M_PI)/p )); |
476 return a*::qPow(2.0f,-10*(t-1)) * ::sin( (t-1-s)*(2*M_PI)/p )*.5 + 1.0; |
476 return a*::qPow(2.0f,-10*(t-1)) * ::qSin( (t-1-s)*(2*M_PI)/p )*.5 + 1.0; |
477 } |
477 } |
478 |
478 |
479 /** |
479 /** |
480 * Easing equation function for an elastic (exponentially decaying sine wave) easing out/in: deceleration until halfway, then acceleration. |
480 * Easing equation function for an elastic (exponentially decaying sine wave) easing out/in: deceleration until halfway, then acceleration. |
481 * |
481 * |