as

Dependencies:   CommonTypes ESC Matrix PID Servo kalman mbed-rtos mbed

Fork of Nucleo_MPU_9250_ by Alan Huchin Herrera

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers MathFuncs.h Source File

MathFuncs.h

00001 /*
00002  * SOURCE FILE : MathFuncs.h
00003  *
00004  * Definition of class MathFuncs.
00005  *
00006  */
00007 
00008 #ifndef MathFuncsDefined
00009 
00010     #define MathFuncsDefined
00011     
00012     #include "Types.h"
00013     
00014     /** Various useful maths related functions. */
00015     class MathFuncs {
00016     
00017     public :
00018 
00019         /** Constrain a number to be between 2 values.
00020          *
00021          * @param x Number to constrain.
00022          * @param min Minimum value.
00023          * @param max Maximum value.
00024          * @returns A number between min and max.
00025          */
00026         static Int16 Constrain( Int16 x, Int16 min, Int16 max ) {
00027             if( x < min ) {
00028                 return min;
00029             }
00030             else if( x > max ) {
00031                 return max;
00032             }
00033             else {
00034                 return x;
00035             }
00036         }
00037             
00038     };
00039 
00040 #endif
00041 
00042 /* END of MathFuncs.h */
00043