From 3043b2f7fcf4471983c8d4472b17ccf9df1710c8 Mon Sep 17 00:00:00 2001 From: Micah Cochran Date: Sat, 28 May 2016 11:26:35 -0500 Subject: Change math constants, similar to PR #372. Use M_ namespace with the de facto standard M_PI and its ilk. Change names that are widely used in the project to be in the M_ namespace, so HALFPI becomes M_HALFPI. HALFPI is #defined as M_PI_2 (the defacto standard name). #defines _USE_MATH_DEFINES for MS Visual Studio (I didn't personally test this part, but Appveyor will not build otherwise). --- src/projects.h | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) (limited to 'src/projects.h') diff --git a/src/projects.h b/src/projects.h index 2957f848..e7b62700 100644 --- a/src/projects.h +++ b/src/projects.h @@ -92,11 +92,21 @@ extern double hypot(double, double); # define hypot _hypot #endif - /* some useful constants */ -#define HALFPI 1.5707963267948966 -#define FORTPI 0.78539816339744833 -#define PI 3.14159265358979323846 -#define TWOPI 6.2831853071795864769 +/* enable predefined math constants M_* for MS Visual Studio workaround */ +#ifdef _MSC_VER +#define _USE_MATH_DEFINES +#endif + +/* some more useful math constants and aliases */ +#define M_FORTPI M_PI_4 /* pi/4 */ +#define M_HALFPI M_PI_2 /* pi/2 */ +/* M_PI pi */ +#define M_PI_HALFPI 4.71238898038468985766 /* 1.5*pi */ +#define M_TWOPI 6.28318530717958647693 /* 2*pi */ +#define M_TWO_D_PI M_2_PI /* 2/pi */ +#define M_TWOPI_HALFPI 7.85398163397448309616 /* 2.5*pi */ +/* M_SQRT2 sqrt(2) */ + /* maximum tag id length for +init and default files */ #ifndef ID_TAG_MAX -- cgit v1.2.3