28 #ifndef AGS_SHARED_UTIL_MATH_H 29 #define AGS_SHARED_UTIL_MATH_H 31 #include "common/std/limits.h" 33 #include "ags/lib/std.h" 38 #define M_PI 3.14159265358979323846 46 inline const T &Max(
const T &a,
const T &b) {
51 inline const T &Min(
const T &a,
const T &b) {
56 inline const T &Clamp(
const T &val,
const T &floor,
const T &ceil) {
57 return Max<T>(floor, Min<T>(val, ceil));
61 inline void ClampLength(T &from, T &length,
const T &floor,
const T &height) {
63 length -= floor - from;
65 }
else if (from >= floor + height) {
66 from = floor + height;
70 length = Max<T>(length, 0);
71 length = Min<T>(length, height - from);
77 inline T Surplus(
const T &larger,
const T &smaller) {
78 return larger > smaller ? larger - smaller : 0;
83 template <
typename T,
typename TBig>
84 inline T InRangeOrDef(
const TBig &val,
const T &def) {
85 return (val >= std::numeric_limits<T>::min() && val <= std::numeric_limits<T>::max()) ?
86 static_cast<T
>(val) : def;
89 inline float RadiansToDegrees(
float rads) {
90 return rads * (float)(180.0 / M_PI);
93 inline float DegreesToRadians(
float deg) {
94 return deg * (float)(M_PI / 180.0);
Definition: achievements_tables.h:27