Add absolute, radians and degrees math utilities
This commit is contained in:
parent
8275fce9c6
commit
c70f252349
@ -4,8 +4,11 @@
|
||||
#include "aliases/aliases.h"
|
||||
|
||||
#define square(x) (x * x)
|
||||
#define absolute(x) (x < 0.0 ? x * -1.0 : x)
|
||||
|
||||
i32 min(i32 a, i32 b);
|
||||
i32 max(i32 a, i32 b);
|
||||
f64 radians(f64 degrees);
|
||||
f64 degrees(f64 radians);
|
||||
|
||||
#endif // !MATH_UTILS_H
|
||||
|
@ -1,5 +1,10 @@
|
||||
#include "math_utils.h"
|
||||
#include <math.h>
|
||||
|
||||
i32 min(i32 a, i32 b) { return a <= b ? a : b; }
|
||||
|
||||
i32 max(i32 a, i32 b) { return a >= b ? a : b; }
|
||||
|
||||
f64 radians(f64 degrees) { return degrees * M_PI / 180.0; }
|
||||
|
||||
f64 degrees(f64 radians) { return radians * 180.0 / M_PI; }
|
||||
|
Loading…
Reference in New Issue
Block a user