9 #ifndef _TurtleBrains_Interpolation_h_
10 #define _TurtleBrains_Interpolation_h_
16 namespace Interpolation
26 inline float Linear(
float percentage)
44 template <
typename T> T Linear(
float percentage,
const T& start,
const T&
final)
47 return start + ((
final - start) * percentage);
58 inline float SmoothStep(
float percentage)
60 return (percentage * percentage * (3.0f - 2.0f * percentage));
76 template <
typename T> T SmoothStep(
float percentage,
const T& start,
const T& end)
78 const float smoothPercentage = SmoothStep(percentage);
79 return (start * smoothPercentage) + (end * (1.0f - smoothPercentage));
90 inline float Squared(
float percentage)
92 return percentage * percentage;
108 template <
typename T> T Squared(
float percentage,
const T& start,
const T& end)
110 const float squaredPercentage = Squared(percentage);
111 return (squaredPercentage * start) + (end * (1.0f - squaredPercentage));
122 inline float InverseSquared(
float percentage)
124 return 1.0f - ((1.0f - percentage) * (1.0f - percentage));
140 template <
typename T> T InverseSquared(
float percentage,
const T& start,
const T& end)
142 const float inverseSquared = InverseSquared(percentage);
143 return (inverseSquared * start) + (end * (1.0f - inverseSquared));
164 template <
typename T> T CubicBezier(
float percentage,
const T& a,
const T& b,
const T& c,
const T& d)
166 const T tempA = Linear(percentage, a, c);
167 const T tempB = Linear(percentage, c, d);
168 const T tempC = Linear(percentage, d, b);
170 const T tempAA = Linear(percentage, tempA, tempB);
171 const T tempBB = Linear(percentage, tempB, tempC);
173 return Linear(percentage, tempAA, tempBB);
190 template <
typename T> T CubicBezierTangent(
float percentage,
const T& a,
const T& b,
const T& c,
const T& d)
193 const T c1(d - (3.0f * c) + (3.0f * b) - a);
194 const T c2((3.0f * c) - (6.0f * b) + (3.0f * a));
195 const T c3((3.0f * b) - (3.0f * a));
198 return ((c1 * (3.0f * percentage * percentage)) + (c2 * (2.0f * percentage)) + c3);
Contains objects and functions for dealing with Vector and Matrix math.
Contains all functions, classes and helpers related to game/application development written by Tim "B...
Definition: tb_application_dialog.h:21