Namespaces | |
namespace | filters |
Classes | |
class | Random_ |
Typedefs | |
typedef boost::detail::thread::singleton < class Random_ > | Random |
Functions | |
static uint64_t | counter_with_overflow (uint64_t full_value, uint16_t new_value) |
static int | ipow (int base, int exp) |
static bool | is_bit_mask_index_false (int bit_mask, int index) |
static bool | is_bit_mask_index_true (int bit_mask, int index) |
static double | linear_interpolate_ (double x, double x0, double y0, double x1, double y1) |
static int | sign (double x) |
static double | to_degrees (double rad) |
static double | to_rad (double degrees) |
Variables | |
static const double | pi = 3.14159265 |
typedef boost::detail::thread::singleton< class Random_ > sr_math_utils::Random |
This is the usable singleton of the Random class.
The typical usage for this class is: -> generate double betwen 0 and 1 sr_math_utils::Random::instance().generate<double>()
-> generate integer between 0 and 10 sr_math_utils::Random::instance().generate<int>(0, 10)
-> generate double betwen 0 and 10 sr_math_utils::Random::instance().generate<double>(0, 10)
Definition at line 329 of file sr_math_utils.hpp.
static uint64_t sr_math_utils::counter_with_overflow | ( | uint64_t | full_value, |
uint16_t | new_value | ||
) | [inline, static] |
Increment a counter given a value which can overflow.
WARNING: only works if called often enough: if new_value > last_value but overflowed between the 2 calls, then we're not able to detect the overflow.
full_value | the full value (with no overflow) |
new_value | the new value we received from the motor. |
Definition at line 104 of file sr_math_utils.hpp.
static int sr_math_utils::ipow | ( | int | base, |
int | exp | ||
) | [inline, static] |
Definition at line 66 of file sr_math_utils.hpp.
static bool sr_math_utils::is_bit_mask_index_false | ( | int | bit_mask, |
int | index | ||
) | [inline, static] |
Definition at line 88 of file sr_math_utils.hpp.
static bool sr_math_utils::is_bit_mask_index_true | ( | int | bit_mask, |
int | index | ||
) | [inline, static] |
Definition at line 80 of file sr_math_utils.hpp.
static double sr_math_utils::linear_interpolate_ | ( | double | x, |
double | x0, | ||
double | y0, | ||
double | x1, | ||
double | y1 | ||
) | [inline, static] |
Interpolate linearly between the 2 points, for the given value
y = y0 + (x-x0)*((y1-y0)/(x1-x0))
x | the X value to compute the interpolation for. |
x0 | the X value of our first point |
y0 | the Y value of our first point |
x1 | the X value of our second point |
y1 | the Y value of our second point |
Definition at line 131 of file sr_math_utils.hpp.
static int sr_math_utils::sign | ( | double | x | ) | [inline, static] |
Checks the sign of a given number.
x | the number we want to study. |
Definition at line 154 of file sr_math_utils.hpp.
static double sr_math_utils::to_degrees | ( | double | rad | ) | [inline, static] |
Convert an angle in degrees to an angle in degrees.
degrees | the value in radians. |
Definition at line 61 of file sr_math_utils.hpp.
static double sr_math_utils::to_rad | ( | double | degrees | ) | [inline, static] |
Convert an angle in degrees to an angle in radians.
degrees | the value in degrees |
Definition at line 49 of file sr_math_utils.hpp.
const double sr_math_utils::pi = 3.14159265 [static] |
Definition at line 40 of file sr_math_utils.hpp.