Six crescent shaped legs

Dependencies:   mbed

Math.hpp

Committer:
sim642
Date:
2016-04-12
Revision:
17:cb8ad2fc76e5
Child:
18:1437610bea8b

File content as of revision 17:cb8ad2fc76e5:

#ifndef MATH_H
#define MATH_H

#include <cmath>

template<typename T>
T min(T a, T b)
{
    return a < b ? a : b;
}

template<typename T>
T max(T a, T b)
{
    return a > b ? a : b;
}

template<typename T>
T clamp(T val, T low, T high)
{
    return min(max(val, low), high);
}

template<typename T>
T clampAmplitude(T val, T amp)
{
    amp = std::abs(amp); // ensure order
    return clamp(val, -amp, amp);
}

#endif // MATH_H