enforce proper use of clamp()
This commit is contained in:
parent
b16f402040
commit
3aaa621ee6
1 changed files with 8 additions and 2 deletions
|
@ -9,6 +9,7 @@
|
||||||
#include "taisei.h"
|
#include "taisei.h"
|
||||||
|
|
||||||
#include "miscmath.h"
|
#include "miscmath.h"
|
||||||
|
#include "assert.h"
|
||||||
|
|
||||||
double approach(double v, double t, double d) {
|
double approach(double v, double t, double d) {
|
||||||
if(v < t) {
|
if(v < t) {
|
||||||
|
@ -37,10 +38,15 @@ double min(double a, double b) {
|
||||||
}
|
}
|
||||||
|
|
||||||
double clamp(double f, double lower, double upper) {
|
double clamp(double f, double lower, double upper) {
|
||||||
if(f < lower)
|
assert(lower <= upper);
|
||||||
|
|
||||||
|
if(f < lower) {
|
||||||
return lower;
|
return lower;
|
||||||
if(f > upper)
|
}
|
||||||
|
|
||||||
|
if(f > upper) {
|
||||||
return upper;
|
return upper;
|
||||||
|
}
|
||||||
|
|
||||||
return f;
|
return f;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue