00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018 #ifndef _CONVERSIONS_H_
00019 #define _CONVERSIONS_H_
00020
00021 #include <vamos/geometry/Constants.h>
00022
00023 #include <algorithm>
00024
00025
00026
00027 #ifdef WIN32
00028 # undef min
00029 # undef max
00030 #endif
00031
00032 namespace Vamos_Geometry
00033 {
00034 inline double rad_to_deg (double rad) { return rad * 180.0 / pi; }
00035 inline double deg_to_rad (double deg) { return deg * pi / 180.0; }
00036
00037 inline double rad_s_to_rpm (double rad_s) { return rad_s * 30.0 / pi; }
00038 inline double rpm_to_rad_s (double rpm) { return rpm * pi / 30.0; }
00039
00040 inline double m_s_to_km_h (double m_s) { return m_s * 3.6; }
00041 inline double km_h_to_m_s (double km_h) { return km_h / 3.6; }
00042
00043 template <typename T> T clip (T value, T low, T high)
00044 { return std::max (std::min (value, high), low); }
00045
00046 template <typename T> T sign (T value)
00047 { return value == 0 ? 0 : (value > 0 ? 1 : -1); }
00048 }
00049
00050 #endif