José Claudio / Mbed 2 deprecated QuadCopter-Sensor-Serial

Dependencies:   mbed

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers Util.cpp Source File

Util.cpp

00001 #include "Util.h"
00002 
00003 int clampInt(int value, int min, int max)
00004 {
00005     if (value < min)
00006         return min;
00007     else if (value > max)
00008         return max;
00009         
00010     return value;
00011 }
00012 
00013 float clampFloat(float value, float min, float max)
00014 {
00015     if (value < min)
00016         return min;
00017     else if (value > max)
00018         return max;
00019         
00020     return value;
00021 }
00022 /*
00023 float abs(float value)
00024 {
00025     if(value < 0)
00026         return ((-1)*value);
00027  
00028     return value;
00029 }
00030 */
00031 float norm(float val1, float val2, float val3)
00032 {
00033     return sqrt(pow(val1,2)+pow(val2,2)+pow(val3,2));
00034 }