Robot Control Library
other.h
Go to the documentation of this file.
1 /**
2  * <rc/math/other.h>
3  *
4  * @brief Math functions that don't fit elsewhere.
5  *
6  * @author James Strawson
7  * @date 2016
8  *
9  * @addtogroup Other_Math
10  * @ingroup Math
11  * @{
12  */
13 
14 
15 #ifndef RC_MATH_OTHER_H
16 #define RC_MATH_OTHER_H
17 
18 #ifdef __cplusplus
19 extern "C" {
20 #endif
21 
22 /**
23  * @brief Returns a random floating point number between -1 and 1.
24  *
25  * Uses standard C rand function and bitwise operations which is much faster
26  * than doing floating point arithmetic.
27  *
28  * @return random floating point number between -1 and 1
29  */
30 float rc_get_random_float(void);
31 
32 /**
33  * @brief Returns a random double-precision floating point number between
34  * -1 and 1.
35  *
36  * Uses standard C rand function and bitwise operations which is much faster
37  * than doing floating point arithmetic.
38  *
39  * @return random double-precision floating point number between -1 and 1
40  */
41 double rc_get_random_double(void);
42 
43 /**
44  * @brief Modifies val to be bounded between between min and max.
45  *
46  * @param val The value to be checked and possibly modified
47  * @param[in] min The lower bound
48  * @param[in] max The upper bound
49  *
50  * @return Returns 1 if saturation occurred, 0 if val was already in bound,
51  * and -1 if min was falsely larger than max.
52  */
53 int rc_saturate_float(float* val, float min, float max);
54 
55 /**
56  * @brief Modifies val to be bounded between between min and max.
57  *
58  * @param val The value to be checked and possibly modified
59  * @param[in] min The lower bound
60  * @param[in] max The upper bound
61  *
62  * @return Returns 1 if saturation occurred, 0 if val was already in bound,
63  * and -1 if min was falsely larger than max.
64  */
65 int rc_saturate_double(double* val, double min, double max);
66 
67 
68 #ifdef __cplusplus
69 }
70 #endif
71 
72 #endif // RC_MATH_OTHER_H
73 
74 /** @} end group math*/
float rc_get_random_float(void)
Returns a random floating point number between -1 and 1.
int rc_saturate_double(double *val, double min, double max)
Modifies val to be bounded between between min and max.
double rc_get_random_double(void)
Returns a random double-precision floating point number between -1 and 1.
#define min(a, b)
Definition: rc_usefulincludes.h:73
int rc_saturate_float(float *val, float min, float max)
Modifies val to be bounded between between min and max.