|
14 | 14 | #include <stdint.h> |
15 | 15 | #include <stdbool.h> |
16 | 16 |
|
17 | | -/** |
18 | | - * Gets the absolute value. |
19 | | - * |
20 | | - * @param [in] value The value. |
21 | | - * @return The absolute (positive) value. |
22 | | - */ |
23 | | -static inline int32_t pbio_math_abs(int32_t value) { |
24 | | - return __builtin_abs(value); |
25 | | -} |
26 | | - |
27 | | -/** |
28 | | - * Gets the maximum of two values. |
29 | | - * |
30 | | - * @param [in] a Value. |
31 | | - * @param [in] b Value. |
32 | | - * @return a if it is greater than b, else b. |
33 | | - */ |
34 | | -static inline int32_t pbio_math_max(int32_t a, int32_t b) { |
35 | | - if (a > b) { |
36 | | - return a; |
37 | | - } |
38 | | - |
39 | | - return b; |
40 | | -} |
41 | | - |
42 | | -/** |
43 | | - * Gets the minimum of two values. |
44 | | - * |
45 | | - * @param [in] a Value. |
46 | | - * @param [in] b Value. |
47 | | - * @return a if it is less than b, else b. |
48 | | - */ |
49 | | -static inline int32_t pbio_math_min(int32_t a, int32_t b) { |
50 | | - if (a < b) { |
51 | | - return a; |
52 | | - } |
53 | | - |
54 | | - return b; |
55 | | -} |
56 | | - |
57 | | -/** |
58 | | - * Get the sign of @p a. |
59 | | - * |
60 | | - * @param [in] a A signed integer value. |
61 | | - * @return 1 if @p a is positive, -1 if @p a is negative or 0 if @p a |
62 | | - * is 0. |
63 | | - */ |
64 | | -static inline int32_t pbio_math_sign(int32_t a) { |
65 | | - if (a == 0) { |
66 | | - return 0; |
67 | | - } |
68 | | - |
69 | | - return a > 0 ? 1 : -1; |
70 | | -} |
71 | | - |
72 | | -/** |
73 | | - * Checks that the signs of @p a and @p b are not opposite. |
74 | | - * |
75 | | - * @param [in] a A signed integer value. |
76 | | - * @param [in] b A signed integer value. |
77 | | - * @return True if either value is zero or if the signs are the same, |
78 | | - * else false. |
79 | | - */ |
80 | | -static inline bool pbio_math_sign_not_opposite(int32_t a, int32_t b) { |
81 | | - if (a == 0 || b == 0) { |
82 | | - return true; |
83 | | - } |
84 | | - |
85 | | - return (a > 0) == (b > 0); |
86 | | -} |
87 | | - |
| 17 | +bool pbio_math_sign_not_opposite(int32_t a, int32_t b); |
| 18 | +int32_t pbio_math_abs(int32_t value); |
88 | 19 | int32_t pbio_math_atan2(int32_t y, int32_t x); |
89 | 20 | int32_t pbio_math_bind(int32_t value, int32_t min, int32_t max); |
90 | 21 | int32_t pbio_math_clamp(int32_t value, int32_t abs_max); |
| 22 | +int32_t pbio_math_max(int32_t a, int32_t b); |
| 23 | +int32_t pbio_math_min(int32_t a, int32_t b); |
91 | 24 | int32_t pbio_math_mult_then_div(int32_t a, int32_t b, int32_t c); |
| 25 | +int32_t pbio_math_sign(int32_t a); |
92 | 26 | int32_t pbio_math_sqrt(int32_t n); |
93 | 27 |
|
94 | 28 | #endif // _PBIO_MATH_H_ |
|
0 commit comments