aboutsummaryrefslogtreecommitdiff
path: root/game/addons/zylann.hterrain/native/src/math_funcs.h
blob: 34c907110c250e68bbaea4a11aed3e0b8ef9bf47 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#ifndef MATH_FUNCS_H
#define MATH_FUNCS_H

namespace Math {

inline float lerp(float minv, float maxv, float t) {
    return minv + t * (maxv - minv);
}

template <typename T>
inline T clamp(T x, T minv, T maxv) {
    if (x < minv) {
        return minv;
    }
    if (x > maxv) {
        return maxv;
    }
    return x;
}

template <typename T>
inline T min(T a, T b) {
    return a < b ? a : b;
}

} // namespace Math

#endif // MATH_FUNCS_H