Main Page | Modules | Class Hierarchy | Alphabetical List | Data Structures | File List | Data Fields | Globals | Related Pages

Common math functions
[Definitions automatically generated by otStudio]


Defines

#define _ceilPos(X)   ((X - (int)(X)) > 0 ? (int)(X + 1) : (int)(X))
 Ceil macro.
#define _ceilNeg(X)   ((X - (int)(X)) < 0 ? (int)(X - 1) : (int)(X))
#define _ceil(X)   ( ((X) > 0) ? _ceilPos(X) : _ceilNeg(X) )

Functions

int _rand (void)
 Returns a pseudo-random integral number in the range between 0 and 32767. This number is generated by an algorithm that returns a sequence of apparently non-related numbers each time it is called. This algorithm uses a seed to generate the series, which should be initialized to some distinctive value using function _srand.
void _srand (unsigned int seed)
 The pseudo-random number generator is initialized using the argument passed as seed. For every different seed value used in a call to srand, the pseudo-random number generator can be expected to generate a different succession of results in the subsequent calls to _rand.
long map (long x, long in_min, long in_max, long out_min, long out_max)
 Re-maps a number from one range to another. From Arduino project.
float _floor (float num)
 Floor function.

Define Documentation

#define _ceil  )     ( ((X) > 0) ? _ceilPos(X) : _ceilNeg(X) )
 

#define _ceilNeg  )     ((X - (int)(X)) < 0 ? (int)(X - 1) : (int)(X))
 

#define _ceilPos  )     ((X - (int)(X)) > 0 ? (int)(X + 1) : (int)(X))
 


Function Documentation

float _floor float  num  ) 
 

int _rand void   ) 
 

Returns:
An integer value between 0 and 32767

void _srand unsigned int  seed  ) 
 

Parameters:
seed An integer value to be used as seed by the pseudo-random number generator algorithm.

long map long  x,
long  in_min,
long  in_max,
long  out_min,
long  out_max
 

Parameters:
x The number to map.
in_min The lower bound of the value's current range.
in_max The upper bound of the value's current range.
out_min The lower bound of the value's target range.
out_max The upper bound of the value's target range.
Returns:
The mapped value.
footer

otStudio - Library Reference - (C) 2020-23 Officina Turini, All Rights Reserved
Document built with Doxygen 1.4.0