00001
00002
00003
00004
00005
00006
00007
00008 #ifndef FE_UTILS_H_
00009 #define FE_UTILS_H_
00010
00011 #include <stdlib.h>
00012
00013 const float pi = 3.14159;
00014 const float twopi = 2.0 * pi;
00015
00016 inline float clamp(float value, float lower, float upper){
00017 if (value > upper)
00018 return upper;
00019 if(value < lower)
00020 return lower;
00021 return value;
00022 }
00023
00024 inline float makeAnglePosNeg(float angle)
00025 {
00026
00027 while (angle > pi)
00028 angle -= twopi;
00029 while (angle < -pi)
00030 angle += twopi;
00031
00032 return angle;
00033 }
00034
00035 inline float differenceBetweenAngles(float angle1, float angle2){
00036 return makeAnglePosNeg(angle1 - angle2);
00037 }
00038
00039 inline float feet(float x){
00040 return 0.3048 * x;
00041 }
00042 inline float meters(float x){
00043 return x;
00044 }
00045
00046 inline float knots(float x) {
00047 return 0.514444444 * x;
00048 }
00049 inline float feetPerSecondSquared(float x) {
00050 return 0.3048 * x;
00051 }
00052
00053 inline float degreesPerSecond(float x) {
00054 return 0.0174532925 * x;
00055 }
00056
00057 inline float tons(float x){
00058 return x * 907.18474;
00059 }
00060 inline float pounds(float x){
00061 return x * 0.45359237;
00062 }
00063
00064 inline int randInt(int low, int high) {
00065 return low + random() % (high - low);
00066 }
00067
00068 #include <boost/date_time/posix_time/posix_time.hpp>
00069 using namespace boost::posix_time;
00070
00071 inline ptime getCurrentTime(){
00072 return boost::posix_time::microsec_clock::local_time();
00073 }
00074
00075
00076
00077 #endif