diff --git a/panda/src/linmath/deg_2_rad.h b/panda/src/linmath/deg_2_rad.h index 77f2307df2..7f7b8ab9c2 100644 --- a/panda/src/linmath/deg_2_rad.h +++ b/panda/src/linmath/deg_2_rad.h @@ -24,11 +24,11 @@ #include "mathNumbers.h" BEGIN_PUBLISH -INLINE_LINMATH double deg_2_rad( double f ) { return f * (MathNumbers::pi / 180.0); } -INLINE_LINMATH double rad_2_deg( double f ) { return f * (180.0 / MathNumbers::pi); } +INLINE_LINMATH double deg_2_rad( double f ) { return f * MathNumbers::deg_2_rad; } +INLINE_LINMATH double rad_2_deg( double f ) { return f * MathNumbers::rad_2_deg; } -INLINE_LINMATH float deg_2_rad( float f ) { return f * (MathNumbers::pi_f / 180.0f); } -INLINE_LINMATH float rad_2_deg( float f ) { return f * (180.0f / MathNumbers::pi_f); } +INLINE_LINMATH float deg_2_rad( float f ) { return f * MathNumbers::deg_2_rad_f; } +INLINE_LINMATH float rad_2_deg( float f ) { return f * MathNumbers::rad_2_deg_f; } END_PUBLISH #endif diff --git a/panda/src/linmath/mathNumbers.cxx b/panda/src/linmath/mathNumbers.cxx index a3190973f5..5cffb5e9bb 100644 --- a/panda/src/linmath/mathNumbers.cxx +++ b/panda/src/linmath/mathNumbers.cxx @@ -21,6 +21,11 @@ const double MathNumbers::pi = 4.0 * atan(1.0); const double MathNumbers::ln2 = log(2.0); +const double MathNumbers::rad_2_deg = 180.0 / MathNumbers::pi; +const double MathNumbers::deg_2_rad = MathNumbers::pi / 180.0; const float MathNumbers::pi_f = 4.0 * atan(1.0); const float MathNumbers::ln2_f = log(2.0); +const float MathNumbers::rad_2_deg_f = 180.0 / MathNumbers::pi; +const float MathNumbers::deg_2_rad_f = MathNumbers::pi / 180.0; + diff --git a/panda/src/linmath/mathNumbers.h b/panda/src/linmath/mathNumbers.h index 580640f07a..2c6d64b1f5 100644 --- a/panda/src/linmath/mathNumbers.h +++ b/panda/src/linmath/mathNumbers.h @@ -23,10 +23,14 @@ class EXPCL_PANDA MathNumbers { PUBLISHED: static const float pi_f; + static const float rad_2_deg_f; + static const float deg_2_rad_f; static const float ln2_f; static const double pi; static const double ln2; + static const double rad_2_deg; + static const double deg_2_rad; }; #endif