Quadcopter working with accelerômeter and accelerometer, and bluetooth radio for communication

Dependencies:   mbed

Util.cpp

Committer:
jose_claudiojr
Date:
2013-05-21
Revision:
0:56b8c86181b1

File content as of revision 0:56b8c86181b1:

#include "Util.h"

int clampInt(int value, int min, int max)
{
    if (value < min)
        return min;
    else if (value > max)
        return max;
        
    return value;
}

float clampFloat(float value, float min, float max)
{
    if (value < min)
        return min;
    else if (value > max)
        return max;
        
    return value;
}
/*
float abs(float value)
{
    if(value < 0)
        return ((-1)*value);
 
    return value;
}
*/
float norm(float val1, float val2, float val3)
{
    return sqrt(pow(val1,2)+pow(val2,2)+pow(val3,2));
}