aboutsummaryrefslogtreecommitdiff
path: root/src/projects.h
diff options
context:
space:
mode:
authorMicah Cochran <micahcochran@users.noreply.github.com>2016-05-28 11:26:35 -0500
committerMicah Cochran <micahcochran@users.noreply.github.com>2016-05-28 11:26:35 -0500
commit3043b2f7fcf4471983c8d4472b17ccf9df1710c8 (patch)
tree94e63e8367dad31a6f0fe1703050d0ad79340785 /src/projects.h
parenta112ea3172e89230fa307567be3d70e286b1eeb5 (diff)
downloadPROJ-3043b2f7fcf4471983c8d4472b17ccf9df1710c8.tar.gz
PROJ-3043b2f7fcf4471983c8d4472b17ccf9df1710c8.zip
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).
Diffstat (limited to 'src/projects.h')
-rw-r--r--src/projects.h20
1 files changed, 15 insertions, 5 deletions
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