Namespaces | Classes | Typedefs | Functions | Variables
sr_math_utils Namespace Reference

Namespaces

 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 (int64_t bit_mask, int index)
 
static bool is_bit_mask_index_true (int64_t 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 Documentation

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 334 of file sr_math_utils.hpp.

Function Documentation

static uint64_t sr_math_utils::counter_with_overflow ( uint64_t  full_value,
uint16_t  new_value 
)
inlinestatic

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.

Parameters
full_valuethe full value (with no overflow)
new_valuethe new value we received from the motor.
Returns
The new full value

Definition at line 111 of file sr_math_utils.hpp.

static int sr_math_utils::ipow ( int  base,
int  exp 
)
inlinestatic

Definition at line 67 of file sr_math_utils.hpp.

static bool sr_math_utils::is_bit_mask_index_false ( int64_t  bit_mask,
int  index 
)
inlinestatic

Definition at line 95 of file sr_math_utils.hpp.

static bool sr_math_utils::is_bit_mask_index_true ( int64_t  bit_mask,
int  index 
)
inlinestatic

Definition at line 83 of file sr_math_utils.hpp.

static double sr_math_utils::linear_interpolate_ ( double  x,
double  x0,
double  y0,
double  x1,
double  y1 
)
inlinestatic

Interpolate linearly between the 2 points, for the given value

y = y0 + (x-x0)*((y1-y0)/(x1-x0))

Parameters
xthe X value to compute the interpolation for.
x0the X value of our first point
y0the Y value of our first point
x1the X value of our second point
y1the Y value of our second point
Returns
the computed Y value (calibrated value)

Definition at line 139 of file sr_math_utils.hpp.

static int sr_math_utils::sign ( double  x)
inlinestatic

Checks the sign of a given number.

Parameters
xthe number we want to study.
Returns
1 if x is positive, -1 if negative.

Definition at line 278 of file sr_math_utils.hpp.

static double sr_math_utils::to_degrees ( double  rad)
inlinestatic

Convert an angle in degrees to an angle in degrees.

Parameters
radthe value in radians.
Returns
the value in degrees.

Definition at line 62 of file sr_math_utils.hpp.

static double sr_math_utils::to_rad ( double  degrees)
inlinestatic

Convert an angle in degrees to an angle in radians.

Parameters
degreesthe value in degrees
Returns
the value in radians.

Definition at line 50 of file sr_math_utils.hpp.

Variable Documentation

const double sr_math_utils::pi = 3.14159265
static

Definition at line 41 of file sr_math_utils.hpp.



sr_utilities
Author(s): Ugo Cupcic
autogenerated on Tue Oct 13 2020 03:55:49