00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #ifndef SGE_MATH_CONSTANTS_HPP_INCLUDED
00022 #define SGE_MATH_CONSTANTS_HPP_INCLUDED
00023
00024 #include <cmath>
00025
00026 #ifndef M_PI
00027 #define M_PI 3.1415926535897932384626433832795028841971693993751058
00028 #endif
00029
00030 namespace sge
00031 {
00032 namespace math
00033 {
00034
00035 const double PI = M_PI;
00036 const long double PI_L =
00037 3.1415926535897932384626433832795028841971693993751058L;
00038 const double DEGREE =
00039 0.0174532925199432957692369076848861271344287188854172;
00040 const long double DEGREE_L =
00041 0.0174532925199432957692369076848861271344287188854172L;
00042
00043 template<typename T>
00044 inline T pi()
00045 {
00046 return static_cast<T>(PI_L);
00047 }
00048
00049 template<typename T>
00050 inline T twopi()
00051 {
00052 return static_cast<T>(2) * pi<T>();
00053 }
00054
00055 template<typename T>
00056 inline T deg_to_rad(const T deg)
00057 {
00058 return deg * PI / static_cast<T>(180);
00059 }
00060
00061 template<typename T>
00062 inline T rad_to_deg(const T rad)
00063 {
00064 return rad * static_cast<T>(180) / PI;
00065 }
00066
00067 }
00068
00069 }
00070
00071 #endif