Change lerp implementations to same weighting form
This commit is contained in:
parent
6305261270
commit
d81537ba51
11
lerp.cpp
11
lerp.cpp
@ -37,18 +37,17 @@ double lerp::trunc (double a, double, double)
|
|||||||
|
|
||||||
double
|
double
|
||||||
lerp::linear (double a, double b, double weight) {
|
lerp::linear (double a, double b, double weight) {
|
||||||
CHECK (weight >= 0 && weight <= 1.0);
|
CHECK (weight >= 0.0 && weight <= 1.0);
|
||||||
return (1.0 - weight) * a + weight * b;
|
return a * (1.0 - weight) + b * weight;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
double
|
double
|
||||||
lerp::cosine (double a, double b, double weight) {
|
lerp::cosine (double a, double b, double weight) {
|
||||||
CHECK (weight >= 0 && weight <= 1.0);
|
CHECK (weight >= 0.0 && weight <= 1.0);
|
||||||
double ft = weight * PI;
|
double t = (1.0 - cos (weight * PI)) * 0.5;
|
||||||
double f = (1.0 - cos (ft)) * 0.5;
|
|
||||||
|
|
||||||
return a * (1.0 - f) + b * f;
|
return a * (1.0 - t) + b * t;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user