Robot Control Library
Other_Math

Description

Math functions that don't fit elsewhere.

<rc/math/other.h>

Author
James Strawson
Date
2016

Functions

float rc_get_random_float (void)
 Returns a random floating point number between -1 and 1. More...
 
double rc_get_random_double (void)
 Returns a random double-precision floating point number between -1 and 1. More...
 
int rc_saturate_float (float *val, float min, float max)
 Modifies val to be bounded between between min and max. More...
 
int rc_saturate_double (double *val, double min, double max)
 Modifies val to be bounded between between min and max. More...
 

Function Documentation

◆ rc_get_random_float()

float rc_get_random_float ( void  )

Returns a random floating point number between -1 and 1.

Uses standard C rand function and bitwise operations which is much faster than doing floating point arithmetic.

Returns
random floating point number between -1 and 1

◆ rc_get_random_double()

double rc_get_random_double ( void  )

Returns a random double-precision floating point number between -1 and 1.

Uses standard C rand function and bitwise operations which is much faster than doing floating point arithmetic.

Returns
random double-precision floating point number between -1 and 1

◆ rc_saturate_float()

int rc_saturate_float ( float *  val,
float  min,
float  max 
)

Modifies val to be bounded between between min and max.

Parameters
valThe value to be checked and possibly modified
[in]minThe lower bound
[in]maxThe upper bound
Returns
Returns 1 if saturation occurred, 0 if val was already in bound, and -1 if min was falsely larger than max.

◆ rc_saturate_double()

int rc_saturate_double ( double *  val,
double  min,
double  max 
)

Modifies val to be bounded between between min and max.

Parameters
valThe value to be checked and possibly modified
[in]minThe lower bound
[in]maxThe upper bound
Returns
Returns 1 if saturation occurred, 0 if val was already in bound, and -1 if min was falsely larger than max.
Examples:
rc_balance.c.