HaikuDepot: notify work status from main window
[haiku.git] / src / apps / haiku3d / MathUtils.cpp
blobff5d4e29c1504148019bb37885108d570221edf7
1 /*
2 * Copyright 2008, Haiku Inc. All rights reserved.
3 * Distributed under the terms of the MIT License.
5 * Authors:
6 * Alexandre Deckner <alex@zappotek.com>
7 */
9 // Some math utils, useful for animation
12 #include "MathUtils.h"
14 #include <math.h>
17 float
18 MathUtils::EaseInOutCubic(float time, float start, float distance,
19 float duration)
21 time /= duration / 2.0;
22 if (time < 1.0)
23 return distance / 2.0 * time * time * time + start;
24 time -= 2.0;
25 return distance / 2.0 * (time * time * time + 2.0) + start;
29 float
30 MathUtils::EaseInOutQuart(float time, float start, float distance,
31 float duration)
33 time /= duration / 2;
35 if (time < 1)
36 return distance / 2 * time * time * time * time + start;
38 time -= 2;
40 return -distance / 2 * (time * time * time * time - 2) + start;
44 float
45 MathUtils::EaseInOutQuint(float time, float start, float distance,
46 float duration)
48 time /= duration / 2;
49 if (time < 1)
50 return distance / 2 * time * time * time * time * time + start;
51 time -= 2;
52 return distance / 2 *(time * time * time * time * time + 2) + start;
56 float
57 MathUtils::EaseInOutSine(float time, float start, float distance,
58 float duration)
60 return -distance / 2 * (cos(3.14159 * time / distance) - 1) + start;